@evanpurkhiser/eslint-config 0.20.0 → 0.21.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/.github/workflows/main.yml +8 -1
- package/README.md +8 -8
- package/eslint.config.mjs +3 -0
- package/package.json +17 -12
- package/{prettier.config.js → prettier.config.mjs} +3 -2
- package/src/common.mjs +104 -0
- package/src/index.mjs +6 -0
- package/src/react.mjs +44 -0
- package/common.js +0 -100
- package/index.js +0 -3
- package/react.js +0 -18
|
@@ -5,10 +5,17 @@ on:
|
|
|
5
5
|
branches: [main]
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
|
+
lint:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: volta-cli/action@v4
|
|
13
|
+
- run: yarn install
|
|
14
|
+
- run: yarn lint
|
|
8
15
|
publish:
|
|
9
16
|
runs-on: ubuntu-latest
|
|
10
17
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v4
|
|
12
19
|
- uses: volta-cli/action@v4
|
|
13
20
|
- name: bump version
|
|
14
21
|
run: |
|
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ These are my eslint configurations that I use across my various personal
|
|
|
7
7
|
projects.
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
yarn install -D @
|
|
10
|
+
yarn install -D @evanpurkhiser/eslint-config
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Create a
|
|
13
|
+
Create a `eslint.config.mjs` file with the contents:
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import {all} from '@evanpurkhiser/eslint-config';
|
|
17
|
+
|
|
18
|
+
export defaukt [...all];
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
The default configuration is for React apps, but you can select from the
|
|
@@ -27,7 +27,7 @@ following configurations
|
|
|
27
27
|
For example:
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
import {common} from '@evanpurkhiser/eslint-config';
|
|
31
|
+
|
|
32
|
+
export defaukt [...common];
|
|
33
33
|
```
|
package/package.json
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evanpurkhiser/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Evan Purkhiser's personal eslint configuration",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/evanpurkhiser/eslint-config",
|
|
7
7
|
"author": "Evan Purkhiser",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"
|
|
12
|
-
"eslint-
|
|
13
|
-
"eslint-plugin-
|
|
14
|
-
"eslint-plugin-
|
|
15
|
-
"eslint-plugin-
|
|
16
|
-
"
|
|
17
|
-
"eslint
|
|
10
|
+
"@eslint/js": "^9.15.0",
|
|
11
|
+
"eslint-config-prettier": "^9.1.0",
|
|
12
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
13
|
+
"eslint-plugin-react": "^7.37.2",
|
|
14
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
15
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
16
|
+
"globals": "^15.12.0",
|
|
17
|
+
"typescript-eslint": "^8.16.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"eslint": ">=8.0.0",
|
|
21
21
|
"prettier": ">=3.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"
|
|
24
|
+
"eslint": "^9.15.0",
|
|
25
|
+
"prettier": "^3.3.3",
|
|
26
|
+
"typescript": "^5.7.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lint": "eslint ."
|
|
25
30
|
},
|
|
26
31
|
"volta": {
|
|
27
|
-
"node": "
|
|
28
|
-
"yarn": "1.22.
|
|
32
|
+
"node": "22.11.0",
|
|
33
|
+
"yarn": "1.22.22"
|
|
29
34
|
}
|
|
30
35
|
}
|
package/src/common.mjs
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended';
|
|
3
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
4
|
+
import {builtinModules} from 'node:module';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
const common = tseslint.config(
|
|
8
|
+
eslint.configs.recommended,
|
|
9
|
+
tseslint.configs.recommended,
|
|
10
|
+
tseslint.configs.stylistic,
|
|
11
|
+
eslintPluginPrettier,
|
|
12
|
+
{
|
|
13
|
+
plugins: {
|
|
14
|
+
'simple-import-sort': simpleImportSort,
|
|
15
|
+
},
|
|
16
|
+
languageOptions: {
|
|
17
|
+
ecmaVersion: 'latest',
|
|
18
|
+
sourceType: 'module',
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
// Best practices
|
|
22
|
+
'array-callback-return': ['warn'],
|
|
23
|
+
'consistent-return': ['warn'],
|
|
24
|
+
'no-caller': ['warn'],
|
|
25
|
+
'no-else-return': ['error', {allowElseIf: false}],
|
|
26
|
+
'no-extra-label': ['error'],
|
|
27
|
+
'no-floating-decimal': ['error'],
|
|
28
|
+
'no-implied-eval': ['error'],
|
|
29
|
+
'no-lone-blocks': ['error'],
|
|
30
|
+
'no-return-await': ['error'],
|
|
31
|
+
'no-self-compare': ['error'],
|
|
32
|
+
'no-sequences': ['error'],
|
|
33
|
+
'no-useless-call': ['warn'],
|
|
34
|
+
'no-useless-concat': ['warn'],
|
|
35
|
+
'no-useless-return': ['warn'],
|
|
36
|
+
'require-await': ['warn'],
|
|
37
|
+
curly: ['error'],
|
|
38
|
+
eqeqeq: ['error'],
|
|
39
|
+
radix: ['warn'],
|
|
40
|
+
|
|
41
|
+
// Variables
|
|
42
|
+
'no-undef-init': ['warn'],
|
|
43
|
+
|
|
44
|
+
// Style (mostly handled by prettier)
|
|
45
|
+
'eol-last': ['error', 'always'],
|
|
46
|
+
'new-parens': ['error'],
|
|
47
|
+
'padded-blocks': ['warn', 'never'],
|
|
48
|
+
'spaced-comment': ['warn', 'always'],
|
|
49
|
+
|
|
50
|
+
// ECMA 6
|
|
51
|
+
'no-var': ['error'],
|
|
52
|
+
'prefer-arrow-callback': ['warn'],
|
|
53
|
+
'prefer-const': ['error'],
|
|
54
|
+
'prefer-destructuring': ['off'],
|
|
55
|
+
'prefer-numeric-literals': ['warn'],
|
|
56
|
+
'prefer-rest-params': ['warn'],
|
|
57
|
+
'prefer-spread': ['warn'],
|
|
58
|
+
'prefer-template': ['warn'],
|
|
59
|
+
'arrow-body-style': ['error', 'as-needed'],
|
|
60
|
+
|
|
61
|
+
// disabled for typescript
|
|
62
|
+
'no-unused-expressions': ['off'],
|
|
63
|
+
|
|
64
|
+
// Typescript
|
|
65
|
+
'@typescript-eslint/explicit-function-return-type': ['off'],
|
|
66
|
+
'@typescript-eslint/no-use-before-define': ['off'],
|
|
67
|
+
'@typescript-eslint/no-explicit-any': ['off'],
|
|
68
|
+
'@typescript-eslint/no-non-null-assertion': ['off'],
|
|
69
|
+
'@typescript-eslint/explicit-module-boundary-types': ['off'],
|
|
70
|
+
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
|
|
71
|
+
'@typescript-eslint/no-unused-expressions': ['error'],
|
|
72
|
+
|
|
73
|
+
// see: https://github.com/typescript-eslint/typescript-eslint/issues/420
|
|
74
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
75
|
+
|
|
76
|
+
// Consistent Array<T> / T[] usage
|
|
77
|
+
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
|
|
78
|
+
|
|
79
|
+
// Sort imports
|
|
80
|
+
'simple-import-sort/exports': 'error',
|
|
81
|
+
'simple-import-sort/imports': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
groups: [
|
|
85
|
+
// Side effect imports.
|
|
86
|
+
['^\\u0000'],
|
|
87
|
+
// Packages. `react` related packages come first.
|
|
88
|
+
['^react', '^@?\\w'],
|
|
89
|
+
// Node.js builtins.
|
|
90
|
+
[`^(${builtinModules.join('|')})(/|$)`],
|
|
91
|
+
// Internal packages.
|
|
92
|
+
['^(src|app)(/.*|$)'],
|
|
93
|
+
// Parent imports. Put `..` last.
|
|
94
|
+
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
|
|
95
|
+
// Other relative imports. Put same-folder imports and `.` last.
|
|
96
|
+
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export {common};
|
package/src/index.mjs
ADDED
package/src/react.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
2
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
|
|
6
|
+
const react = tseslint.config(
|
|
7
|
+
reactPlugin.configs.flat.recommended,
|
|
8
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
plugins: {
|
|
12
|
+
react: reactPlugin,
|
|
13
|
+
'react-hooks': reactHooksPlugin,
|
|
14
|
+
},
|
|
15
|
+
settings: {
|
|
16
|
+
react: {
|
|
17
|
+
version: 'detect',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
languageOptions: {
|
|
22
|
+
parserOptions: {
|
|
23
|
+
ecmaFeatures: {
|
|
24
|
+
jsx: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
globals: {
|
|
28
|
+
...globals.browser,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
rules: {
|
|
33
|
+
'react/prop-types': ['off'],
|
|
34
|
+
'react/display-name': ['off'],
|
|
35
|
+
'react/no-access-state-in-setstate': ['warn'],
|
|
36
|
+
'react/no-this-in-sfc': ['warn'],
|
|
37
|
+
'react/prefer-stateless-function': ['warn'],
|
|
38
|
+
'react/jsx-boolean-value': ['warn'],
|
|
39
|
+
'react/jsx-pascal-case': ['warn'],
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export {react};
|
package/common.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
'eslint:recommended',
|
|
4
|
-
'plugin:prettier/recommended',
|
|
5
|
-
'plugin:@typescript-eslint/recommended',
|
|
6
|
-
'plugin:@typescript-eslint/stylistic',
|
|
7
|
-
],
|
|
8
|
-
plugins: ['prettier', 'import', '@typescript-eslint', 'simple-import-sort'],
|
|
9
|
-
parser: '@typescript-eslint/parser',
|
|
10
|
-
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaVersion: 6,
|
|
13
|
-
sourceType: 'module',
|
|
14
|
-
ecmaFeatures: {
|
|
15
|
-
jsx: true,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
rules: {
|
|
20
|
-
// Best practices
|
|
21
|
-
'array-callback-return': ['warn'],
|
|
22
|
-
'consistent-return': ['warn'],
|
|
23
|
-
'no-caller': ['warn'],
|
|
24
|
-
'no-else-return': ['error', {allowElseIf: false}],
|
|
25
|
-
'no-extra-label': ['error'],
|
|
26
|
-
'no-floating-decimal': ['error'],
|
|
27
|
-
'no-implied-eval': ['error'],
|
|
28
|
-
'no-lone-blocks': ['error'],
|
|
29
|
-
'no-return-await': ['error'],
|
|
30
|
-
'no-self-compare': ['error'],
|
|
31
|
-
'no-sequences': ['error'],
|
|
32
|
-
'no-useless-call': ['warn'],
|
|
33
|
-
'no-useless-concat': ['warn'],
|
|
34
|
-
'no-useless-return': ['warn'],
|
|
35
|
-
'require-await': ['warn'],
|
|
36
|
-
curly: ['error'],
|
|
37
|
-
eqeqeq: ['error'],
|
|
38
|
-
radix: ['warn'],
|
|
39
|
-
|
|
40
|
-
// Variables
|
|
41
|
-
'no-undef-init': ['warn'],
|
|
42
|
-
|
|
43
|
-
// Style (mostly handled by prettier)
|
|
44
|
-
'eol-last': ['error', 'always'],
|
|
45
|
-
'new-parens': ['error'],
|
|
46
|
-
'padded-blocks': ['warn', 'never'],
|
|
47
|
-
'spaced-comment': ['warn', 'always'],
|
|
48
|
-
|
|
49
|
-
// ECMA 6
|
|
50
|
-
'no-var': ['error'],
|
|
51
|
-
'prefer-arrow-callback': ['warn'],
|
|
52
|
-
'prefer-const': ['error'],
|
|
53
|
-
'prefer-destructuring': ['off'],
|
|
54
|
-
'prefer-numeric-literals': ['warn'],
|
|
55
|
-
'prefer-rest-params': ['warn'],
|
|
56
|
-
'prefer-spread': ['warn'],
|
|
57
|
-
'prefer-template': ['warn'],
|
|
58
|
-
'arrow-body-style': ['error', 'as-needed'],
|
|
59
|
-
|
|
60
|
-
// disabled for typescript
|
|
61
|
-
'no-unused-expressions': ['off'],
|
|
62
|
-
|
|
63
|
-
// Typescript
|
|
64
|
-
'@typescript-eslint/explicit-function-return-type': ['off'],
|
|
65
|
-
'@typescript-eslint/no-use-before-define': ['off'],
|
|
66
|
-
'@typescript-eslint/no-explicit-any': ['off'],
|
|
67
|
-
'@typescript-eslint/no-non-null-assertion': ['off'],
|
|
68
|
-
'@typescript-eslint/explicit-module-boundary-types': ['off'],
|
|
69
|
-
'@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_'}],
|
|
70
|
-
'@typescript-eslint/no-unused-expressions': ['error'],
|
|
71
|
-
|
|
72
|
-
// see: https://github.com/typescript-eslint/typescript-eslint/issues/420
|
|
73
|
-
'@typescript-eslint/no-useless-constructor': 'error',
|
|
74
|
-
|
|
75
|
-
// Consistent Array<T> / T[] usage
|
|
76
|
-
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
|
|
77
|
-
|
|
78
|
-
// Sort imports
|
|
79
|
-
'simple-import-sort/exports': 'error',
|
|
80
|
-
'simple-import-sort/imports': [
|
|
81
|
-
'error',
|
|
82
|
-
{
|
|
83
|
-
groups: [
|
|
84
|
-
// Side effect imports.
|
|
85
|
-
['^\\u0000'],
|
|
86
|
-
// Packages. `react` related packages come first.
|
|
87
|
-
['^react', '^@?\\w'],
|
|
88
|
-
// Node.js builtins.
|
|
89
|
-
[`^(${require('module').builtinModules.join('|')})(/|$)`],
|
|
90
|
-
// Internal packages.
|
|
91
|
-
['^(src|app)(/.*|$)'],
|
|
92
|
-
// Parent imports. Put `..` last.
|
|
93
|
-
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
|
|
94
|
-
// Other relative imports. Put same-folder imports and `.` last.
|
|
95
|
-
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
};
|
package/index.js
DELETED
package/react.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
|
|
3
|
-
plugins: ['react', 'react-hooks'],
|
|
4
|
-
|
|
5
|
-
settings: {
|
|
6
|
-
react: {version: 'detect'},
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
rules: {
|
|
10
|
-
'react/prop-types': ['off'],
|
|
11
|
-
'react/display-name': ['off'],
|
|
12
|
-
'react/no-access-state-in-setstate': ['warn'],
|
|
13
|
-
'react/no-this-in-sfc': ['warn'],
|
|
14
|
-
'react/prefer-stateless-function': ['warn'],
|
|
15
|
-
'react/jsx-boolean-value': ['warn'],
|
|
16
|
-
'react/jsx-pascal-case': ['warn'],
|
|
17
|
-
},
|
|
18
|
-
};
|