Skip to content

Commit 0cf2e98

Browse files
authored
chore: upgrade eslint to v9 (#11108)
1 parent a531625 commit 0cf2e98

File tree

12 files changed

+322
-279
lines changed

12 files changed

+322
-279
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ trim_trailing_whitespace = true
1111
[test/**/expected.css]
1212
insert_final_newline = false
1313

14-
[{package.json,.travis.yml,.eslintrc.json}]
14+
[package.json]
1515
indent_style = space

.eslintignore

-24
This file was deleted.

.eslintrc.cjs

-54
This file was deleted.

.prettierignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# NOTE: In general this should be kept in sync with .eslintignore
2-
31
packages/**/dist/*.js
42
packages/**/build/*.js
53
packages/**/npm/**/*
@@ -31,7 +29,6 @@ sites/svelte.dev/src/lib/generated
3129
**/.vercel
3230
.github/CODEOWNERS
3331
.prettierignore
34-
.eslintignore
3532
.changeset
3633
pnpm-lock.yaml
3734
pnpm-workspace.yaml

eslint.config.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import svelte_config from '@sveltejs/eslint-config';
2+
import lube from 'eslint-plugin-lube';
3+
4+
/** @type {import('eslint').Linter.FlatConfig[]} */
5+
export default [
6+
...svelte_config,
7+
{
8+
plugins: {
9+
lube
10+
},
11+
rules: {
12+
'no-console': 'error',
13+
'lube/svelte-naming-convention': ['error', { fixSameNames: true }],
14+
// eslint isn't that well-versed with JSDoc to know that `foo: /** @type{..} */ (foo)` isn't a violation of this rule, so turn it off
15+
'object-shorthand': 'off',
16+
'no-var': 'off',
17+
18+
// TODO: enable these rules and run `pnpm lint:fix`
19+
// skipping that for now so as to avoid impacting real work
20+
'@stylistic/quotes': 'off',
21+
'@typescript-eslint/no-unused-vars': 'off',
22+
'prefer-const': 'off'
23+
}
24+
},
25+
{
26+
files: ['playgrounds/**/*'],
27+
rules: {
28+
'lube/svelte-naming-convention': 'off',
29+
'no-console': 'off'
30+
}
31+
},
32+
{
33+
ignores: [
34+
'**/*.d.ts',
35+
'**/tests',
36+
'packages/svelte/compiler/index.js',
37+
// documentation can contain invalid examples
38+
'documentation',
39+
// contains a fork of the REPL which doesn't adhere to eslint rules
40+
'sites/svelte-5-preview/**',
41+
// wasn't checked previously, reenable at some point
42+
'sites/svelte.dev/**'
43+
]
44+
}
45+
];

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@
1919
"preview-site": "npm run build --prefix sites/svelte-5-preview",
2020
"check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check",
2121
"format": "prettier --write .",
22-
"lint": "prettier --check . && eslint ./",
22+
"lint": "prettier --check . && eslint",
2323
"test": "vitest run",
2424
"test-output": "vitest run --coverage --reporter=json --outputFile=sites/svelte-5-preview/src/routes/status/results.json",
2525
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
2626
"changeset:publish": "changeset publish"
2727
},
2828
"devDependencies": {
2929
"@changesets/cli": "^2.27.1",
30-
"@sveltejs/eslint-config": "^6.0.4",
30+
"@sveltejs/eslint-config": "^7.0.1",
3131
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
3232
"@types/node": "^20.11.5",
33-
"@typescript-eslint/eslint-plugin": "^6.21.0",
3433
"@vitest/coverage-v8": "^1.2.1",
3534
"concurrently": "^8.2.2",
3635
"cross-env": "^7.0.3",
37-
"eslint": "^8.56.0",
36+
"eslint": "^9.0.0",
3837
"eslint-plugin-lube": "^0.4.3",
3938
"jsdom": "22.0.0",
4039
"playwright": "^1.41.1",
4140
"prettier": "^3.2.4",
4241
"prettier-plugin-svelte": "^3.1.2",
4342
"typescript": "^5.3.3",
43+
"typescript-eslint": "^7.6.0",
4444
"vitest": "^1.2.1"
4545
},
4646
"pnpm": {

packages/svelte/src/internal/client/dom/elements/bindings/input.js

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ export function bind_checked(input, get_value, update) {
131131
update(value);
132132
});
133133

134-
// eslint-disable-next-line eqeqeq
135134
if (get_value() == undefined) {
136135
update(false);
137136
}

packages/svelte/src/internal/client/reactivity/equality.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ export function equals(value) {
99
* @returns {boolean}
1010
*/
1111
export function safe_not_equal(a, b) {
12-
// eslint-disable-next-line eqeqeq
1312
return a != a
14-
? // eslint-disable-next-line eqeqeq
15-
b == b
13+
? b == b
1614
: a !== b || (a !== null && typeof a === 'object') || typeof a === 'function';
1715
}
1816

packages/svelte/src/internal/shared/utils.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line @typescript-eslint/no-empty-function
21
export const noop = () => {};
32

43
// Adapted from https://github.com/then/is-promise/blob/master/index.js

packages/svelte/src/store/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ export function readable(value, start) {
2727
* @returns {boolean}
2828
*/
2929
export function safe_not_equal(a, b) {
30-
// eslint-disable-next-line eqeqeq
31-
return a != a
32-
? // eslint-disable-next-line eqeqeq
33-
b == b
34-
: a !== b || (a && typeof a === 'object') || typeof a === 'function';
30+
return a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';
3531
}
3632

3733
/**

playgrounds/demo/server.js

-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ async function createServer() {
4343
createServer()
4444
.then(({ app }) =>
4545
app.listen(PORT, () => {
46-
// eslint-disable-next-line no-console
4746
console.log(`http://localhost:${PORT}`);
4847
})
4948
)
5049
.catch((err) => {
51-
// eslint-disable-next-line no-console
5250
console.error('Error Starting Server:\n', err);
5351
process.exit(1);
5452
});

0 commit comments

Comments
 (0)