Skip to content

Commit 920a918

Browse files
renovate[bot]MetRonnie
authored andcommitted
Migrate to ESLint flat config & neostandard
1 parent c3cd24d commit 920a918

File tree

14 files changed

+962
-798
lines changed

14 files changed

+962
-798
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
33
*
44
* This program is free software: you can redistribute it and/or modify
@@ -15,22 +15,29 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
/**
18+
/*
1919
* Eslint config for dist directory.
2020
*
2121
* Note: we can't keep it in there because it would get wiped by build.
2222
*/
23-
module.exports = {
24-
plugins: ['compat'],
25-
extends: ['plugin:compat/recommended'],
26-
env: {
27-
browser: true,
28-
},
29-
parserOptions: {
30-
sourceType: 'module',
31-
// Don't need to worry about ECMA syntax as that's handled by Vite/ESBuild
32-
ecmaVersion: 'latest',
23+
24+
import { defineConfig } from 'eslint/config'
25+
import globals from 'globals'
26+
import compatPlugin from 'eslint-plugin-compat'
27+
28+
export default defineConfig([
29+
compatPlugin.configs['flat/recommended'],
30+
{
31+
linterOptions: {
32+
noInlineConfig: true,
33+
},
34+
languageOptions: {
35+
sourceType: 'module',
36+
globals: {
37+
...globals.browser,
38+
},
39+
// Don't need to worry about ECMA syntax as that's handled by Vite/ESBuild:
40+
ecmaVersion: 'latest',
41+
},
3342
},
34-
noInlineConfig: true,
35-
reportUnusedDisableDirectives: false, // doesn't seem to work
36-
}
43+
])

eslint.config.mjs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
import { defineConfig } from 'eslint/config'
19+
import js from '@eslint/js'
20+
import globals from 'globals'
21+
import pluginVue from 'eslint-plugin-vue'
22+
import pluginVuetify from 'eslint-plugin-vuetify'
23+
import pluginCypress from 'eslint-plugin-cypress/flat'
24+
import noOnlyTests from 'eslint-plugin-no-only-tests'
25+
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
26+
27+
const cypressTestFiles = ['tests/e2e/**', 'tests/component/**']
28+
const unitTestFiles = ['**/*.spec.js']
29+
30+
export default defineConfig([
31+
// NOTE: neostandard includes various plugins
32+
...neostandard({
33+
noJsx: true,
34+
// Neostandard makes it easier to configure ignores than ESLint's way:
35+
ignores: [
36+
...resolveIgnoresFromGitignore(),
37+
'.yarn/',
38+
],
39+
}),
40+
41+
js.configs.recommended,
42+
43+
...pluginVue.configs['flat/essential'],
44+
45+
...pluginVuetify.configs['flat/base'],
46+
47+
{
48+
languageOptions: {
49+
sourceType: 'module',
50+
// Allow new ECMAScript syntax but not globals. This is because vite/esbuild
51+
// transforms syntax to es2015 (at the earliest) but does not pollyfill APIs.
52+
ecmaVersion: 'latest',
53+
globals: {
54+
...globals.browser,
55+
}
56+
},
57+
rules: {
58+
'@stylistic/comma-dangle': ['error', {
59+
arrays: 'only-multiline',
60+
objects: 'only-multiline',
61+
imports: 'only-multiline',
62+
exports: 'only-multiline',
63+
functions: 'only-multiline',
64+
}],
65+
66+
'no-console': ['error', {
67+
allow: ['warn', 'error'],
68+
}],
69+
70+
'vue/multi-word-component-names': ['off'],
71+
72+
'promise/param-names': ['error'],
73+
'promise/no-return-wrap': ['error'],
74+
},
75+
},
76+
77+
{
78+
files: ['scripts/**', 'src/services/mock/**'],
79+
languageOptions: {
80+
globals: {
81+
...globals.node,
82+
},
83+
},
84+
rules: {
85+
'no-console': ['off'],
86+
},
87+
},
88+
89+
{
90+
files: cypressTestFiles,
91+
plugins: {
92+
cypress: pluginCypress,
93+
},
94+
extends: ['cypress/recommended'],
95+
rules: {
96+
'cypress/unsafe-to-chain-command': ['off'],
97+
}
98+
},
99+
100+
{
101+
files: unitTestFiles,
102+
languageOptions: {
103+
globals: {
104+
...globals.vitest,
105+
},
106+
},
107+
},
108+
109+
{
110+
files: [...unitTestFiles, ...cypressTestFiles],
111+
plugins: {
112+
'no-only-tests': noOnlyTests,
113+
},
114+
rules: {
115+
'no-console': ['off'],
116+
117+
'no-only-tests/no-only-tests': ['error'],
118+
119+
// Don't complain about certain chai assertions:
120+
'no-unused-expressions': ['off'],
121+
},
122+
},
123+
])

package.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"coverage:component": "COVERAGE=true yarn run test:component",
1313
"coverage:e2e": "COVERAGE=true yarn run test:e2e",
1414
"dev": "yarn run serve",
15-
"lint": "eslint . --ext .js,.jsx,.mjs,.cjs,.ts,.tsx,.vue --ignore-path .gitignore",
16-
"lint:compat": "eslint dist/ --no-eslintrc -c eslintrc-dist.cjs",
15+
"lint": "eslint",
16+
"lint:compat": "eslint dist/ -c dist.eslint.config.mjs",
1717
"preview": "node ./scripts/concurrently.cjs serve:jupyterhub preview",
1818
"serve": "node ./scripts/concurrently.cjs serve:jupyterhub serve:vue",
1919
"serve:vue": "vite --mode offline",
@@ -55,38 +55,37 @@
5555
},
5656
"devDependencies": {
5757
"@cypress/code-coverage": "3.14.0",
58+
"@eslint/js": "9.24.0",
5859
"@vitejs/plugin-vue": "5.2.3",
5960
"@vitest/coverage-istanbul": "3.1.2",
6061
"@vue/test-utils": "2.4.6",
6162
"concurrently": "9.1.2",
6263
"cross-fetch": "4.1.0",
6364
"cypress": "14.3.2",
6465
"cypress-vite": "1.6.0",
65-
"eslint": "8.57.1",
66-
"eslint-config-standard": "17.1.0",
67-
"eslint-plugin-compat": "4.2.0",
68-
"eslint-plugin-cypress": "2.15.2",
69-
"eslint-plugin-import": "2.31.0",
70-
"eslint-plugin-n": "16.6.2",
66+
"eslint": "9.24.0",
67+
"eslint-plugin-compat": "6.0.2",
68+
"eslint-plugin-cypress": "4.2.0",
7169
"eslint-plugin-no-only-tests": "3.3.0",
72-
"eslint-plugin-promise": "6.6.0",
73-
"eslint-plugin-vue": "9.33.0",
70+
"eslint-plugin-vue": "10.0.0",
7471
"eslint-plugin-vuetify": "2.5.2",
7572
"express": "5.1.0",
7673
"express-ws": "5.0.2",
74+
"globals": "16.0.0",
7775
"istanbul-lib-coverage": "3.2.2",
7876
"jsdom": "26.1.0",
7977
"json-server": "0.17.4",
78+
"neostandard": "0.12.1",
8079
"nodemon": "3.1.10",
8180
"nyc": "17.1.0",
8281
"sass-embedded": "1.87.0",
8382
"sinon": "20.0.0",
84-
"standard": "17.1.2",
8583
"vite": "6.3.4",
8684
"vite-plugin-eslint": "1.8.1",
8785
"vite-plugin-istanbul": "7.0.0",
8886
"vite-plugin-vuetify": "2.1.1",
89-
"vitest": "3.1.2"
87+
"vitest": "3.1.2",
88+
"vue-eslint-parser": "10.1.3"
9089
},
9190
"peerDependenciesMeta": {
9291
"react": {

renovate.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@
110110
{
111111
"groupName": "eslint packages",
112112
"matchPackageNames": [
113-
"standard",
114-
"eslint*"
113+
"/^@?eslint/",
114+
"*-eslint-parser"
115115
],
116116
"automerge": true,
117117
"schedule": [

scripts/concurrently.cjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-console */
21
const concurrently = require('concurrently')
32

43
const args = process.argv.slice(2)

src/components/cylc/tree/GScanTreeItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export default {
158158
computed: {
159159
workflowLink () {
160160
return this.node.type === 'workflow'
161-
? `/workspace/${ this.node.tokens.workflow }`
161+
? `/workspace/${this.node.tokens.workflow}`
162162
: ''
163163
},
164164

src/components/graphqlFormGenerator/FormInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
// dictionary of props for overriding default values
8282
propOverrides: {
8383
type: Object,
84-
default: () => { Object() }
84+
default: () => ({ })
8585
}
8686
},
8787

src/services/mock/.eslintrc.cjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/.eslintrc.cjs

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)