Upgrade ESLint and fix linting issues
Some checks failed
test / lint (push) Has been cancelled
test / unit-tests (16.x) (push) Has been cancelled
test / unit-tests (18.x) (push) Has been cancelled
test / unit-tests (20.x) (push) Has been cancelled
test / unit-tests (22.x) (push) Has been cancelled
test / integration-tests (16.x) (push) Has been cancelled
test / integration-tests (18.x) (push) Has been cancelled
test / integration-tests (20.x) (push) Has been cancelled
test / integration-tests (22.x) (push) Has been cancelled
test / e2e-tests (18.x) (push) Has been cancelled

This commit is contained in:
Kristjan ESPERANTO 2025-02-16 23:48:29 +01:00 committed by Traines
parent afa99b0742
commit 6d1d0c626f
6 changed files with 459 additions and 469 deletions

View file

@ -1,54 +0,0 @@
{
"env": {
"es2021": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@stylistic/all-extends"],
"ignorePatterns": ["node_modules", "*example.js"],
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"rules": {
"curly": "error",
"no-implicit-coercion": "error",
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "none",
"ignoreRestSiblings": false
}
],
"@stylistic/array-bracket-newline": ["error", "consistent"],
"@stylistic/array-element-newline": ["error", "consistent"],
"@stylistic/arrow-parens": "off",
"@stylistic/comma-dangle": ["error", "always-multiline"],
"@stylistic/dot-location": ["error", "property"],
"@stylistic/function-call-argument-newline": ["error", "consistent"],
"@stylistic/function-paren-newline": "off",
"@stylistic/indent": ["error", "tab"],
"@stylistic/indent-binary-ops": ["error", "tab"],
"@stylistic/max-len": "off",
"@stylistic/multiline-ternary": ["error", "always-multiline"],
"@stylistic/newline-per-chained-call": ["error", { "ignoreChainWithDepth": 1 }],
"@stylistic/no-mixed-operators": "off",
"@stylistic/no-tabs": "off",
"@stylistic/object-property-newline": "off",
"@stylistic/one-var-declaration-per-line": "off",
"@stylistic/operator-linebreak": ["error", "before"],
"@stylistic/padded-blocks": "off",
"@stylistic/quote-props": ["error", "consistent-as-needed"],
"@stylistic/quotes": ["error", "single"]
},
"overrides": [
{
"files": [
"test/**"
],
"rules": {
"no-unused-vars": "off"
}
}
]
}

61
eslint.config.js Normal file
View file

@ -0,0 +1,61 @@
import eslintPluginJs from '@eslint/js';
import eslintPluginStylistic from '@stylistic/eslint-plugin';
import globals from 'globals';
const config = [
eslintPluginJs.configs.recommended,
eslintPluginStylistic.configs['all-flat'],
{
files: ['**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
globals: {
...globals.node,
},
sourceType: 'module',
},
rules: {
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/arrow-parens': 'off',
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/function-paren-newline': 'off',
'@stylistic/indent': ['error', 'tab'],
'@stylistic/indent-binary-ops': ['error', 'tab'],
'@stylistic/max-len': 'off',
'@stylistic/multiline-comment-style': 'off',
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
'@stylistic/newline-per-chained-call': ['error', {ignoreChainWithDepth: 1}],
'@stylistic/no-mixed-operators': 'off',
'@stylistic/no-tabs': 'off',
'@stylistic/object-property-newline': 'off',
'@stylistic/one-var-declaration-per-line': 'off',
'@stylistic/operator-linebreak': ['error', 'before'],
'@stylistic/padded-blocks': 'off',
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
'@stylistic/quotes': ['error', 'single'],
'curly': 'error',
'no-implicit-coercion': 'error',
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'none',
ignoreRestSiblings: false,
},
],
},
},
{
files: ['test/**', '**/example.js'],
rules: {
'no-unused-vars': 'off',
'@stylistic/semi': 'off',
},
},
];
export default config;

