mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-18 14:52:46 +00:00
Compare commits
5 Commits
89-push-no
...
81-automat
| Author | SHA1 | Date | |
|---|---|---|---|
|
f8efb7db57
|
|||
|
2a1a7a5d5b
|
|||
|
|
a69b80d1d4 | ||
|
e2abc983ef
|
|||
|
913193abdb
|
5
.changeset/rich-rats-guess.md
Normal file
5
.changeset/rich-rats-guess.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@openstapps/backend": patch
|
||||
---
|
||||
|
||||
fix for geo.point mapping
|
||||
@@ -1,11 +1,5 @@
|
||||
# @openstapps/backend
|
||||
|
||||
## 3.3.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 67ab1fd6: fix for geo.point mapping
|
||||
|
||||
## 3.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/backend",
|
||||
"description": "A reference implementation for a StApps backend",
|
||||
"version": "3.3.1",
|
||||
"version": "3.3.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
@@ -106,9 +106,6 @@
|
||||
"entry": [
|
||||
"src/cli.ts"
|
||||
],
|
||||
"loader": {
|
||||
".groovy": "text"
|
||||
},
|
||||
"sourcemap": true,
|
||||
"clean": true,
|
||||
"target": "es2022",
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
void traverse(def a, def b, ArrayList path, HashMap result) {
|
||||
if (a instanceof Map && b instanceof Map) {
|
||||
for (key in a.keySet()) {
|
||||
path.add(key);
|
||||
traverse(a.get(key), b.get(key), path, result);
|
||||
path.remove(path.size() - 1);
|
||||
}
|
||||
} else if (a instanceof List && b instanceof List) {
|
||||
int la = a.size();
|
||||
int lb = b.size();
|
||||
int max = la > lb ? la : lb;
|
||||
for (int i = 0; i < max; i++) {
|
||||
path.add(i);
|
||||
if (i < la && i < lb) {
|
||||
traverse(a[i], b[i], path, result);
|
||||
} else if (i >= la) {
|
||||
result.added.add(path.toArray());
|
||||
} else {
|
||||
result.removed.add(path.toArray());
|
||||
}
|
||||
path.remove(path.size() - 1);
|
||||
}
|
||||
} else if (a == null && b != null) {
|
||||
result.removed.add(path.toArray());
|
||||
} else if (a != null && b == null) {
|
||||
result.added.add(path.toArray());
|
||||
} else if (!a.equals(b)) {
|
||||
result.changed.add(path.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
def to;
|
||||
def from;
|
||||
|
||||
for (state in states) {
|
||||
if (state.index.equals(params.newIndex)) {
|
||||
to = state.doc;
|
||||
} else {
|
||||
from = state.doc;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap result = [
|
||||
'added': [],
|
||||
'removed': [],
|
||||
'changed': []
|
||||
];
|
||||
|
||||
traverse(to, from, new ArrayList(), result);
|
||||
|
||||
if (to == null && from != null) {
|
||||
result.status = 'removed';
|
||||
} else if (to != null && from == null) {
|
||||
result.status = 'added';
|
||||
} else if (
|
||||
result.added.size() == 0 &&
|
||||
result.removed.size() == 0 &&
|
||||
result.changed.size() == 0
|
||||
) {
|
||||
result.status = 'unchanged';
|
||||
} else {
|
||||
result.status = 'changed';
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -47,7 +47,6 @@ import {
|
||||
import {noUndefined} from './util/no-undefined.js';
|
||||
import {retryCatch, RetryOptions} from './util/retry.js';
|
||||
import {Feature, Point, Polygon} from 'geojson';
|
||||
import indexDiffScript from './diff-index.groovy';
|
||||
|
||||
/**
|
||||
* A database interface for elasticsearch
|
||||
@@ -240,42 +239,6 @@ export class Elasticsearch implements Database {
|
||||
.then(it => Object.entries(it).map(([name]) => name))
|
||||
.catch(() => [] as string[]);
|
||||
|
||||
if (activeIndices.length <= 1) {
|
||||
const result = await this.client.transform.previewTransform({
|
||||
source: {
|
||||
index: [...activeIndices, index],
|
||||
query: {match_all: {}},
|
||||
},
|
||||
dest: {index: 'compare'},
|
||||
pivot: {
|
||||
group_by: {
|
||||
uid: {terms: {field: 'uid.raw'}},
|
||||
},
|
||||
aggregations: {
|
||||
compare: {
|
||||
scripted_metric: {
|
||||
map_script: `
|
||||
state.index = doc['_index'];
|
||||
state.doc = params['_source'];`,
|
||||
combine_script: `
|
||||
state.index = state.index[0];
|
||||
return state;
|
||||
`,
|
||||
reduce_script: {
|
||||
source: indexDiffScript,
|
||||
params: {
|
||||
newIndex: index,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
console.log(JSON.stringify(result.preview, null, 2))
|
||||
}
|
||||
|
||||
await this.client.indices.updateAliases({
|
||||
actions: [
|
||||
{
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// initialize the sort value with the maximum
|
||||
double price = Double.MAX_VALUE;
|
||||
|
||||
// if we have any offers
|
||||
if (params._source.containsKey(params.field)) {
|
||||
// iterate through all offers
|
||||
for (offer in params._source[params.field]) {
|
||||
// if this offer contains a role specific price
|
||||
if (offer.containsKey('prices') && offer.prices.containsKey(params.universityRole)) {
|
||||
// if the role specific price is smaller than the cheapest we found
|
||||
if (offer.prices[params.universityRole] < price) {
|
||||
// set the role specific price as cheapest for now
|
||||
price = offer.prices[params.universityRole];
|
||||
}
|
||||
} else { // we have no role specific price for our role in this offer
|
||||
// if the default price of this offer is lower than the cheapest we found
|
||||
if (offer.price < price) {
|
||||
// set this price as the cheapest
|
||||
price = offer.price;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return cheapest price for our role
|
||||
return price;
|
||||
@@ -13,8 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SortOptions} from '@elastic/elasticsearch/lib/api/types.js';
|
||||
import {SCPriceSort} from '@openstapps/core';
|
||||
import priceSortScript from './price-sort.groovy';
|
||||
import {SCPriceSort, SCSportCoursePriceGroup, SCThingsField} from '@openstapps/core';
|
||||
|
||||
/**
|
||||
* Converts a price sort to elasticsearch syntax
|
||||
@@ -24,11 +23,47 @@ export function buildPriceSort(sort: SCPriceSort): SortOptions {
|
||||
return {
|
||||
_script: {
|
||||
order: sort.order,
|
||||
script: {
|
||||
source: priceSortScript,
|
||||
params: sort.arguments,
|
||||
},
|
||||
script: buildPriceSortScript(sort.arguments.universityRole, sort.arguments.field),
|
||||
type: 'number' as const,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a script for sorting search results by prices
|
||||
* @param universityRole User group which consumes university services
|
||||
* @param field Field in which wanted offers with prices are located
|
||||
*/
|
||||
export function buildPriceSortScript(
|
||||
universityRole: keyof SCSportCoursePriceGroup,
|
||||
field: SCThingsField,
|
||||
): string {
|
||||
return `
|
||||
// initialize the sort value with the maximum
|
||||
double price = Double.MAX_VALUE;
|
||||
|
||||
// if we have any offers
|
||||
if (params._source.containsKey('${field}')) {
|
||||
// iterate through all offers
|
||||
for (offer in params._source.${field}) {
|
||||
// if this offer contains a role specific price
|
||||
if (offer.containsKey('prices') && offer.prices.containsKey('${universityRole}')) {
|
||||
// if the role specific price is smaller than the cheapest we found
|
||||
if (offer.prices.${universityRole} < price) {
|
||||
// set the role specific price as cheapest for now
|
||||
price = offer.prices.${universityRole};
|
||||
}
|
||||
} else { // we have no role specific price for our role in this offer
|
||||
// if the default price of this offer is lower than the cheapest we found
|
||||
if (offer.price < price) {
|
||||
// set this price as the cheapest
|
||||
price = offer.price;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return cheapest price for our role
|
||||
return price;
|
||||
`;
|
||||
}
|
||||
|
||||
6
backend/backend/src/types.d.ts
vendored
6
backend/backend/src/types.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
declare module '*.groovy' {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -22,7 +22,7 @@ const config = {
|
||||
'plugin:unicorn/recommended',
|
||||
'prettier',
|
||||
],
|
||||
plugins: ['eslint-plugin-unicorn', 'eslint-plugin-jsdoc'],
|
||||
plugins: ['eslint-plugin-unicorn', 'eslint-plugin-jsdoc', 'header'],
|
||||
settings: {
|
||||
jsdoc: {
|
||||
mode: 'typescript',
|
||||
@@ -36,6 +36,7 @@ const config = {
|
||||
'unicorn/prefer-node-protocol': 'off',
|
||||
'unicorn/no-process-exit': 'off',
|
||||
'unicorn/no-array-reduce': 'off',
|
||||
'unicorn/prefer-event-target': 'off',
|
||||
'unicorn/prevent-abbreviations': [
|
||||
'error',
|
||||
{
|
||||
@@ -77,6 +78,27 @@ const config = {
|
||||
},
|
||||
],
|
||||
|
||||
'header/header': [
|
||||
2,
|
||||
'block',
|
||||
[
|
||||
'',
|
||||
' * Copyright (C) 2023 StApps',
|
||||
' * This program is free software: you can redistribute it and/or modify it',
|
||||
' * under the terms of the GNU General Public License as published by the Free',
|
||||
' * Software Foundation, version 3.',
|
||||
' *',
|
||||
' * This program is distributed in the hope that it will be useful, but WITHOUT',
|
||||
' * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or',
|
||||
' * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for',
|
||||
' * more details.',
|
||||
' *',
|
||||
' * You should have received a copy of the GNU General Public License along with',
|
||||
' * this program. If not, see <https://www.gnu.org/licenses/>.',
|
||||
' ',
|
||||
],
|
||||
],
|
||||
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
Copyright (C) {{year}} {{author}}
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
@@ -22,11 +22,13 @@
|
||||
"typescript": "5.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "7.2.0",
|
||||
"@typescript-eslint/parser": "7.2.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-jsdoc": "48.2.1",
|
||||
"eslint-plugin-unicorn": "51.0.1"
|
||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||
"@typescript-eslint/parser": "5.60.1",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-plugin-jsdoc": "46.4.2",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-unicorn": "47.0.0",
|
||||
"eslint-plugin-header": "3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
0
examples/minimal-connector/app.js
Executable file → Normal file
0
examples/minimal-connector/app.js
Executable file → Normal file
@@ -1,2 +1,3 @@
|
||||
src/app/_helpers/data
|
||||
node_modules
|
||||
src/index.html
|
||||
|
||||
@@ -1,76 +1,43 @@
|
||||
{
|
||||
"root": true,
|
||||
"ignorePatterns": ["projects/**/*"],
|
||||
"extends": ["@openstapps/eslint-config"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module",
|
||||
"project": ["tsconfig.json", "tsconfig.spec.json", "cypress/tsconfig.json"],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@angular-eslint/recommended",
|
||||
"plugin:@angular-eslint/template/process-inline-templates",
|
||||
"plugin:jsdoc/recommended",
|
||||
"plugin:unicorn/recommended",
|
||||
"prettier"
|
||||
"plugin:@angular-eslint/template/process-inline-templates"
|
||||
],
|
||||
"plugins": ["eslint-plugin-unicorn", "eslint-plugin-jsdoc"],
|
||||
"settings": {
|
||||
"jsdoc": {
|
||||
"mode": "typescript"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"unicorn/filename-case": "error",
|
||||
"unicorn/no-array-reduce": "off",
|
||||
"unicorn/no-array-callback-reference": "off",
|
||||
"unicorn/no-await-expression-member": "off",
|
||||
"unicorn/prefer-object-from-entries": "off",
|
||||
"unicorn/prefer-node-protocol": "off",
|
||||
"unicorn/no-process-exit": "off",
|
||||
"unicorn/prefer-event-target": "off",
|
||||
"unicorn/prevent-abbreviations": [
|
||||
"warn",
|
||||
{
|
||||
"replacements": {
|
||||
"ref": false,
|
||||
"i": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"unicorn/no-nested-ternary": "off",
|
||||
"unicorn/better-regex": "off",
|
||||
"unicorn/no-non-null-assertion": "off",
|
||||
"unicorn/consistent-function-scoping": ["error", {"checkArrowFunctions": false}],
|
||||
"jsdoc/no-types": "error",
|
||||
"jsdoc/require-param": "off",
|
||||
"jsdoc/require-param-description": "error",
|
||||
"jsdoc/check-param-names": "error",
|
||||
"jsdoc/require-returns": "off",
|
||||
"jsdoc/require-param-type": "off",
|
||||
"jsdoc/require-returns-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"args": "after-used",
|
||||
"argsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/lines-between-class-members": ["error", "always"],
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@angular-eslint/use-lifecycle-interface": "error"
|
||||
"@angular-eslint/use-lifecycle-interface": "error",
|
||||
"no-console": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["*.html"],
|
||||
"extends": ["plugin:@angular-eslint/template/recommended", "prettier"]
|
||||
"plugins": ["header"],
|
||||
"extends": ["plugin:@angular-eslint/template/recommended", "prettier"],
|
||||
"rules": {
|
||||
"header/header": [
|
||||
2,
|
||||
"block-html",
|
||||
[
|
||||
"~ Copyright (C) 2023 StApps",
|
||||
" ~ This program is free software: you can redistribute it and/or modify it",
|
||||
" ~ under the terms of the GNU General Public License as published by the Free",
|
||||
" ~ Software Foundation, version 3.",
|
||||
" ~",
|
||||
" ~ This program is distributed in the hope that it will be useful, but WITHOUT",
|
||||
" ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or",
|
||||
" ~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for",
|
||||
" ~ more details.",
|
||||
" ~",
|
||||
" ~ You should have received a copy of the GNU General Public License along with",
|
||||
" ~ this program. If not, see <https://www.gnu.org/licenses/>."
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
"@ionic/angular-toolkit": "11.0.1",
|
||||
"@ionic/cli": "7.2.0",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/fontkit": "2.0.7",
|
||||
"@types/geojson": "1.0.6",
|
||||
@@ -154,11 +155,6 @@
|
||||
"@typescript-eslint/parser": "7.2.0",
|
||||
"cordova-res": "0.15.4",
|
||||
"cypress": "13.7.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-plugin-jsdoc": "48.2.1",
|
||||
"eslint-plugin-prettier": "5.1.3",
|
||||
"eslint-plugin-unicorn": "51.0.1",
|
||||
"fast-deep-equal": "3.1.3",
|
||||
"fontkit": "2.0.2",
|
||||
"glob": "10.3.10",
|
||||
"http-server": "14.1.1",
|
||||
|
||||
@@ -25,6 +25,8 @@ import {PAIAPatron} from '../../types';
|
||||
export class ProfilePageComponent {
|
||||
patron?: PAIAPatron;
|
||||
|
||||
propertiesToShow: (keyof PAIAPatron)[] = ['id', 'name', 'email', 'address', 'expires'];
|
||||
|
||||
constructor(private readonly libraryAccountService: LibraryAccountService) {}
|
||||
|
||||
async ionViewWillEnter(): Promise<void> {
|
||||
|
||||
@@ -26,45 +26,27 @@
|
||||
<ion-card>
|
||||
<ion-card-content>
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col> {{ 'library.account.pages.profile.labels.id' | translate }}: </ion-col>
|
||||
<ion-col>
|
||||
{{ patron.id }}
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row>
|
||||
<ion-col> {{ 'library.account.pages.profile.labels.name' | translate }}: </ion-col>
|
||||
<ion-col> {{ patron.name_details?.title ?? '' }} {{ patron.name }} </ion-col>
|
||||
</ion-row>
|
||||
@if (patron.email) {
|
||||
<ion-row>
|
||||
<ion-col> {{ 'library.account.pages.profile.labels.email' | translate }}: </ion-col>
|
||||
<ion-col>
|
||||
{{ patron.email }}
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
}
|
||||
@if (patron.address) {
|
||||
<ion-row>
|
||||
<ion-col> {{ 'library.account.pages.profile.labels.address' | translate }}: </ion-col>
|
||||
<ion-col>
|
||||
{{ patron.address }}
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
}
|
||||
@if (patron.expires) {
|
||||
<ion-row>
|
||||
<ion-col> {{ 'library.account.pages.profile.labels.expires' | translate }}: </ion-col>
|
||||
<ion-col>
|
||||
@if (isUnlimitedExpiry(patron.expires)) {
|
||||
{{ 'library.account.pages.profile.values.unlimited' | translate }}
|
||||
} @else {
|
||||
{{ 'library.account.pages.profile.values.expires' | translate }}: {{
|
||||
patron.expires | amDateFormat: 'll'
|
||||
}}
|
||||
}
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
@for (property of propertiesToShow; track property) {
|
||||
@if (patron[property]) {
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
{{ 'library.account.pages.profile.labels' + '.' + property | translate }}:
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
@if (!['expires'].includes(property)) {
|
||||
{{ patron[property] }}
|
||||
} @else {
|
||||
@if (isUnlimitedExpiry(patron['expires'])) {
|
||||
{{ 'library.account.pages.profile.values.unlimited' | translate }}
|
||||
} @else {
|
||||
{{ 'library.account.pages.profile.values.expires' | translate }}: {{
|
||||
patron['expires'] | amDateFormat: 'll'
|
||||
}}
|
||||
}
|
||||
}
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
}
|
||||
}
|
||||
</ion-grid>
|
||||
</ion-card-content>
|
||||
|
||||
@@ -22,13 +22,6 @@ export interface PAIAPatron {
|
||||
status?: PAIAPatronStatus;
|
||||
type?: string;
|
||||
note?: string;
|
||||
// HeBIS specific property (not in PAIA documentation)
|
||||
name_details?: {
|
||||
firstname?: string;
|
||||
lastname?: string;
|
||||
gender?: string;
|
||||
title?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export enum PAIAPatronStatus {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const environment = {
|
||||
backend_url: 'https://mobile.server.uni-frankfurt.de',
|
||||
app_host: 'mobile.app.uni-frankfurt.de',
|
||||
custom_url_scheme: 'de.anyschool.app',
|
||||
backend_version: '3.3.0',
|
||||
backend_version: '999.0.0',
|
||||
production: true,
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const environment = {
|
||||
backend_url: 'https://mobile.server.uni-frankfurt.de',
|
||||
app_host: 'mobile.app.uni-frankfurt.de',
|
||||
custom_url_scheme: 'de.anyschool.app',
|
||||
backend_version: '3.3.0',
|
||||
backend_version: '999.0.0',
|
||||
production: false,
|
||||
};
|
||||
|
||||
|
||||
@@ -43,5 +43,10 @@
|
||||
"turbo-ignore": "1.10.16",
|
||||
"typedoc": "0.25.12",
|
||||
"typescript": "5.4.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"eslint-plugin-header@3.1.1": "patches/eslint-plugin-header@3.1.1.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
patches/eslint-plugin-header@3.1.1.patch
Normal file
41
patches/eslint-plugin-header@3.1.1.patch
Normal file
@@ -0,0 +1,41 @@
|
||||
diff --git a/lib/rules/header.js b/lib/rules/header.js
|
||||
index 3504b6fc59b780674e652ad1ca944cb3577b8fed..d86dc0b490845c22f54ae83dbc52efcf448e628b 100644
|
||||
--- a/lib/rules/header.js
|
||||
+++ b/lib/rules/header.js
|
||||
@@ -27,6 +27,9 @@ function excludeShebangs(comments) {
|
||||
// check if they are at the start of the file since that is already checked by
|
||||
// hasHeader().
|
||||
function getLeadingComments(context, node) {
|
||||
+ if (!node.body) {
|
||||
+ return context.getSourceCode().ast.comments;
|
||||
+ }
|
||||
var all = excludeShebangs(context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node));
|
||||
if (all[0].type.toLowerCase() === "block") {
|
||||
return [all[0]];
|
||||
@@ -44,6 +47,8 @@ function genCommentBody(commentType, textArray, eol, numNewlines) {
|
||||
var eols = eol.repeat(numNewlines);
|
||||
if (commentType === "block") {
|
||||
return "/*" + textArray.join(eol) + "*/" + eols;
|
||||
+ } else if (commentType === "block-html") {
|
||||
+ return "<!--\n " + textArray.join(eol) + "\n -->" + eols;
|
||||
} else {
|
||||
return "//" + textArray.join(eol + "//") + eols;
|
||||
}
|
||||
@@ -103,7 +108,7 @@ function hasHeader(src) {
|
||||
src = src.slice(m.index + m[0].length);
|
||||
}
|
||||
}
|
||||
- return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//";
|
||||
+ return src.substr(0, 2) === "/*" || src.substr(0, 2) === "//" || src.substr(0, 4) === "<!--";
|
||||
}
|
||||
|
||||
function matchesLineEndings(src, num) {
|
||||
@@ -180,7 +185,7 @@ module.exports = {
|
||||
message: "missing header",
|
||||
fix: canFix ? genPrependFixer(commentType, node, fixLines, eol, numNewlines) : null
|
||||
});
|
||||
- } else if (leadingComments[0].type.toLowerCase() !== commentType) {
|
||||
+ } else if (leadingComments[0].type.toLowerCase() !== commentType.replace(/-html$/, '')) {
|
||||
context.report({
|
||||
loc: node.loc,
|
||||
message: "header should be a {{commentType}} comment",
|
||||
5
pnpm-lock.yaml
generated
5
pnpm-lock.yaml
generated
@@ -4,6 +4,11 @@ settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
patchedDependencies:
|
||||
eslint-plugin-header@3.1.1:
|
||||
hash: pgohhqwij7scbwihbawhnhtg3i
|
||||
path: patches/eslint-plugin-header@3.1.1.patch
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
|
||||
Reference in New Issue
Block a user