Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1aa3701

Browse files
authored
style: update to ESLint v9 and rework lint config (#438)
1 parent f1fb8dd commit 1aa3701

22 files changed

+182
-145
lines changed

‎.eslintignore‎

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

‎.eslintrc.cjs‎

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

‎.github/dependabot.yml‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ updates:
2323
development:
2424
dependency-type: 'development'
2525

26-
# TODO(mcous, 2024年04月30日): update to ESLint v9 + flat config
27-
ignore:
28-
- dependency-name: 'eslint'
29-
versions: ['>=9']
30-
- dependency-name: 'eslint-plugin-n'
31-
versions: ['>=17']
32-
- dependency-name: 'eslint-plugin-promise'
33-
versions: ['>=7']
34-
3526
# Update GitHub Actions dependencies
3627
- package-ecosystem: 'github-actions'
3728
directory: '/'

‎.prettierignore‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
scripts/*
2-
.eslintignore
3-
.prettierignore
41
.all-contributorsrc

‎.prettierrc.yaml‎

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

‎eslint.config.js‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import js from '@eslint/js'
2+
import eslintPluginVitest from '@vitest/eslint-plugin'
3+
import eslintConfigPrettier from 'eslint-config-prettier'
4+
import eslintPluginJestDom from 'eslint-plugin-jest-dom'
5+
import eslintPluginPromise from 'eslint-plugin-promise'
6+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
7+
import eslintPluginSvelte from 'eslint-plugin-svelte'
8+
import eslintPluginTestingLibrary from 'eslint-plugin-testing-library'
9+
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
10+
import globals from 'globals'
11+
import tseslint from 'typescript-eslint'
12+
13+
export default tseslint.config(
14+
js.configs.recommended,
15+
tseslint.configs.strict,
16+
tseslint.configs.stylistic,
17+
eslintPluginUnicorn.configs['flat/recommended'],
18+
eslintPluginPromise.configs['flat/recommended'],
19+
eslintPluginSvelte.configs['flat/recommended'],
20+
eslintPluginSvelte.configs['flat/prettier'],
21+
eslintConfigPrettier,
22+
{
23+
name: 'settings',
24+
languageOptions: {
25+
ecmaVersion: 'latest',
26+
sourceType: 'module',
27+
parserOptions: {
28+
parser: tseslint.parser,
29+
extraFileExtensions: ['.svelte'],
30+
},
31+
globals: {
32+
...globals.browser,
33+
...globals.node,
34+
...globals.jest,
35+
},
36+
},
37+
},
38+
{
39+
name: 'ignores',
40+
ignores: ['coverage', 'types'],
41+
},
42+
{
43+
name: 'simple-import-sort',
44+
plugins: {
45+
'simple-import-sort': eslintPluginSimpleImportSort,
46+
},
47+
rules: {
48+
'simple-import-sort/imports': 'error',
49+
'simple-import-sort/exports': 'error',
50+
},
51+
},
52+
{
53+
name: 'tests',
54+
files: ['**/*.test.js'],
55+
extends: [
56+
eslintPluginVitest.configs.recommended,
57+
eslintPluginJestDom.configs['flat/recommended'],
58+
eslintPluginTestingLibrary.configs['flat/dom'],
59+
],
60+
rules: {
61+
'testing-library/no-node-access': [
62+
'error',
63+
{ allowContainerFirstChild: true },
64+
],
65+
},
66+
},
67+
{
68+
name: 'extras',
69+
rules: {
70+
'unicorn/prevent-abbreviations': 'off',
71+
},
72+
},
73+
{
74+
name: 'svelte-extras',
75+
files: ['**/*.svelte'],
76+
rules: {
77+
'svelte/no-unused-svelte-ignore': 'off',
78+
'unicorn/filename-case': ['error', { case: 'pascalCase' }],
79+
'unicorn/no-useless-undefined': 'off',
80+
},
81+
},
82+
{
83+
name: 'ts-extras',
84+
files: ['**/*.ts'],
85+
extends: [
86+
tseslint.configs.strictTypeChecked,
87+
tseslint.configs.stylisticTypeChecked,
88+
],
89+
languageOptions: {
90+
parserOptions: {
91+
projectService: true,
92+
},
93+
},
94+
}
95+
)

‎jest.config.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { VERSION as SVELTE_VERSION } from 'svelte/compiler'
22

