@aneuhold/eslint-config 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/package.json +2 -1
- package/src/angular-config.js +4 -5
- package/src/react-config.js +10 -10
- package/src/react-next-config.js +24 -0
- package/src/svelte-config.js +2 -9
- package/src/ts-lib-config.js +10 -17
package/README.md
CHANGED
|
@@ -18,14 +18,33 @@ Make sure to add the following settings to VSCode settings.json:
|
|
|
18
18
|
|
|
19
19
|
```json
|
|
20
20
|
{
|
|
21
|
+
// Use prettier for all files that ESLint doesn't support
|
|
22
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
23
|
+
"editor.formatOnSave": true,
|
|
24
|
+
// Use ESLint for all file types that it supports (which still uses prettier behind the scenes)
|
|
25
|
+
"[typescript][javascript][javascriptreact][typescriptreact]": {
|
|
26
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
|
27
|
+
"editor.formatOnSave": true
|
|
28
|
+
},
|
|
29
|
+
"editor.codeActionsOnSave": {
|
|
30
|
+
"source.fixAll.eslint": "always",
|
|
31
|
+
"source.organizeImports": "explicit"
|
|
32
|
+
},
|
|
21
33
|
"eslint.useFlatConfig": true,
|
|
22
34
|
"eslint.run": "onSave",
|
|
23
35
|
"eslint.format.enable": true,
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
"eslint.validate": [
|
|
37
|
+
"javascript",
|
|
38
|
+
"javascriptreact",
|
|
39
|
+
"typescript",
|
|
40
|
+
"typescriptreact"
|
|
41
|
+
// Add "svelte" here if using Svelte
|
|
42
|
+
]
|
|
26
43
|
}
|
|
27
44
|
```
|
|
28
45
|
|
|
46
|
+
Then add a prettier file, such as the one in this repo [here](.prettierrc.js).
|
|
47
|
+
|
|
29
48
|
### Setup for `CommonJS`
|
|
30
49
|
|
|
31
50
|
Add `eslint.config.js` like so:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aneuhold/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Main ESLint Configuration for personal projects",
|
|
5
5
|
"main": "./src/ts-lib-config.js",
|
|
6
6
|
"packageManager": "pnpm@10.15.0",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@eslint/js": "^9.34.0",
|
|
39
|
+
"@next/eslint-plugin-next": "^15.5.2",
|
|
39
40
|
"@stylistic/eslint-plugin-js": "^4.4.1",
|
|
40
41
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
41
42
|
"@typescript-eslint/eslint-plugin": "^8.41.0",
|
package/src/angular-config.js
CHANGED
|
@@ -7,12 +7,12 @@ import tseslint from 'typescript-eslint';
|
|
|
7
7
|
// Allows us to bring in the recommended rules for Angular projects from angular-eslint
|
|
8
8
|
import angular from 'angular-eslint';
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import stylisticJs from '@stylistic/eslint-plugin-js';
|
|
11
|
+
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
11
12
|
import eslintPluginImport from 'eslint-plugin-import';
|
|
12
13
|
import eslintPluginJsdoc from 'eslint-plugin-jsdoc';
|
|
14
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
13
15
|
import eslintPluginUnusedImports from 'eslint-plugin-unused-imports';
|
|
14
|
-
import stylisticJs from '@stylistic/eslint-plugin-js';
|
|
15
|
-
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
16
16
|
|
|
17
17
|
// Export our config array, which is composed together thanks to the typed utility function from typescript-eslint
|
|
18
18
|
export default tseslint.config(
|
|
@@ -122,8 +122,7 @@ export default tseslint.config(
|
|
|
122
122
|
'warn',
|
|
123
123
|
{
|
|
124
124
|
alphabetize: {
|
|
125
|
-
order:
|
|
126
|
-
'asc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
|
|
125
|
+
order: 'asc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
|
|
127
126
|
caseInsensitive: true /* ignore case. Options: [true, false] */
|
|
128
127
|
},
|
|
129
128
|
'newlines-between': 'never'
|
package/src/react-config.js
CHANGED
|
@@ -12,17 +12,17 @@ export default tseslint.config([
|
|
|
12
12
|
js.configs.recommended,
|
|
13
13
|
reactHooks.configs['recommended-latest'],
|
|
14
14
|
reactRefresh.configs.vite,
|
|
15
|
-
eslintPluginPrettierRecommended
|
|
15
|
+
eslintPluginPrettierRecommended,
|
|
16
16
|
],
|
|
17
17
|
languageOptions: {
|
|
18
18
|
globals: globals.browser,
|
|
19
19
|
parserOptions: {
|
|
20
|
-
sourceType: 'module'
|
|
21
|
-
}
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
},
|
|
22
22
|
},
|
|
23
23
|
rules: {
|
|
24
|
-
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }]
|
|
25
|
-
}
|
|
24
|
+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
|
25
|
+
},
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
files: ['**/*.{ts,tsx}'],
|
|
@@ -34,11 +34,11 @@ export default tseslint.config([
|
|
|
34
34
|
sourceType: 'module',
|
|
35
35
|
// "project" looks to be deprecated, so use "projectService" instead.
|
|
36
36
|
// See https://typescript-eslint.io/getting-started/typed-linting
|
|
37
|
-
projectService: true
|
|
38
|
-
}
|
|
39
|
-
}
|
|
37
|
+
projectService: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
|
-
ignores: ['.yarn', 'build', 'dist', 'node_modules', '**/.DS_Store']
|
|
43
|
-
}
|
|
42
|
+
ignores: ['.yarn', 'build', 'dist', 'node_modules', '**/.DS_Store'],
|
|
43
|
+
},
|
|
44
44
|
]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import nextPlugin from '@next/eslint-plugin-next';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import reactConfig from './react-config.js';
|
|
4
|
+
|
|
5
|
+
// Ya, this is kind of weird, but if you dig into the actual code in the next plugin, this is correct.
|
|
6
|
+
const { flatConfig } = nextPlugin;
|
|
7
|
+
|
|
8
|
+
export default tseslint.config(
|
|
9
|
+
...reactConfig,
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
12
|
+
extends: [flatConfig.recommended],
|
|
13
|
+
rules: {
|
|
14
|
+
// Allow export names that are used by Next.js in the app directory.
|
|
15
|
+
'react-refresh/only-export-components': [
|
|
16
|
+
'error',
|
|
17
|
+
{ allowExportNames: ['metadata', 'links', 'headers', 'loader', 'action'] },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
// Any other override settings. e.g. for `files: ['**/*.test.*']`
|
|
23
|
+
}
|
|
24
|
+
);
|
package/src/svelte-config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import eslint from '@eslint/js';
|
|
2
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
2
3
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
3
4
|
import eslintPluginSvelte from 'eslint-plugin-svelte';
|
|
4
5
|
import globals from 'globals';
|
|
5
6
|
import svelteParser from 'svelte-eslint-parser';
|
|
6
7
|
import tseslint from 'typescript-eslint';
|
|
7
|
-
import jsdoc from 'eslint-plugin-jsdoc';
|
|
8
8
|
|
|
9
9
|
const defaultConfig = tseslint.config(
|
|
10
10
|
{
|
|
@@ -111,13 +111,6 @@ export default tseslint.config(
|
|
|
111
111
|
// other override settings. e.g. for `files: ['**/*.test.*']`
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
|
-
ignores: [
|
|
115
|
-
'.svelte-kit',
|
|
116
|
-
'.yarn',
|
|
117
|
-
'build',
|
|
118
|
-
'node_modules',
|
|
119
|
-
'**/.DS_Store',
|
|
120
|
-
'eslint.config.js'
|
|
121
|
-
]
|
|
114
|
+
ignores: ['.svelte-kit', '.yarn', 'build', 'node_modules', '**/.DS_Store', 'eslint.config.js']
|
|
122
115
|
} // overrides global ignores
|
|
123
116
|
);
|
package/src/ts-lib-config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import eslint from '@eslint/js';
|
|
2
|
+
import jsdoc from 'eslint-plugin-jsdoc';
|
|
2
3
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
3
4
|
import globals from 'globals';
|
|
4
5
|
import tseslint from 'typescript-eslint';
|
|
5
|
-
import jsdoc from 'eslint-plugin-jsdoc';
|
|
6
6
|
|
|
7
7
|
const defaultConfig = tseslint.config(
|
|
8
8
|
{
|
|
@@ -11,15 +11,15 @@ const defaultConfig = tseslint.config(
|
|
|
11
11
|
eslint.configs.recommended,
|
|
12
12
|
...tseslint.configs.strictTypeChecked,
|
|
13
13
|
jsdoc.configs['flat/recommended-typescript'],
|
|
14
|
-
eslintPluginPrettierRecommended
|
|
14
|
+
eslintPluginPrettierRecommended,
|
|
15
15
|
],
|
|
16
16
|
languageOptions: {
|
|
17
17
|
parser: tseslint.parser,
|
|
18
18
|
parserOptions: {
|
|
19
19
|
sourceType: 'module',
|
|
20
|
-
project: true
|
|
20
|
+
project: true,
|
|
21
21
|
},
|
|
22
|
-
globals: { ...globals.node }
|
|
22
|
+
globals: { ...globals.node },
|
|
23
23
|
},
|
|
24
24
|
// Rules for js, and ts in ts files
|
|
25
25
|
rules: {
|
|
@@ -38,18 +38,18 @@ const defaultConfig = tseslint.config(
|
|
|
38
38
|
'error',
|
|
39
39
|
{
|
|
40
40
|
allowNumber: true,
|
|
41
|
-
allowBoolean: true
|
|
42
|
-
}
|
|
41
|
+
allowBoolean: true,
|
|
42
|
+
},
|
|
43
43
|
],
|
|
44
44
|
// Turned off because it doesn't seem too helpful, and it likes to error
|
|
45
45
|
// on things that seem to be just fine in generics.
|
|
46
|
-
'@typescript-eslint/no-unnecessary-type-parameters': 'off'
|
|
47
|
-
}
|
|
46
|
+
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
|
|
47
|
+
},
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
// disable type-aware linting on JS files
|
|
51
51
|
files: ['**/*.js', '**/*.mjs'],
|
|
52
|
-
extends: [tseslint.configs.disableTypeChecked]
|
|
52
|
+
extends: [tseslint.configs.disableTypeChecked],
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
|
|
@@ -59,13 +59,6 @@ export default tseslint.config(
|
|
|
59
59
|
// other override settings. e.g. for `files: ['**/*.test.*']`
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
|
-
ignores: [
|
|
63
|
-
'.yarn',
|
|
64
|
-
'build',
|
|
65
|
-
'lib',
|
|
66
|
-
'node_modules',
|
|
67
|
-
'eslint.config.js',
|
|
68
|
-
'**/.DS_Store'
|
|
69
|
-
]
|
|
62
|
+
ignores: ['.yarn', 'build', 'lib', 'node_modules', 'eslint.config.js', '**/.DS_Store'],
|
|
70
63
|
} // overrides global ignores
|
|
71
64
|
);
|