783
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -72,9 +72,9 @@
"@pollyjs/adapter-node-http": "^6.0.5", "@pollyjs/adapter-node-http": "^6.0.5",
"@pollyjs/core": "^6.0.5", "@pollyjs/core": "^6.0.5",
"@pollyjs/persister-fs": "^6.0.5", "@pollyjs/persister-fs": "^6.0.5",
"@stylistic/eslint-plugin": "^1.5.1", "@stylistic/eslint-plugin": "^3.1.0",
"db-rest": "github:derhuerst/db-rest", "db-rest": "github:derhuerst/db-rest",
"eslint": "^8.56.0", "eslint": "^9.20.1",
"hafas-rest-api": "^5.1.3", "hafas-rest-api": "^5.1.3",
"is-coordinates": "^2.0.2", "is-coordinates": "^2.0.2",
"is-roughly-equal": "^0.1.0", "is-roughly-equal": "^0.1.0",
@ -84,8 +84,8 @@
"validate-fptf": "^3.0.0" "validate-fptf": "^3.0.0"
}, },
"scripts": { "scripts": {
"lint": "eslint .", "lint": "eslint",
"lint:fix": "eslint . --fix", "lint:fix": "eslint --fix",
"test-unit": "tap test/lib/*.js test/*.js test/format/*.js test/parse/*.js", "test-unit": "tap test/lib/*.js test/*.js test/format/*.js test/parse/*.js",
"test-integration": "VCR_MODE=playback tap test/e2e/*.js", "test-integration": "VCR_MODE=playback tap test/e2e/*.js",
"test-integration:record": "VCR_MODE=record tap -t60 -j1 test/e2e/*.js", "test-integration:record": "VCR_MODE=record tap -t60 -j1 test/e2e/*.js",

View file

@ -16,11 +16,11 @@ const parseJourneyLeg = (ctx, pt, date, fallbackLocations) => { // pt = raw leg
const stops = pt.halte?.length && pt.halte || pt.stops?.length && pt.stops || []; const stops = pt.halte?.length && pt.halte || pt.stops?.length && pt.stops || [];
const res = { const res = {
origin: stops.length && profile.parseLocation(ctx, stops[0].ort || stops[0].station || stops[0]) origin: stops.length && profile.parseLocation(ctx, stops[0].ort || stops[0].station || stops[0])
|| pt.abgangsOrt?.name && profile.parseLocation(ctx, pt.abgangsOrt) || pt.abgangsOrt?.name && profile.parseLocation(ctx, pt.abgangsOrt)
|| locationFallback(pt.abfahrtsOrtExtId, pt.abfahrtsOrt, fallbackLocations), || locationFallback(pt.abfahrtsOrtExtId, pt.abfahrtsOrt, fallbackLocations),
destination: stops.length && profile.parseLocation(ctx, stops[stops.length - 1].ort || stops[stops.length - 1].station || stops[stops.length - 1]) destination: stops.length && profile.parseLocation(ctx, stops[stops.length - 1].ort || stops[stops.length - 1].station || stops[stops.length - 1])
|| pt.ankunftsOrt?.name && profile.parseLocation(ctx, pt.ankunftsOrt) || pt.ankunftsOrt?.name && profile.parseLocation(ctx, pt.ankunftsOrt)
|| locationFallback(pt.ankunftsOrtExtId, pt.ankunftsOrt, fallbackLocations), || locationFallback(pt.ankunftsOrtExtId, pt.ankunftsOrt, fallbackLocations),
}; };
const cancelledDep = stops.length && profile.parseCancelled(stops[0]); const cancelledDep = stops.length && profile.parseCancelled(stops[0]);

View file

@ -37,11 +37,11 @@ const parseRemarks = (ctx, ref) => {
let res = { let res = {
code: remark.code || remark.key || remark.id, code: remark.code || remark.key || remark.id,
summary: remark.nachrichtKurz || remark.value || remark.ueberschrift || remark.text || remark.shortText summary: remark.nachrichtKurz || remark.value || remark.ueberschrift || remark.text || remark.shortText
|| Object.values(remark.descriptions || {}) || Object.values(remark.descriptions || {})
.shift()?.textShort, .shift()?.textShort,
text: remark.nachrichtLang || remark.value || remark.text || remark.caption text: remark.nachrichtLang || remark.value || remark.text || remark.caption
|| Object.values(remark.descriptions || {}) || Object.values(remark.descriptions || {})
.shift()?.text, .shift()?.text,
type: type, type: type,
}; };
if (remark.modDateTime || remark.letzteAktualisierung) { if (remark.modDateTime || remark.letzteAktualisierung) {
@ -208,9 +208,9 @@ const parseCancelled = (ref) => {
|| ref.journeyCancelled || ref.journeyCancelled
|| (ref.risNotizen || ref.echtzeitNotizen || ref.meldungen) && Boolean( || (ref.risNotizen || ref.echtzeitNotizen || ref.meldungen) && Boolean(
(ref.risNotizen || ref.echtzeitNotizen || ref.meldungen).find(r => r.key == 'text.realtime.stop.cancelled' (ref.risNotizen || ref.echtzeitNotizen || ref.meldungen).find(r => r.key == 'text.realtime.stop.cancelled'
|| r.type == 'HALT_AUSFALL' || r.type == 'HALT_AUSFALL'
|| r.text == 'Halt entfällt' || r.text == 'Halt entfällt'
|| r.text == 'Stop cancelled', || r.text == 'Stop cancelled',
), ),
); );
}; };