@rhyster/eslint-config 1.0.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 +20 -0
- package/README.md +7 -0
- package/dist/build.config.d.ts +3 -0
- package/dist/build.config.d.ts.map +1 -0
- package/dist/eslint.config.d.ts +853 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/index.cjs +1911 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3731 -0
- package/dist/index.d.mts +3731 -0
- package/dist/index.d.ts +3731 -0
- package/dist/index.mjs +1898 -0
- package/dist/index.mjs.map +1 -0
- package/dist/src/airbnb/best-practices.d.ts +177 -0
- package/dist/src/airbnb/best-practices.d.ts.map +1 -0
- package/dist/src/airbnb/errors.d.ts +69 -0
- package/dist/src/airbnb/errors.d.ts.map +1 -0
- package/dist/src/airbnb/es6.d.ts +82 -0
- package/dist/src/airbnb/es6.d.ts.map +1 -0
- package/dist/src/airbnb/imports.d.ts +91 -0
- package/dist/src/airbnb/imports.d.ts.map +1 -0
- package/dist/src/airbnb/node.d.ts +19 -0
- package/dist/src/airbnb/node.d.ts.map +1 -0
- package/dist/src/airbnb/strict.d.ts +8 -0
- package/dist/src/airbnb/strict.d.ts.map +1 -0
- package/dist/src/airbnb/style.d.ts +310 -0
- package/dist/src/airbnb/style.d.ts.map +1 -0
- package/dist/src/airbnb/variables.d.ts +35 -0
- package/dist/src/airbnb/variables.d.ts.map +1 -0
- package/dist/src/index.d.ts +3729 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/typescript.d.ts +49 -0
- package/dist/src/typescript.d.ts.map +1 -0
- package/package.json +59 -0
- package/src/airbnb/best-practices.ts +477 -0
- package/src/airbnb/errors.ts +215 -0
- package/src/airbnb/es6.ts +210 -0
- package/src/airbnb/imports.ts +288 -0
- package/src/airbnb/node.ts +54 -0
- package/src/airbnb/strict.ts +9 -0
- package/src/airbnb/style.ts +699 -0
- package/src/airbnb/variables.ts +74 -0
- package/src/index.ts +111 -0
- package/src/typescript.ts +90 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import confusingBrowserGlobals from 'confusing-browser-globals';
|
|
2
|
+
|
|
3
|
+
import type { Linter } from 'eslint';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: '@rhyster/eslint-config/airbnb/variables',
|
|
7
|
+
rules: {
|
|
8
|
+
// enforce or disallow variable initializations at definition
|
|
9
|
+
// https://eslint.org/docs/rules/init-declarations
|
|
10
|
+
'init-declarations': 'off',
|
|
11
|
+
|
|
12
|
+
// disallow deletion of variables
|
|
13
|
+
// https://eslint.org/docs/rules/no-delete-var
|
|
14
|
+
'no-delete-var': 'error',
|
|
15
|
+
|
|
16
|
+
// disallow labels that share a name with a variable
|
|
17
|
+
// https://eslint.org/docs/rules/no-label-var
|
|
18
|
+
'no-label-var': 'error',
|
|
19
|
+
|
|
20
|
+
// disallow specific globals
|
|
21
|
+
// https://eslint.org/docs/rules/no-restricted-globals
|
|
22
|
+
'no-restricted-globals': [
|
|
23
|
+
'error',
|
|
24
|
+
{
|
|
25
|
+
name: 'isFinite',
|
|
26
|
+
message:
|
|
27
|
+
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'isNaN',
|
|
31
|
+
message:
|
|
32
|
+
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
|
|
33
|
+
},
|
|
34
|
+
...confusingBrowserGlobals.map((g) => ({
|
|
35
|
+
name: g,
|
|
36
|
+
message: `Use window.${g} instead. https://github.com/facebook/create-react-app/blob/HEAD/packages/confusing-browser-globals/README.md`,
|
|
37
|
+
})),
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
// disallow declaration of variables already declared in the outer scope
|
|
41
|
+
// https://eslint.org/docs/rules/no-shadow
|
|
42
|
+
'no-shadow': 'error',
|
|
43
|
+
|
|
44
|
+
// disallow shadowing of names such as arguments
|
|
45
|
+
// https://eslint.org/docs/rules/no-shadow-restricted-names
|
|
46
|
+
'no-shadow-restricted-names': 'error',
|
|
47
|
+
|
|
48
|
+
// disallow use of undeclared variables unless mentioned in a /*global */ block
|
|
49
|
+
// https://eslint.org/docs/rules/no-undef
|
|
50
|
+
'no-undef': 'error',
|
|
51
|
+
|
|
52
|
+
// disallow use of undefined when initializing variables
|
|
53
|
+
// https://eslint.org/docs/rules/no-undef-init
|
|
54
|
+
'no-undef-init': 'error',
|
|
55
|
+
|
|
56
|
+
// disallow use of undefined variable
|
|
57
|
+
// https://eslint.org/docs/rules/no-undefined
|
|
58
|
+
'no-undefined': 'off',
|
|
59
|
+
|
|
60
|
+
// disallow declaration of variables that are not used in the code
|
|
61
|
+
// https://eslint.org/docs/rules/no-unused-vars
|
|
62
|
+
'no-unused-vars': [
|
|
63
|
+
'error',
|
|
64
|
+
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
|
|
65
|
+
],
|
|
66
|
+
|
|
67
|
+
// disallow use of variables before they are defined
|
|
68
|
+
// https://eslint.org/docs/rules/no-use-before-define
|
|
69
|
+
'no-use-before-define': [
|
|
70
|
+
'error',
|
|
71
|
+
{ functions: true, classes: true, variables: true },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
} satisfies Linter.Config;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import stylistic from '@stylistic/eslint-plugin';
|
|
2
|
+
import importx from 'eslint-plugin-import-x';
|
|
3
|
+
import nodePlugin from 'eslint-plugin-n';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
import tseslint from 'typescript-eslint';
|
|
6
|
+
|
|
7
|
+
import bestPractices from './airbnb/best-practices.ts';
|
|
8
|
+
import errors from './airbnb/errors.ts';
|
|
9
|
+
import es6 from './airbnb/es6.ts';
|
|
10
|
+
import imports from './airbnb/imports.ts';
|
|
11
|
+
import nodeRules from './airbnb/node.ts';
|
|
12
|
+
import strict from './airbnb/strict.ts';
|
|
13
|
+
import style from './airbnb/style.ts';
|
|
14
|
+
import variables from './airbnb/variables.ts';
|
|
15
|
+
import typescript from './typescript.ts';
|
|
16
|
+
|
|
17
|
+
import type { Linter } from 'eslint';
|
|
18
|
+
|
|
19
|
+
type Config = Linter.Config;
|
|
20
|
+
type Plugin = NonNullable<Config['plugins']>[string];
|
|
21
|
+
type Parser = NonNullable<Config['languageOptions']>['parser'];
|
|
22
|
+
|
|
23
|
+
const general = {
|
|
24
|
+
name: '@rhyster/eslint-config/airbnb/general',
|
|
25
|
+
plugins: {
|
|
26
|
+
'@typescript-eslint': tseslint.plugin as Plugin,
|
|
27
|
+
'@stylistic': stylistic as Plugin,
|
|
28
|
+
'import-x': importx as unknown as Plugin,
|
|
29
|
+
},
|
|
30
|
+
languageOptions: {
|
|
31
|
+
parser: tseslint.parser as Parser,
|
|
32
|
+
parserOptions: {
|
|
33
|
+
projectService: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
settings: {
|
|
37
|
+
'import-x/parsers': {
|
|
38
|
+
espree: [
|
|
39
|
+
'.js',
|
|
40
|
+
'.mjs',
|
|
41
|
+
],
|
|
42
|
+
'@typescript-eslint/parser': [
|
|
43
|
+
'.ts',
|
|
44
|
+
'.d.ts',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
'import-x/resolver': {
|
|
48
|
+
node: {
|
|
49
|
+
extensions: [
|
|
50
|
+
'.mjs',
|
|
51
|
+
'.js',
|
|
52
|
+
'.json',
|
|
53
|
+
'.ts',
|
|
54
|
+
'.d.ts',
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
'import-x/extensions': [
|
|
59
|
+
'.js',
|
|
60
|
+
'.mjs',
|
|
61
|
+
'.ts',
|
|
62
|
+
'.d.ts',
|
|
63
|
+
],
|
|
64
|
+
'import-x/core-modules': [],
|
|
65
|
+
'import-x/ignore': [
|
|
66
|
+
'node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$',
|
|
67
|
+
],
|
|
68
|
+
'import-x/external-module-folders': [
|
|
69
|
+
'node_modules',
|
|
70
|
+
'node_modules/@types',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
} as const satisfies Config;
|
|
74
|
+
|
|
75
|
+
export const core = [
|
|
76
|
+
{
|
|
77
|
+
name: '@rhyster/eslint-config/files-ts',
|
|
78
|
+
files: ['**/*.ts'],
|
|
79
|
+
},
|
|
80
|
+
general,
|
|
81
|
+
bestPractices,
|
|
82
|
+
errors,
|
|
83
|
+
style,
|
|
84
|
+
variables,
|
|
85
|
+
es6,
|
|
86
|
+
imports,
|
|
87
|
+
strict,
|
|
88
|
+
typescript,
|
|
89
|
+
] as const satisfies Config[];
|
|
90
|
+
|
|
91
|
+
export const node = [
|
|
92
|
+
...core,
|
|
93
|
+
{
|
|
94
|
+
languageOptions: {
|
|
95
|
+
globals: globals.node,
|
|
96
|
+
},
|
|
97
|
+
plugins: {
|
|
98
|
+
n: nodePlugin,
|
|
99
|
+
},
|
|
100
|
+
...nodeRules,
|
|
101
|
+
},
|
|
102
|
+
] as const satisfies Config[];
|
|
103
|
+
|
|
104
|
+
export const browser = [
|
|
105
|
+
...core,
|
|
106
|
+
{
|
|
107
|
+
languageOptions: {
|
|
108
|
+
globals: globals.browser,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
] as const satisfies Config[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
name: '@rhyster/eslint-config/typescript',
|
|
5
|
+
rules: {
|
|
6
|
+
// https://typescript-eslint.io/rules/naming-convention
|
|
7
|
+
'@typescript-eslint/naming-convention': 'error',
|
|
8
|
+
camelcase: 'off',
|
|
9
|
+
|
|
10
|
+
// https://typescript-eslint.io/rules/default-param-last
|
|
11
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
12
|
+
'default-param-last': 'off',
|
|
13
|
+
|
|
14
|
+
// https://typescript-eslint.io/rules/dot-notation
|
|
15
|
+
'@typescript-eslint/dot-notation': 'error',
|
|
16
|
+
'dot-notation': 'off',
|
|
17
|
+
|
|
18
|
+
// https://typescript-eslint.io/rules/no-array-constructor
|
|
19
|
+
'@typescript-eslint/no-array-constructor': 'error',
|
|
20
|
+
'no-array-constructor': 'off',
|
|
21
|
+
|
|
22
|
+
// https://typescript-eslint.io/rules/no-empty-function
|
|
23
|
+
'@typescript-eslint/no-empty-function': 'error',
|
|
24
|
+
'no-empty-function': 'off',
|
|
25
|
+
|
|
26
|
+
// https://typescript-eslint.io/rules/no-implied-eval
|
|
27
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
28
|
+
'no-implied-eval': 'off',
|
|
29
|
+
'no-new-func': 'off',
|
|
30
|
+
|
|
31
|
+
// https://typescript-eslint.io/rules/no-loop-func
|
|
32
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
33
|
+
'no-loop-func': 'off',
|
|
34
|
+
|
|
35
|
+
// https://typescript-eslint.io/rules/no-magic-numbers
|
|
36
|
+
'@typescript-eslint/no-magic-numbers': 'off',
|
|
37
|
+
'no-magic-numbers': 'off',
|
|
38
|
+
|
|
39
|
+
// https://typescript-eslint.io/rules/no-shadow
|
|
40
|
+
'@typescript-eslint/no-shadow': 'error',
|
|
41
|
+
'no-shadow': 'off',
|
|
42
|
+
|
|
43
|
+
// https://typescript-eslint.io/rules/only-throw-error
|
|
44
|
+
'@typescript-eslint/only-throw-error': 'error',
|
|
45
|
+
'no-throw-literal': 'off',
|
|
46
|
+
|
|
47
|
+
// https://typescript-eslint.io/rules/no-unused-expressions
|
|
48
|
+
'@typescript-eslint/no-unused-expressions': 'error',
|
|
49
|
+
'no-unused-expressions': 'off',
|
|
50
|
+
|
|
51
|
+
// https://typescript-eslint.io/rules/no-unused-vars
|
|
52
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
53
|
+
'no-unused-vars': 'off',
|
|
54
|
+
|
|
55
|
+
// https://typescript-eslint.io/rules/no-use-before-define
|
|
56
|
+
'@typescript-eslint/no-use-before-define': 'error',
|
|
57
|
+
'no-use-before-define': 'off',
|
|
58
|
+
|
|
59
|
+
// https://typescript-eslint.io/rules/no-useless-constructor
|
|
60
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
61
|
+
'no-useless-constructor': 'off',
|
|
62
|
+
|
|
63
|
+
// https://typescript-eslint.io/rules/prefer-promise-reject-errors
|
|
64
|
+
'@typescript-eslint/prefer-promise-reject-errors': 'error',
|
|
65
|
+
'prefer-promise-reject-errors': 'off',
|
|
66
|
+
|
|
67
|
+
// https://typescript-eslint.io/rules/require-await
|
|
68
|
+
'@typescript-eslint/require-await': 'off',
|
|
69
|
+
'require-await': 'off',
|
|
70
|
+
|
|
71
|
+
// https://typescript-eslint.io/rules/return-await
|
|
72
|
+
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
|
|
73
|
+
'no-return-await': 'off',
|
|
74
|
+
|
|
75
|
+
// https://typescript-eslint.io/rules/no-dupe-class-members
|
|
76
|
+
// checked by the TypeScript compiler
|
|
77
|
+
'no-dupe-class-members': 'off',
|
|
78
|
+
|
|
79
|
+
// https://typescript-eslint.io/rules/no-redeclare
|
|
80
|
+
// checked by the TypeScript compiler
|
|
81
|
+
'no-redeclare': 'off',
|
|
82
|
+
|
|
83
|
+
// https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
|
|
84
|
+
'import-x/named': 'off',
|
|
85
|
+
'import-x/namespace': 'off',
|
|
86
|
+
'import-x/default': 'off',
|
|
87
|
+
'import-x/no-named-as-default-member': 'off',
|
|
88
|
+
'import-x/no-unresolved': 'off',
|
|
89
|
+
},
|
|
90
|
+
} satisfies Linter.Config;
|