@dr.pogodin/eslint-configs 0.0.1
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/LICENSE.md +22 -0
- package/README.md +47 -0
- package/babel.config.cjs +10 -0
- package/package.json +48 -0
- package/react-ts.mjs +37 -0
- package/typescript.mjs +141 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
_Copyright © 2025, Dr. Sergey Pogodin_
|
|
4
|
+
— <doc@pogodin.studio> (https://dr.pogodin.studio)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# ESLint Configs
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@dr.pogodin/eslint-configs)
|
|
4
|
+
[](https://www.npmjs.com/package/@dr.pogodin/eslint-configs)
|
|
5
|
+
[](https://app.circleci.com/pipelines/github/birdofpreyru/eslint-configs)
|
|
6
|
+
[](https://github.com/birdofpreyru/eslint-configs)
|
|
7
|
+
[](https://dr.pogodin.studio/docs/eslint-configs)
|
|
8
|
+
|
|
9
|
+
ESLint configurations for TypeScript and/or React projects. This project is
|
|
10
|
+
invisioned as a replacement of AirBnB ESLint Configs, which are completely
|
|
11
|
+
neglected by AirBnB lately, and are deaf to well justified complaigns of users.
|
|
12
|
+
Thus, the aims of this project are:
|
|
13
|
+
|
|
14
|
+
- Code style similar to that of AirBnB configs + Some opionated improvements on
|
|
15
|
+
top of them.
|
|
16
|
+
|
|
17
|
+
- Support of the latest ESLint releases.
|
|
18
|
+
|
|
19
|
+
- Timely upgrades of dependencies.
|
|
20
|
+
|
|
21
|
+
[](https://github.com/sponsors/birdofpreyru)
|
|
22
|
+
|
|
23
|
+
## Getting Started
|
|
24
|
+
|
|
25
|
+
**BEWARE:** These early releases are the very first take on the problem, to get
|
|
26
|
+
things moving. It is definitely needs more attention both to the configurations,
|
|
27
|
+
and to their necessary customization options, and for the config variants
|
|
28
|
+
necessary for different kinds of projects and use cases.
|
|
29
|
+
|
|
30
|
+
For now, if you want to try on your own risk, you can install the package as
|
|
31
|
+
```sh
|
|
32
|
+
npm install --save-dev @dr.pogodin/eslint-configs
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then use it in your ESLint config:
|
|
36
|
+
```js
|
|
37
|
+
// eslint.config.mjs
|
|
38
|
+
|
|
39
|
+
import base from '@dr.pogodin/eslint-configs/react-ts';
|
|
40
|
+
// or import from '@dr.pogodin/eslint-config/typescript'; for non-react projects.
|
|
41
|
+
|
|
42
|
+
export default base;
|
|
43
|
+
// or you may further tune imported "base" config to your project needs.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
These configs assume that Babel is configured in the host project to transpile
|
|
47
|
+
TypeScript code into JS.
|
package/babel.config.cjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dr.pogodin/eslint-configs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "ESLint configurations for TypeScript and/or React projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./react-ts": "./react-ts.mjs",
|
|
8
|
+
"./typescript": "./typescript.mjs"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"lint": "eslint -c typescript.mjs",
|
|
12
|
+
"test": "npm run lint"
|
|
13
|
+
},
|
|
14
|
+
"repository": "github:birdofpreyru/eslint-configs",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ESLint",
|
|
17
|
+
"Config",
|
|
18
|
+
"React",
|
|
19
|
+
"TypeScript",
|
|
20
|
+
"Configuration",
|
|
21
|
+
"ESLint-Config",
|
|
22
|
+
"Linter"
|
|
23
|
+
],
|
|
24
|
+
"author": "Dr. Sergey Pogodin <doc@pogodin.studio> (https://dr.pogodin.studio)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/birdofpreyru/eslint-configs/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://dr.pogodin.studio/docs/eslint-configs",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@babel/eslint-parser": "^7.26.8",
|
|
32
|
+
"@babel/eslint-plugin": "^7.25.9",
|
|
33
|
+
"@babel/preset-env": "^7.26.9",
|
|
34
|
+
"@babel/preset-react": "^7.26.3",
|
|
35
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
36
|
+
"@eslint/js": "^9.21.0",
|
|
37
|
+
"@stylistic/eslint-plugin": "^4.1.0",
|
|
38
|
+
"eslint": "^9.21.0",
|
|
39
|
+
"eslint-import-resolver-typescript": "^4.3.2",
|
|
40
|
+
"eslint-plugin-import": "^2.31.0",
|
|
41
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
42
|
+
"eslint-plugin-react": "^7.37.4",
|
|
43
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
44
|
+
"globals": "^16.0.0",
|
|
45
|
+
"typescript": "^5.7.0",
|
|
46
|
+
"typescript-eslint": "^8.25.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/react-ts.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
2
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
|
+
|
|
4
|
+
import base from './typescript.mjs';
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
...base,
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
|
|
10
|
+
settings: {
|
|
11
|
+
react: { version: '19' },
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
reactPlugin.configs.flat.recommended,
|
|
16
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
17
|
+
|
|
18
|
+
// TODO: This does not work because a bug in eslint-plugin-react-hooks:
|
|
19
|
+
// https://github.com/facebook/react/issues/32431
|
|
20
|
+
// thus, the workaround below.
|
|
21
|
+
// reactHooks.configs.recommended
|
|
22
|
+
{
|
|
23
|
+
plugins: { 'react-hooks': reactHooks },
|
|
24
|
+
rules: { ...reactHooks.configs.recommended.rules },
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
rules: {
|
|
29
|
+
'react/function-component-definition': ['error', {
|
|
30
|
+
namedComponents: 'arrow-function',
|
|
31
|
+
unnamedComponents: 'arrow-function',
|
|
32
|
+
}],
|
|
33
|
+
'react-hooks/exhaustive-deps': 'error',
|
|
34
|
+
'react/prop-types': 'off',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
package/typescript.mjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import babelParser from '@babel/eslint-parser';
|
|
2
|
+
import babelPlugin from '@babel/eslint-plugin';
|
|
3
|
+
import pluginJest from 'eslint-plugin-jest';
|
|
4
|
+
import importPlugin from 'eslint-plugin-import';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
import tseslint from 'typescript-eslint';
|
|
7
|
+
|
|
8
|
+
import pluginJs from '@eslint/js';
|
|
9
|
+
import stylisticPlugin from '@stylistic/eslint-plugin';
|
|
10
|
+
|
|
11
|
+
export default tseslint.config(
|
|
12
|
+
{ ignores: ['__coverage__', 'build/'] },
|
|
13
|
+
{
|
|
14
|
+
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: { ...globals.browser, ...globals.node },
|
|
17
|
+
parser: babelParser,
|
|
18
|
+
},
|
|
19
|
+
linterOptions: {
|
|
20
|
+
reportUnusedDisableDirectives: 'error',
|
|
21
|
+
reportUnusedInlineConfigs: 'error',
|
|
22
|
+
},
|
|
23
|
+
plugins: {
|
|
24
|
+
'@babel': babelPlugin,
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
'import/resolver': {
|
|
28
|
+
node: true,
|
|
29
|
+
typescript: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
importPlugin.flatConfigs.recommended,
|
|
35
|
+
|
|
36
|
+
pluginJs.configs.recommended,
|
|
37
|
+
|
|
38
|
+
stylisticPlugin.configs.all,
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
rules: {
|
|
42
|
+
'@babel/new-cap': 'error',
|
|
43
|
+
'@babel/no-invalid-this': 'error',
|
|
44
|
+
'@babel/no-undef': 'error',
|
|
45
|
+
'@babel/no-unused-expressions': 'error',
|
|
46
|
+
|
|
47
|
+
'@stylistic/object-curly-spacing': 'off',
|
|
48
|
+
'@babel/object-curly-spacing': ['error', 'always'],
|
|
49
|
+
|
|
50
|
+
'@babel/semi': 'error',
|
|
51
|
+
'@stylistic/array-bracket-newline': ['error', 'consistent'],
|
|
52
|
+
'@stylistic/array-element-newline': ['error', 'consistent'],
|
|
53
|
+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
|
|
54
|
+
'@stylistic/dot-location': ['error', 'property'],
|
|
55
|
+
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
|
|
56
|
+
'@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
|
|
57
|
+
'@stylistic/indent': ['error', 2, {
|
|
58
|
+
SwitchCase: 1,
|
|
59
|
+
}],
|
|
60
|
+
'@stylistic/lines-around-comment': ['error', {
|
|
61
|
+
allowBlockStart: true,
|
|
62
|
+
allowClassStart: true,
|
|
63
|
+
allowObjectStart: true,
|
|
64
|
+
allowTypeStart: true,
|
|
65
|
+
}],
|
|
66
|
+
'@stylistic/max-len': ['error', {
|
|
67
|
+
ignoreStrings: true,
|
|
68
|
+
ignoreTemplateLiterals: true,
|
|
69
|
+
}],
|
|
70
|
+
'@stylistic/multiline-comment-style': 'off',
|
|
71
|
+
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
|
|
72
|
+
'@stylistic/no-extra-parens': ['error', 'all', {
|
|
73
|
+
enforceForArrowConditionals: false,
|
|
74
|
+
ignoreJSX: 'multi-line',
|
|
75
|
+
nestedBinaryExpressions: false,
|
|
76
|
+
returnAssign: false,
|
|
77
|
+
}],
|
|
78
|
+
'@stylistic/no-multiple-empty-lines': ['error', { max: 1 }],
|
|
79
|
+
'@stylistic/object-curly-newline': ['error', {
|
|
80
|
+
consistent: true,
|
|
81
|
+
minProperties: 4,
|
|
82
|
+
}],
|
|
83
|
+
|
|
84
|
+
'@stylistic/object-property-newline': ['error', {
|
|
85
|
+
allowAllPropertiesOnSameLine: true,
|
|
86
|
+
}],
|
|
87
|
+
'@stylistic/operator-linebreak': ['error', 'before'],
|
|
88
|
+
'@stylistic/padded-blocks': ['error', 'never'],
|
|
89
|
+
'@stylistic/quote-props': ['error', 'as-needed'],
|
|
90
|
+
'@stylistic/quotes': ['error', 'single'],
|
|
91
|
+
'@stylistic/space-before-function-paren': ['error', {
|
|
92
|
+
named: 'never',
|
|
93
|
+
}],
|
|
94
|
+
'import/no-cycle': 'error',
|
|
95
|
+
'import/no-extraneous-dependencies': 'error',
|
|
96
|
+
|
|
97
|
+
'no-use-before-define': 'error',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
{
|
|
102
|
+
// TypeScript-specific configuration.
|
|
103
|
+
files: ['**/*.{ts,tsx}'],
|
|
104
|
+
languageOptions: {
|
|
105
|
+
parserOptions: {
|
|
106
|
+
projectService: true,
|
|
107
|
+
tsconfigRootDir: import.meta.dirname,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
extends: [
|
|
111
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
112
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
113
|
+
],
|
|
114
|
+
rules: {
|
|
115
|
+
'@typescript-eslint/array-type': 'off',
|
|
116
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
117
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
118
|
+
|
|
119
|
+
// TODO: Its current implementation seems to give false positive.
|
|
120
|
+
'@typescript-eslint/no-invalid-void-type': 'off',
|
|
121
|
+
|
|
122
|
+
// NOTE: According to its documentation
|
|
123
|
+
// "@typescript-eslint/no-unused-vars"
|
|
124
|
+
// requires to disable "no-unused-vars".
|
|
125
|
+
'no-unused-vars': 'off',
|
|
126
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
127
|
+
|
|
128
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
129
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
{
|
|
134
|
+
files: ['__tests__/**/*.{js,mjs,cjs,ts,jsx,tsx}'],
|
|
135
|
+
// TODO: Is this "extends" really necessary?
|
|
136
|
+
extends: [pluginJest.configs['flat/recommended']],
|
|
137
|
+
rules: {
|
|
138
|
+
'jest/unbound-method': 'error',
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
);
|