33
const SVELTE_TRANSFORM_PATTERN =
4-
SVELTE_VERSION >= '5' ? '^.+\\.svelte(?:\\.js)?$' : '^.+\\.svelte$'
4+
SVELTE_VERSION >= '5'
5+
? String.raw`^.+\.svelte(?:\.js)?$`
6+
: String.raw`^.+\.svelte$`
57

68
export default {
79
testMatch: ['<rootDir>/tests/**/*.test.js'],
@@ -15,7 +17,7 @@ export default {
1517
injectGlobals: false,
1618
moduleNameMapper: {
1719
'^vitest$': '<rootDir>/tests/_jest-vitest-alias.js',
18-
'^@testing-library\\/svelte$': '<rootDir>/src/index.js',
20+
[String.raw`^@testing-library\/svelte$`]: '<rootDir>/src/index.js',
1921
},
2022
resetMocks: true,
2123
restoreMocks: true,

‎package.json‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,25 @@
9090
"@testing-library/dom": "9.x.x || 10.x.x"
9191
},
9292
"devDependencies": {
93+
"@eslint/js": "^9.26.0",
9394
"@jest/globals": "^29.7.0",
9495
"@sveltejs/vite-plugin-svelte": "^5.0.3",
9596
"@testing-library/jest-dom": "^6.6.3",
9697
"@testing-library/user-event": "^14.6.1",
97-
"@typescript-eslint/eslint-plugin": "^8.0.0",
98-
"@typescript-eslint/parser": "^8.0.0",
9998
"@vitest/coverage-v8": "^3.1.3",
99+
"@vitest/eslint-plugin": "^1.1.44",
100100
"all-contributors-cli": "^6.26.1",
101101
"doctoc": "^2.2.1",
102-
"eslint": "^8.57.0",
103-
"eslint-config-prettier": "^9.1.0",
104-
"eslint-config-standard": "^17.1.0",
105-
"eslint-plugin-import": "^2.29.1",
106-
"eslint-plugin-n": "^16.6.2",
107-
"eslint-plugin-promise": "^6.4.0",
102+
"eslint": "^9.26.0",
103+
"eslint-config-prettier": "^10.1.5",
104+
"eslint-plugin-jest-dom": "^5.5.0",
105+
"eslint-plugin-promise": "^7.2.1",
108106
"eslint-plugin-simple-import-sort": "^12.1.1",
109-
"eslint-plugin-svelte": "^2.42.0",
107+
"eslint-plugin-svelte": "^3.5.1",
108+
"eslint-plugin-testing-library": "^7.1.1",
109+
"eslint-plugin-unicorn": "^59.0.1",
110110
"expect-type": "^1.2.1",
111+
"globals": "^16.1.0",
111112
"happy-dom": "^17.4.6",
112113
"jest": "^29.7.0",
113114
"jest-environment-jsdom": "^29.7.0",
@@ -119,6 +120,7 @@
119120
"svelte-check": "^4.1.7",
120121
"svelte-jester": "^5.0.0",
121122
"typescript": "^5.8.3",
123+
"typescript-eslint": "^8.32.0",
122124
"typescript-svelte-plugin": "^0.3.46",
123125
"vite": "^6.3.5",
124126
"vitest": "^3.1.3"

‎prettier.config.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
semi: false,
3+
singleQuote: true,
4+
trailingComma: 'es5',
5+
plugins: ['prettier-plugin-svelte'],
6+
overrides: [
7+
{
8+
files: '*.svelte',
9+
options: {
10+
parser: 'svelte',
11+
},
12+
},
13+
],
14+
}

‎src/core/index.js‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@
77
*/
88
import * as LegacyCore from './legacy.js'
99
import * as ModernCore from './modern.svelte.js'
10-
import {
11-
createValidateOptions,
12-
UnknownSvelteOptionsError,
13-
} from './validate-options.js'
10+
import { createValidateOptions } from './validate-options.js'
1411

1512
const { mount, unmount, updateProps, allowedOptions } =
1613
ModernCore.IS_MODERN_SVELTE ? ModernCore : LegacyCore
1714

1815
/** Validate component options. */
1916
const validateOptions = createValidateOptions(allowedOptions)
2017

21-
export {
22-
mount,
23-
UnknownSvelteOptionsError,
24-
unmount,
25-
updateProps,
26-
validateOptions,
27-
}
18+
export { mount, unmount, updateProps, validateOptions }
19+
export { UnknownSvelteOptionsError } from './validate-options.js'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /