@snowyyd/eslint-config 1.1.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/LICENSE +21 -0
- package/README.md +86 -0
- package/base.d.ts +3 -0
- package/base.js +10 -0
- package/index.d.ts +5 -0
- package/index.js +21 -0
- package/lib/convert-configs.js +47 -0
- package/lib/personal.js +83 -0
- package/lib/shared.js +219 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Matt Turnbull <matt@iamturns.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# eslint-config-x
|
|
2
|
+
|
|
3
|
+
An [ESLint](https://eslint.org/) configuration I use in personal JavaScript/TypeScript projects.
|
|
4
|
+
Based on [Airbnb](https://github.com/airbnb/javascript), and [Airbnb TypeScript](https://github.com/claabs/eslint-config-airbnb-typescript-x).
|
|
5
|
+
|
|
6
|
+
> [!IMPORTANT]
|
|
7
|
+
> This configuration is not intended to be "stable" or for "public use", especially since my JavaScript standards are not widely used (e.g., brace style).
|
|
8
|
+
> There are still changes I need to make to properly migrate my [old config](https://github.com/n0bodysec/eslint-config-n0bodysec) to ESLint v9.
|
|
9
|
+
>
|
|
10
|
+
> If for some reason you came to this repository looking for an implementation more faithful to Airbnb standards, I recommend one of the following alternatives:
|
|
11
|
+
> 1. https://github.com/claabs/eslint-config-airbnb-typescript-x
|
|
12
|
+
> 2. https://github.com/Kenneth-Sills/eslint-config-airbnb-typescript
|
|
13
|
+
|
|
14
|
+
## 🚀 Usage
|
|
15
|
+
|
|
16
|
+
```shell
|
|
17
|
+
npm install --save-dev typescript-eslint
|
|
18
|
+
npm install --save-dev @snowyyd/eslint-config
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## ⚙️ Example Config
|
|
22
|
+
|
|
23
|
+
### 🥝 TypeScript only
|
|
24
|
+
```ts
|
|
25
|
+
// eslint.config.mjs
|
|
26
|
+
|
|
27
|
+
import configX from '@snowyyd/eslint-config/base';
|
|
28
|
+
import tseslint from 'typescript-eslint';
|
|
29
|
+
|
|
30
|
+
export default tseslint.config(
|
|
31
|
+
...configX,
|
|
32
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
33
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
34
|
+
{
|
|
35
|
+
ignores: ['node_modules', 'dist'],
|
|
36
|
+
languageOptions: {
|
|
37
|
+
parserOptions: {
|
|
38
|
+
projectService: true,
|
|
39
|
+
tsconfigRootDir: import.meta.dirname,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 🍉 Mixed (JS and TS)
|
|
47
|
+
```ts
|
|
48
|
+
// eslint.config.mjs
|
|
49
|
+
|
|
50
|
+
import configX from '@snowyyd/eslint-config-x/base';
|
|
51
|
+
import tseslint from 'typescript-eslint';
|
|
52
|
+
|
|
53
|
+
export default tseslint.config(
|
|
54
|
+
...configX,
|
|
55
|
+
{
|
|
56
|
+
ignores: ['node_modules', 'dist'],
|
|
57
|
+
languageOptions: {
|
|
58
|
+
parserOptions: {
|
|
59
|
+
projectService: true,
|
|
60
|
+
tsconfigRootDir: import.meta.dirname,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
66
|
+
extends: [
|
|
67
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
68
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 📝 Changelog
|
|
75
|
+
|
|
76
|
+
Read the [commits](../../commits) for a comprehensive list of changes.
|
|
77
|
+
|
|
78
|
+
## 👍 Acknowledgements
|
|
79
|
+
|
|
80
|
+
- [Airbnb](https://github.com/airbnb) - Base [config](https://github.com/airbnb/javascript).
|
|
81
|
+
- [Matt Turnbull](https://github.com/iamturns) - Base [Airbnb TS](https://github.com/iamturns/eslint-config-airbnb-typescript).
|
|
82
|
+
- [Charlie Laabs](https://github.com/claabs) - Airbnb TS [fork](https://github.com/claabs/eslint-config-airbnb-typescript-x).
|
|
83
|
+
|
|
84
|
+
## 📜 License
|
|
85
|
+
|
|
86
|
+
Licensed under [MIT License](LICENSE).
|
package/base.d.ts
ADDED
package/base.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
2
|
+
const shared = require('./lib/shared');
|
|
3
|
+
const personal = require('./lib/personal');
|
|
4
|
+
const { convertConfigs } = require('./lib/convert-configs');
|
|
5
|
+
|
|
6
|
+
const compat = new FlatCompat();
|
|
7
|
+
|
|
8
|
+
const config = convertConfigs([...compat.extends('eslint-config-airbnb-base'), ...shared, ...personal]);
|
|
9
|
+
|
|
10
|
+
module.exports = config;
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
2
|
+
const shared = require('./lib/shared');
|
|
3
|
+
const personal = require('./lib/personal');
|
|
4
|
+
const { convertConfigs } = require('./lib/convert-configs');
|
|
5
|
+
|
|
6
|
+
const compat = new FlatCompat();
|
|
7
|
+
|
|
8
|
+
const config = convertConfigs([
|
|
9
|
+
...compat.extends('eslint-config-airbnb'),
|
|
10
|
+
...shared,
|
|
11
|
+
...personal,
|
|
12
|
+
{
|
|
13
|
+
rules: {
|
|
14
|
+
// Append 'tsx' to Airbnb 'react/jsx-filename-extension' rule
|
|
15
|
+
// Original: ['.jsx']
|
|
16
|
+
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
module.exports = config;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const pluginImport = require('eslint-plugin-import-x');
|
|
2
|
+
const stylistic = require('@stylistic/eslint-plugin');
|
|
3
|
+
|
|
4
|
+
const deprecatedFormattingRules = Object.keys(stylistic.configs['disable-legacy']);
|
|
5
|
+
|
|
6
|
+
const replacePluginName = (obj) => Object.fromEntries(
|
|
7
|
+
Object.entries(obj).map(([key, value]) =>
|
|
8
|
+
{
|
|
9
|
+
let newKey = key;
|
|
10
|
+
// Replace deprecated formatting rules with stylistic.
|
|
11
|
+
if (deprecatedFormattingRules.includes(key))
|
|
12
|
+
{
|
|
13
|
+
const ruleName = key.split('/').at(-1);
|
|
14
|
+
newKey = `@stylistic/${ruleName}`;
|
|
15
|
+
}
|
|
16
|
+
// Replace import rules with import-x
|
|
17
|
+
newKey = newKey.replace('import/', 'import-x/');
|
|
18
|
+
return [newKey, value];
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const importXPlugin = pluginImport.flatConfigs.recommended.plugins['import-x'];
|
|
23
|
+
|
|
24
|
+
const convertConfigs = (configs) =>
|
|
25
|
+
{
|
|
26
|
+
const newConfigs = configs.map((config) =>
|
|
27
|
+
{
|
|
28
|
+
let newConfig = config;
|
|
29
|
+
if ('plugins' in config && 'import' in config.plugins)
|
|
30
|
+
{
|
|
31
|
+
newConfig = Object.assign(newConfig, { plugins: { 'import-x': importXPlugin } });
|
|
32
|
+
delete newConfig.plugins.import;
|
|
33
|
+
}
|
|
34
|
+
if ('settings' in config)
|
|
35
|
+
{
|
|
36
|
+
newConfig = Object.assign(newConfig, { settings: replacePluginName(config.settings) });
|
|
37
|
+
}
|
|
38
|
+
if ('rules' in config)
|
|
39
|
+
{
|
|
40
|
+
newConfig = Object.assign(newConfig, { rules: replacePluginName(config.rules) });
|
|
41
|
+
}
|
|
42
|
+
return config;
|
|
43
|
+
});
|
|
44
|
+
return newConfigs;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = { convertConfigs };
|
package/lib/personal.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices');
|
|
2
|
+
|
|
3
|
+
const baseRules = {
|
|
4
|
+
'object-curly-newline': ['error', {
|
|
5
|
+
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
|
|
6
|
+
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
|
|
7
|
+
ImportDeclaration: 'never',
|
|
8
|
+
ExportDeclaration: 'never',
|
|
9
|
+
}],
|
|
10
|
+
'brace-style': ['error', 'allman', { allowSingleLine: true }],
|
|
11
|
+
indent: ['error', 'tab', { SwitchCase: 1 }],
|
|
12
|
+
'no-tabs': ['error', { allowIndentationTabs: true }],
|
|
13
|
+
'max-len': 'off',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = [
|
|
17
|
+
{
|
|
18
|
+
rules: {
|
|
19
|
+
'import/no-dynamic-require': 'off',
|
|
20
|
+
'import/prefer-default-export': 'off',
|
|
21
|
+
|
|
22
|
+
'prefer-template': 'off',
|
|
23
|
+
'prefer-destructuring': 'off',
|
|
24
|
+
'prefer-arrow-callback': 'off',
|
|
25
|
+
|
|
26
|
+
'no-console': 'off',
|
|
27
|
+
'no-param-reassign': 'off',
|
|
28
|
+
'no-plusplus': 'off',
|
|
29
|
+
'no-continue': 'off',
|
|
30
|
+
|
|
31
|
+
'no-restricted-syntax': [
|
|
32
|
+
'error',
|
|
33
|
+
{
|
|
34
|
+
selector: 'ForInStatement',
|
|
35
|
+
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
|
|
36
|
+
},
|
|
37
|
+
/* {
|
|
38
|
+
selector: 'ForOfStatement',
|
|
39
|
+
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
|
|
40
|
+
}, */
|
|
41
|
+
{
|
|
42
|
+
selector: 'LabeledStatement',
|
|
43
|
+
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
selector: 'WithStatement',
|
|
47
|
+
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
|
|
51
|
+
// style
|
|
52
|
+
'object-curly-newline': 'off',
|
|
53
|
+
'@stylistic/object-curly-newline': baseRules['object-curly-newline'],
|
|
54
|
+
|
|
55
|
+
'brace-style': 'off',
|
|
56
|
+
'@stylistic/brace-style': baseRules['brace-style'],
|
|
57
|
+
|
|
58
|
+
indent: 'off',
|
|
59
|
+
'@stylistic/indent': baseRules.indent,
|
|
60
|
+
|
|
61
|
+
'no-tabs': 'off',
|
|
62
|
+
'@stylistic/no-tabs': baseRules['no-tabs'],
|
|
63
|
+
|
|
64
|
+
'max-len': 'off',
|
|
65
|
+
'@stylistic/max-len': baseRules['max-len'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
70
|
+
rules: {
|
|
71
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
72
|
+
|
|
73
|
+
// https://github.com/iamturns/eslint-config-airbnb-typescript/issues/344
|
|
74
|
+
'class-methods-use-this': 'off',
|
|
75
|
+
'@typescript-eslint/class-methods-use-this': [
|
|
76
|
+
baseBestPracticesRules['class-methods-use-this'][0],
|
|
77
|
+
{
|
|
78
|
+
...baseBestPracticesRules['class-methods-use-this'][1],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
];
|
package/lib/shared.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices');
|
|
2
|
+
const { rules: baseErrorsRules } = require('eslint-config-airbnb-base/rules/errors');
|
|
3
|
+
const { rules: baseES6Rules } = require('eslint-config-airbnb-base/rules/es6');
|
|
4
|
+
const { rules: baseImportsRules } = require('eslint-config-airbnb-base/rules/imports');
|
|
5
|
+
const { rules: baseStyleRules } = require('eslint-config-airbnb-base/rules/style');
|
|
6
|
+
const { rules: baseVariablesRules } = require('eslint-config-airbnb-base/rules/variables');
|
|
7
|
+
const tsEslintPlugin = require('@typescript-eslint/eslint-plugin');
|
|
8
|
+
const parserBase = require('@typescript-eslint/parser');
|
|
9
|
+
const stylistic = require('@stylistic/eslint-plugin');
|
|
10
|
+
const eslintPluginImportX = require('eslint-plugin-import-x');
|
|
11
|
+
|
|
12
|
+
module.exports = [
|
|
13
|
+
{
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: {
|
|
16
|
+
// ? TODO: This must be only used on TS files
|
|
17
|
+
meta: parserBase.meta,
|
|
18
|
+
parseForESLint: parserBase.parseForESLint,
|
|
19
|
+
},
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
},
|
|
22
|
+
plugins: {
|
|
23
|
+
'@typescript-eslint': tsEslintPlugin, // TODO: This must be only used on TS files
|
|
24
|
+
'@stylistic': stylistic,
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
...eslintPluginImportX.flatConfigs.typescript.settings,
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
'brace-style': 'off',
|
|
31
|
+
'@stylistic/brace-style': baseStyleRules['brace-style'],
|
|
32
|
+
|
|
33
|
+
// The TypeScript version also adds 3 new options, all of which should be
|
|
34
|
+
// set to the same value as the base config
|
|
35
|
+
'comma-dangle': 'off',
|
|
36
|
+
'@stylistic/comma-dangle': [
|
|
37
|
+
baseStyleRules['comma-dangle'][0],
|
|
38
|
+
{
|
|
39
|
+
...baseStyleRules['comma-dangle'][1],
|
|
40
|
+
enums: baseStyleRules['comma-dangle'][1].arrays,
|
|
41
|
+
generics: baseStyleRules['comma-dangle'][1].arrays,
|
|
42
|
+
tuples: baseStyleRules['comma-dangle'][1].arrays,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
'comma-spacing': 'off',
|
|
47
|
+
'@stylistic/comma-spacing': baseStyleRules['comma-spacing'],
|
|
48
|
+
|
|
49
|
+
'func-call-spacing': 'off',
|
|
50
|
+
'@stylistic/func-call-spacing': baseStyleRules['func-call-spacing'],
|
|
51
|
+
|
|
52
|
+
indent: 'off',
|
|
53
|
+
'@stylistic/indent': baseStyleRules.indent,
|
|
54
|
+
|
|
55
|
+
'keyword-spacing': 'off',
|
|
56
|
+
'@stylistic/keyword-spacing': baseStyleRules['keyword-spacing'],
|
|
57
|
+
|
|
58
|
+
'lines-between-class-members': 'off',
|
|
59
|
+
'@stylistic/lines-between-class-members': baseStyleRules['lines-between-class-members'],
|
|
60
|
+
|
|
61
|
+
'no-extra-parens': 'off',
|
|
62
|
+
'@stylistic/no-extra-parens': baseErrorsRules['no-extra-parens'],
|
|
63
|
+
|
|
64
|
+
'no-extra-semi': 'off',
|
|
65
|
+
'@stylistic/no-extra-semi': baseErrorsRules['no-extra-semi'],
|
|
66
|
+
|
|
67
|
+
'space-before-blocks': 'off',
|
|
68
|
+
'@stylistic/space-before-blocks': baseStyleRules['space-before-blocks'],
|
|
69
|
+
|
|
70
|
+
quotes: 'off',
|
|
71
|
+
'@stylistic/quotes': baseStyleRules.quotes,
|
|
72
|
+
|
|
73
|
+
semi: 'off',
|
|
74
|
+
'@stylistic/semi': baseStyleRules.semi,
|
|
75
|
+
|
|
76
|
+
'space-before-function-paren': 'off',
|
|
77
|
+
'@stylistic/space-before-function-paren': baseStyleRules['space-before-function-paren'],
|
|
78
|
+
|
|
79
|
+
'space-infix-ops': 'off',
|
|
80
|
+
'@stylistic/space-infix-ops': baseStyleRules['space-infix-ops'],
|
|
81
|
+
|
|
82
|
+
'object-curly-spacing': 'off',
|
|
83
|
+
'@stylistic/object-curly-spacing': baseStyleRules['object-curly-spacing'],
|
|
84
|
+
|
|
85
|
+
// Append all JS/TS extensions to Airbnb 'import/extensions' rule
|
|
86
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
|
|
87
|
+
'import/extensions': [
|
|
88
|
+
baseImportsRules['import/extensions'][0],
|
|
89
|
+
baseImportsRules['import/extensions'][1],
|
|
90
|
+
{
|
|
91
|
+
...baseImportsRules['import/extensions'][2],
|
|
92
|
+
cjs: 'never',
|
|
93
|
+
ts: 'never',
|
|
94
|
+
tsx: 'never',
|
|
95
|
+
mts: 'never',
|
|
96
|
+
cts: 'never',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
|
|
100
|
+
// Append all JS/TS extensions to Airbnb 'import/no-extraneous-dependencies' rule
|
|
101
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
102
|
+
'import/no-extraneous-dependencies': [
|
|
103
|
+
baseImportsRules['import/no-extraneous-dependencies'][0],
|
|
104
|
+
{
|
|
105
|
+
...baseImportsRules['import/no-extraneous-dependencies'][1],
|
|
106
|
+
devDependencies: [
|
|
107
|
+
...baseImportsRules['import/no-extraneous-dependencies'][1].devDependencies.map(
|
|
108
|
+
(devDep) =>
|
|
109
|
+
{
|
|
110
|
+
let newDevDep = devDep;
|
|
111
|
+
newDevDep = newDevDep.replace(/\.(js$|{js,jsx}$)/g, '.{js,jsx,mjs,cjs,ts,mts,cts}');
|
|
112
|
+
newDevDep = newDevDep.replace(/{,\.js}$/g, '{,.js,.jsx,.mjs,.cjs,.ts,.mts,.cts}');
|
|
113
|
+
return newDevDep;
|
|
114
|
+
},
|
|
115
|
+
[],
|
|
116
|
+
),
|
|
117
|
+
// Add new eslint config file
|
|
118
|
+
'**/eslint.config.{js,jsx,mjs,cjs,ts,mts,cts}',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
126
|
+
rules: {
|
|
127
|
+
// Rules
|
|
128
|
+
camelcase: 'off',
|
|
129
|
+
// The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
|
|
130
|
+
'@typescript-eslint/naming-convention': [
|
|
131
|
+
'error',
|
|
132
|
+
// Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
|
|
133
|
+
{
|
|
134
|
+
selector: 'variable',
|
|
135
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
136
|
+
},
|
|
137
|
+
// Allow camelCase functions (23.2), and PascalCase functions (23.8)
|
|
138
|
+
{
|
|
139
|
+
selector: 'function',
|
|
140
|
+
format: ['camelCase', 'PascalCase'],
|
|
141
|
+
},
|
|
142
|
+
// Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
|
|
143
|
+
{
|
|
144
|
+
selector: 'typeLike',
|
|
145
|
+
format: ['PascalCase'],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
|
|
149
|
+
'default-param-last': 'off',
|
|
150
|
+
'@typescript-eslint/default-param-last': baseBestPracticesRules['default-param-last'],
|
|
151
|
+
|
|
152
|
+
'dot-notation': 'off',
|
|
153
|
+
'@typescript-eslint/dot-notation': baseBestPracticesRules['dot-notation'],
|
|
154
|
+
|
|
155
|
+
'no-array-constructor': 'off',
|
|
156
|
+
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'],
|
|
157
|
+
|
|
158
|
+
'no-dupe-class-members': 'off',
|
|
159
|
+
'@typescript-eslint/no-dupe-class-members': baseES6Rules['no-dupe-class-members'],
|
|
160
|
+
|
|
161
|
+
'no-empty-function': 'off',
|
|
162
|
+
'@typescript-eslint/no-empty-function': baseBestPracticesRules['no-empty-function'],
|
|
163
|
+
|
|
164
|
+
'no-implied-eval': 'off',
|
|
165
|
+
// 'no-new-func': 'off',
|
|
166
|
+
'@typescript-eslint/no-implied-eval': baseBestPracticesRules['no-implied-eval'],
|
|
167
|
+
|
|
168
|
+
'no-loop-func': 'off',
|
|
169
|
+
'@typescript-eslint/no-loop-func': baseBestPracticesRules['no-loop-func'],
|
|
170
|
+
|
|
171
|
+
'no-magic-numbers': 'off',
|
|
172
|
+
'@typescript-eslint/no-magic-numbers': baseBestPracticesRules['no-magic-numbers'],
|
|
173
|
+
|
|
174
|
+
'no-redeclare': 'off',
|
|
175
|
+
'@typescript-eslint/no-redeclare': baseBestPracticesRules['no-redeclare'],
|
|
176
|
+
|
|
177
|
+
'no-shadow': 'off',
|
|
178
|
+
'@typescript-eslint/no-shadow': baseVariablesRules['no-shadow'],
|
|
179
|
+
|
|
180
|
+
'no-throw-literal': 'off',
|
|
181
|
+
'@typescript-eslint/only-throw-error': baseBestPracticesRules['no-throw-literal'],
|
|
182
|
+
|
|
183
|
+
'no-unused-expressions': 'off',
|
|
184
|
+
'@typescript-eslint/no-unused-expressions': baseBestPracticesRules['no-unused-expressions'],
|
|
185
|
+
|
|
186
|
+
'no-unused-vars': 'off',
|
|
187
|
+
'@typescript-eslint/no-unused-vars': baseVariablesRules['no-unused-vars'],
|
|
188
|
+
|
|
189
|
+
'no-use-before-define': 'off',
|
|
190
|
+
'@typescript-eslint/no-use-before-define': baseVariablesRules['no-use-before-define'],
|
|
191
|
+
|
|
192
|
+
'no-useless-constructor': 'off',
|
|
193
|
+
'@typescript-eslint/no-useless-constructor': baseES6Rules['no-useless-constructor'],
|
|
194
|
+
|
|
195
|
+
'require-await': 'off',
|
|
196
|
+
'@typescript-eslint/require-await': baseBestPracticesRules['require-await'],
|
|
197
|
+
|
|
198
|
+
'no-return-await': 'off',
|
|
199
|
+
'@typescript-eslint/return-await': [
|
|
200
|
+
baseBestPracticesRules['no-return-await'],
|
|
201
|
+
'in-try-catch',
|
|
202
|
+
],
|
|
203
|
+
|
|
204
|
+
// The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler
|
|
205
|
+
// Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
|
|
206
|
+
// Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
|
|
207
|
+
...tsEslintPlugin.configs['eslint-recommended'].overrides.rules,
|
|
208
|
+
|
|
209
|
+
// The following rules are enabled in Airbnb config, but are recommended to be disabled within TypeScript projects
|
|
210
|
+
// See: https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
|
|
211
|
+
'import/named': 'off',
|
|
212
|
+
'import/namespace': 'off',
|
|
213
|
+
'import/default': 'off',
|
|
214
|
+
'import/no-named-as-default-member': 'off',
|
|
215
|
+
// Disable `import/no-unresolved`, see README.md for details
|
|
216
|
+
'import/no-unresolved': 'off',
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snowyyd/eslint-config",
|
|
3
|
+
"description": "Airbnb's ESLint config with TypeScript support + my personal configs",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"homepage": "https://github.com/snowyyd/eslint-config-x#readme",
|
|
6
|
+
"repository": "https://github.com/snowyyd/eslint-config-x.git",
|
|
7
|
+
"bugs": "https://github.com/snowyyd/eslint-config-x/issues",
|
|
8
|
+
"author": "Snowy <snowyyd0@proton.me>",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "commonjs",
|
|
11
|
+
"main": "./index.js",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"default": "./index.js"
|
|
16
|
+
},
|
|
17
|
+
"./base": {
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"default": "./base.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"lint": "eslint ."
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/eslint": "^9.6.1",
|
|
29
|
+
"@types/node": "^22.7.2",
|
|
30
|
+
"typescript": "^5.6.2",
|
|
31
|
+
"typescript-eslint": "^8.7.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@eslint/eslintrc": "^3.1.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@stylistic/eslint-plugin": "^2.8.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.7.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.7.0",
|
|
40
|
+
"eslint": "^9.11.1",
|
|
41
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
42
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
43
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
44
|
+
"eslint-plugin-import-x": "^4.3.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"eslint-config-airbnb": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|