@plugjs/eslint-plugin 0.1.23 → 0.2.0-beta.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/README.md +35 -10
- package/configs/basic.mjs +184 -0
- package/configs/javascript.mjs +51 -0
- package/configs/typescript.mjs +51 -0
- package/eslint.config.mjs +40 -0
- package/package.json +28 -11
- package/configs/typescript.cjs +0 -192
- package/index.cjs +0 -5
package/README.md
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
|
-
PlugJS ESLint Shared Configuration
|
|
2
|
-
|
|
1
|
+
PlugJS ESLint (v9) Shared Configuration
|
|
2
|
+
=======================================
|
|
3
3
|
|
|
4
|
-
This package exports simple configurations for linting our
|
|
4
|
+
This package exports simple configurations for linting our projects. It's the
|
|
5
5
|
easiest way to actually share some configs and plugins.
|
|
6
6
|
|
|
7
|
-
Just add in your
|
|
7
|
+
Just add in your `eslint.config.mjs` something similar to:
|
|
8
8
|
|
|
9
9
|
```javascript
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
import configurations from '@plugjs/eslint-plugin'
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
...configurations,
|
|
14
|
+
// any other configuration you might want to add for your project...
|
|
15
|
+
]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
This includes a number of configurations:
|
|
19
|
+
|
|
20
|
+
* `eslint-recommended`: recommended JavaScript config from ESLint.
|
|
21
|
+
|
|
22
|
+
* `plugjs-base`: basic configuration of ESLint rules.
|
|
23
|
+
* `plugjs-stylistic`: style shared between JavaScript and TypeScript.
|
|
24
|
+
* `plugjs-unicorn`: extra niceties from the ESLint Unicorn plugin.
|
|
25
|
+
* `plugjs-importx`: defines the style of our imports.
|
|
26
|
+
|
|
27
|
+
* `plugjs-javascript`: basic extra rules for JavaScript sources.
|
|
28
|
+
* `plugjs-javascript-cjs`: marks `*.cjs` files as `commonjs`.
|
|
29
|
+
* `plugjs-javascript-mjs`: marks `*.mjs` files as `module`.
|
|
30
|
+
|
|
31
|
+
* `typescript-eslint/recommended`: imports all the configurations from
|
|
32
|
+
TypeScript ESlint recommended, but restrict them to operate only on
|
|
33
|
+
`.ts`, `.cts`, and `.mts` files. This *should* include:
|
|
34
|
+
* `typescript-eslint/base`: basic parser configuration.
|
|
35
|
+
* `typescript-eslint/eslint-recommended`: disable ESLint rules conflicting
|
|
36
|
+
with TypeScript.
|
|
37
|
+
* `typescript-eslint/recommended`: recommended config for TypeScript
|
|
38
|
+
* `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
|
|
39
|
+
|
|
40
|
+
Legal Stuff
|
|
41
|
+
-----------
|
|
42
|
+
|
|
18
43
|
* [Copyright Notice](NOTICE.md)
|
|
19
44
|
* [License](LICENSE.md)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import importxPlugin from 'eslint-plugin-import-x'
|
|
3
|
+
import stylisticPlugin from '@stylistic/eslint-plugin'
|
|
4
|
+
import unicornPlugin from 'eslint-plugin-unicorn'
|
|
5
|
+
|
|
6
|
+
/* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
/** Basic configuration of ESLint rules. */
|
|
9
|
+
export const base = {
|
|
10
|
+
name: 'plugjs-base',
|
|
11
|
+
|
|
12
|
+
languageOptions: {
|
|
13
|
+
globals: globals.es2024,
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
rules: {
|
|
17
|
+
'camelcase': [ 'error', {
|
|
18
|
+
properties: 'never',
|
|
19
|
+
|
|
20
|
+
} ],
|
|
21
|
+
'curly': [ 'error', 'multi-line' ],
|
|
22
|
+
'new-cap': 'error',
|
|
23
|
+
'no-caller': 'error',
|
|
24
|
+
'no-cond-assign': 'off', // overrides eslint recommended
|
|
25
|
+
'no-console': 'warn',
|
|
26
|
+
'no-debugger': 'warn',
|
|
27
|
+
'no-extend-native': 'error',
|
|
28
|
+
'no-extra-bind': 'error',
|
|
29
|
+
'no-multi-str': 'error',
|
|
30
|
+
'no-new-native-nonconstructor': 'error',
|
|
31
|
+
'no-new-wrappers': 'error',
|
|
32
|
+
'no-object-constructor': 'error',
|
|
33
|
+
'no-template-curly-in-string': 'error',
|
|
34
|
+
'no-throw-literal': 'error',
|
|
35
|
+
'no-useless-concat': 'error',
|
|
36
|
+
'no-var': 'error',
|
|
37
|
+
'no-warning-comments': 'warn',
|
|
38
|
+
'one-var': [ 'error', 'never' ],
|
|
39
|
+
'prefer-const': [ 'error', {
|
|
40
|
+
destructuring: 'all',
|
|
41
|
+
} ],
|
|
42
|
+
'prefer-promise-reject-errors': 'error',
|
|
43
|
+
'prefer-rest-params': 'error',
|
|
44
|
+
'prefer-spread': 'error',
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ========================================================================== */
|
|
49
|
+
|
|
50
|
+
/** Style shared between JavaScript and TypeScript. */
|
|
51
|
+
export const stylistic = {
|
|
52
|
+
name: 'plugjs-stylistic',
|
|
53
|
+
|
|
54
|
+
plugins: {
|
|
55
|
+
'@stylistic': stylisticPlugin,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
rules: {
|
|
59
|
+
'@stylistic/array-bracket-newline': 'off',
|
|
60
|
+
'@stylistic/array-bracket-spacing': [ 'error', 'always' ],
|
|
61
|
+
'@stylistic/arrow-parens': [ 'error', 'always' ],
|
|
62
|
+
'@stylistic/block-spacing': [ 'error', 'always' ],
|
|
63
|
+
'@stylistic/brace-style': 'error',
|
|
64
|
+
'@stylistic/comma-dangle': [ 'error', 'always-multiline' ],
|
|
65
|
+
'@stylistic/comma-spacing': 'error',
|
|
66
|
+
'@stylistic/comma-style': 'error',
|
|
67
|
+
'@stylistic/computed-property-spacing': 'error',
|
|
68
|
+
'@stylistic/eol-last': [ 'error', 'always' ],
|
|
69
|
+
'@stylistic/func-call-spacing': 'error',
|
|
70
|
+
'@stylistic/generator-star-spacing': [ 'error', 'after' ],
|
|
71
|
+
'@stylistic/indent': [ 'error', 2, {
|
|
72
|
+
CallExpression: {
|
|
73
|
+
'arguments': 2,
|
|
74
|
+
},
|
|
75
|
+
FunctionDeclaration: {
|
|
76
|
+
'body': 1,
|
|
77
|
+
'parameters': 2,
|
|
78
|
+
},
|
|
79
|
+
FunctionExpression: {
|
|
80
|
+
'body': 1,
|
|
81
|
+
'parameters': 2,
|
|
82
|
+
},
|
|
83
|
+
MemberExpression: 2,
|
|
84
|
+
ObjectExpression: 1,
|
|
85
|
+
SwitchCase: 1,
|
|
86
|
+
ignoredNodes: [
|
|
87
|
+
'ConditionalExpression',
|
|
88
|
+
],
|
|
89
|
+
} ],
|
|
90
|
+
'@stylistic/key-spacing': 'error',
|
|
91
|
+
'@stylistic/keyword-spacing': 'error',
|
|
92
|
+
'@stylistic/linebreak-style': 'error',
|
|
93
|
+
'@stylistic/no-mixed-spaces-and-tabs': 'error',
|
|
94
|
+
'@stylistic/no-multi-spaces': 'error',
|
|
95
|
+
'@stylistic/no-multiple-empty-lines': [ 'error', { 'max': 2, 'maxBOF': 0, 'maxEOF': 1 } ],
|
|
96
|
+
'@stylistic/no-tabs': 'error',
|
|
97
|
+
'@stylistic/no-trailing-spaces': 'error',
|
|
98
|
+
'@stylistic/object-curly-spacing': [ 'error', 'always' ],
|
|
99
|
+
'@stylistic/operator-linebreak': [ 'error', 'after' ],
|
|
100
|
+
'@stylistic/padded-blocks': [ 'error', 'never' ],
|
|
101
|
+
'@stylistic/quote-props': [ 'error', 'consistent' ],
|
|
102
|
+
'@stylistic/quotes': [ 'error', 'single', { 'allowTemplateLiterals': false } ],
|
|
103
|
+
'@stylistic/semi': [ 'error', 'never' ],
|
|
104
|
+
'@stylistic/semi-spacing': 'error',
|
|
105
|
+
'@stylistic/space-before-blocks': 'error',
|
|
106
|
+
'@stylistic/space-before-function-paren': [ 'error', {
|
|
107
|
+
asyncArrow: 'always',
|
|
108
|
+
anonymous: 'never',
|
|
109
|
+
named: 'never',
|
|
110
|
+
} ],
|
|
111
|
+
'@stylistic/spaced-comment': [ 'error', 'always', { 'markers': [ '/ <reference' ] } ],
|
|
112
|
+
'@stylistic/switch-colon-spacing': 'error',
|
|
113
|
+
'@stylistic/rest-spread-spacing': 'error',
|
|
114
|
+
'@stylistic/yield-star-spacing': [ 'error', 'after' ],
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ========================================================================== */
|
|
119
|
+
|
|
120
|
+
/** Extra niceties from the ESLint Unicorn plugin. */
|
|
121
|
+
export const unicorn = {
|
|
122
|
+
name: 'plugjs-unicorn',
|
|
123
|
+
|
|
124
|
+
plugins: {
|
|
125
|
+
'unicorn': unicornPlugin,
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
rules: {
|
|
129
|
+
'unicorn/empty-brace-spaces': 'error',
|
|
130
|
+
'unicorn/no-instanceof-array': 'error',
|
|
131
|
+
'unicorn/prefer-node-protocol': 'error',
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/* ========================================================================== */
|
|
136
|
+
|
|
137
|
+
/** Defines the style of our imports. */
|
|
138
|
+
export const importx = {
|
|
139
|
+
name: 'plugjs-importx',
|
|
140
|
+
|
|
141
|
+
plugins: {
|
|
142
|
+
'import-x': importxPlugin,
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
settings: {
|
|
146
|
+
'import-x/extensions': [ '.ts', '.cts', '.mts', '.js', '.cjs', '.mjs' ],
|
|
147
|
+
'import-x/external-module-folders': [ 'node_modules', 'node_modules/@types' ],
|
|
148
|
+
'import-x/parsers': {
|
|
149
|
+
'@typescript-eslint/parser': [ '.ts', '.cts', '.mts' ],
|
|
150
|
+
'espree': [ '.js', '.mjs', '.cjs' ],
|
|
151
|
+
},
|
|
152
|
+
'import-x/resolver': {
|
|
153
|
+
'typescript': true,
|
|
154
|
+
'node': true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
rules: {
|
|
159
|
+
'import-x/consistent-type-specifier-style': [ 'error', 'prefer-top-level' ],
|
|
160
|
+
'import-x/no-cycle': [ 'error' ],
|
|
161
|
+
'import-x/no-duplicates': [ 'error' ],
|
|
162
|
+
'import-x/no-extraneous-dependencies': [ 'off' ],
|
|
163
|
+
'import-x/order': [ 'error', {
|
|
164
|
+
'groups': [ 'builtin', 'external', 'internal', [ 'parent', 'sibling' ], 'index', 'object', 'type' ],
|
|
165
|
+
'newlines-between': 'always',
|
|
166
|
+
'warnOnUnassignedImports': true,
|
|
167
|
+
} ],
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* ========================================================================== */
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Base module: declares all the common rules shared between JavaScript and
|
|
175
|
+
* TypeScript code bases.
|
|
176
|
+
*
|
|
177
|
+
* This module includes these configurations:
|
|
178
|
+
*
|
|
179
|
+
* * `plugjs-base`: basic configuration of ESLint rules.
|
|
180
|
+
* * `plugjs-stylistic`: style shared between JavaScript and TypeScript.
|
|
181
|
+
* * `plugjs-unicorn`: extra niceties from the ESLint Unicorn plugin.
|
|
182
|
+
* * `plugjs-importx`: defines the style of our imports.
|
|
183
|
+
*/
|
|
184
|
+
export default [ base, stylistic, unicorn, importx ]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Basic extra rules for JavaScript sources. */
|
|
2
|
+
export const javascript = {
|
|
3
|
+
name: 'plugjs-javascript',
|
|
4
|
+
|
|
5
|
+
files: [ '*.js', '*.cjs', '*.mjs' ],
|
|
6
|
+
|
|
7
|
+
rules: {
|
|
8
|
+
'guard-for-in': 'error',
|
|
9
|
+
'no-array-constructor': 'error',
|
|
10
|
+
'no-invalid-this': 'error',
|
|
11
|
+
'no-unused-expressions': 'error',
|
|
12
|
+
'no-unused-vars': [ 'error', {
|
|
13
|
+
args: 'after-used',
|
|
14
|
+
argsIgnorePattern: '^_',
|
|
15
|
+
} ],
|
|
16
|
+
'strict': [ 'error', 'global' ],
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Marks `*.cjs` files as `commonjs`. */
|
|
21
|
+
export const javascriptCommonJs = {
|
|
22
|
+
name: 'plugjs-javascript-cjs',
|
|
23
|
+
|
|
24
|
+
files: [ '*.cjs' ],
|
|
25
|
+
|
|
26
|
+
languageOptions: {
|
|
27
|
+
sourceType: 'commonjs',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Marks `*.mjs` files as `module`. */
|
|
32
|
+
export const javascriptModule = {
|
|
33
|
+
name: 'plugjs-javascript-esm',
|
|
34
|
+
|
|
35
|
+
files: [ '*.mjs' ],
|
|
36
|
+
|
|
37
|
+
languageOptions: {
|
|
38
|
+
sourceType: 'module',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* JavaScript module: declares all the common rules for JavaScript code bases.
|
|
44
|
+
*
|
|
45
|
+
* This module includes these configurations:
|
|
46
|
+
*
|
|
47
|
+
* * `plugjs-javascript`: basic extra rules for JavaScript sources.
|
|
48
|
+
* * `plugjs-javascript-cjs`: marks `*.cjs` files as `commonjs`.
|
|
49
|
+
* * `plugjs-javascript-mjs`: marks `*.mjs` files as `module`.
|
|
50
|
+
*/
|
|
51
|
+
export default [ javascript, javascriptCommonJs, javascriptModule ]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint'
|
|
2
|
+
|
|
3
|
+
/** Our own rules overriding `typescript-eslint/recommended`. */
|
|
4
|
+
export const typescript = {
|
|
5
|
+
name: 'plugjs-typescript',
|
|
6
|
+
|
|
7
|
+
files: [ '**/*.ts', '**/*.cts', '**/*.mts' ],
|
|
8
|
+
|
|
9
|
+
rules: {
|
|
10
|
+
'no-unused-vars': 'off', // overrides ESLint Recommended for TypeScript
|
|
11
|
+
'no-dupe-class-members': 'off', // overrides ESLint Recommended for TypeScript
|
|
12
|
+
|
|
13
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
14
|
+
'@typescript-eslint/explicit-function-return-type': [ 'error', {
|
|
15
|
+
allowExpressions: true,
|
|
16
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
17
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid: true,
|
|
18
|
+
} ],
|
|
19
|
+
'@typescript-eslint/no-dupe-class-members': 'error',
|
|
20
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
21
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
22
|
+
'@typescript-eslint/no-invalid-this': 'error',
|
|
23
|
+
'@typescript-eslint/no-unused-vars': [ 'error', {
|
|
24
|
+
args: 'after-used',
|
|
25
|
+
argsIgnorePattern: '^_',
|
|
26
|
+
} ],
|
|
27
|
+
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* TypeScript module: declares all the common rules for TypeScript code bases.
|
|
33
|
+
*
|
|
34
|
+
* This module includes these configurations:
|
|
35
|
+
*
|
|
36
|
+
* * `typescript-eslint/recommended`: imports all the configurations from
|
|
37
|
+
* TypeScript ESlint recommended, but restrict them to operate only on
|
|
38
|
+
* `.ts`, `.cts`, and `.mts` files. This *should* include:
|
|
39
|
+
* * `typescript-eslint/base`: basic parser configuration.
|
|
40
|
+
* * `typescript-eslint/eslint-recommended`: disable ESLint rules conflicting
|
|
41
|
+
* with TypeScript.
|
|
42
|
+
* * `typescript-eslint/recommended`: recommended config for TypeScript
|
|
43
|
+
* * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
|
|
44
|
+
*/
|
|
45
|
+
export default [
|
|
46
|
+
...tseslint.configs.recommended.map((config) => {
|
|
47
|
+
config.files = [ '**/*.ts', '**/*.cts', '**/*.mts' ]
|
|
48
|
+
return config
|
|
49
|
+
}),
|
|
50
|
+
typescript,
|
|
51
|
+
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
|
|
3
|
+
import basic from './configs/basic.mjs'
|
|
4
|
+
import javascript from './configs/javascript.mjs'
|
|
5
|
+
import typescript from './configs/typescript.mjs'
|
|
6
|
+
|
|
7
|
+
export * from './configs/basic.mjs'
|
|
8
|
+
export * from './configs/javascript.mjs'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base `ESLint` configuration for PlugJS.
|
|
12
|
+
*
|
|
13
|
+
* This includes a number of configurations:
|
|
14
|
+
*
|
|
15
|
+
* * `eslint-recommended`: recommended JavaScript config from ESLint.
|
|
16
|
+
*
|
|
17
|
+
* * `plugjs-base`: basic configuration of ESLint rules.
|
|
18
|
+
* * `plugjs-stylistic`: style shared between JavaScript and TypeScript.
|
|
19
|
+
* * `plugjs-unicorn`: extra niceties from the ESLint Unicorn plugin.
|
|
20
|
+
* * `plugjs-importx`: defines the style of our imports.
|
|
21
|
+
*
|
|
22
|
+
* * `plugjs-javascript`: basic extra rules for JavaScript sources.
|
|
23
|
+
* * `plugjs-javascript-cjs`: marks `*.cjs` files as `commonjs`.
|
|
24
|
+
* * `plugjs-javascript-mjs`: marks `*.mjs` files as `module`.
|
|
25
|
+
*
|
|
26
|
+
* * `typescript-eslint/recommended`: imports all the configurations from
|
|
27
|
+
* TypeScript ESlint recommended, but restrict them to operate only on
|
|
28
|
+
* `.ts`, `.cts`, and `.mts` files. This *should* include:
|
|
29
|
+
* * `typescript-eslint/base`: basic parser configuration.
|
|
30
|
+
* * `typescript-eslint/eslint-recommended`: disable ESLint rules conflicting
|
|
31
|
+
* with TypeScript.
|
|
32
|
+
* * `typescript-eslint/recommended`: recommended config for TypeScript
|
|
33
|
+
* * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
|
|
34
|
+
*/
|
|
35
|
+
export default [
|
|
36
|
+
js.configs.recommended,
|
|
37
|
+
...basic,
|
|
38
|
+
...javascript,
|
|
39
|
+
...typescript,
|
|
40
|
+
]
|
package/package.json
CHANGED
|
@@ -1,26 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/eslint-plugin",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.0-beta.1",
|
|
4
4
|
"description": "Shared ESLint configurations and extras",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./eslint.config.mjs",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"author": "Team Juit <developers@juit.com>",
|
|
7
8
|
"license": "Apache-2.0",
|
|
8
9
|
"scripts": {
|
|
9
|
-
"build": "eslint
|
|
10
|
-
},
|
|
11
|
-
"peerDependencies": {
|
|
12
|
-
"@typescript-eslint/eslint-plugin": ">=6",
|
|
13
|
-
"@typescript-eslint/parser": ">=6"
|
|
10
|
+
"build": "eslint eslint.config.mjs configs"
|
|
14
11
|
},
|
|
15
12
|
"dependencies": {
|
|
16
|
-
"eslint
|
|
13
|
+
"@eslint/js": "^9.5.0",
|
|
14
|
+
"@stylistic/eslint-plugin": "^2.2.2",
|
|
17
15
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
18
|
-
"eslint-plugin-import": "^
|
|
19
|
-
"eslint-plugin-unicorn": "^54.0.0"
|
|
16
|
+
"eslint-plugin-import-x": "^0.5.1",
|
|
17
|
+
"eslint-plugin-unicorn": "^54.0.0",
|
|
18
|
+
"globals": "^15.6.0",
|
|
19
|
+
"typescript-eslint": "rc-v8"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"eslint": "^9.5.0"
|
|
23
|
+
},
|
|
24
|
+
"overrides": {
|
|
25
|
+
"@stylistic/eslint-plugin-plus": {
|
|
26
|
+
"@typescript-eslint/utils": "rc-v8"
|
|
27
|
+
},
|
|
28
|
+
"@stylistic/eslint-plugin-ts": {
|
|
29
|
+
"@typescript-eslint/utils": "rc-v8"
|
|
30
|
+
},
|
|
31
|
+
"eslint-plugin-import": {
|
|
32
|
+
"eslint": "^9.5.0"
|
|
33
|
+
},
|
|
34
|
+
"eslint-plugin-import-x": {
|
|
35
|
+
"@typescript-eslint/utils": "rc-v8"
|
|
36
|
+
}
|
|
20
37
|
},
|
|
21
38
|
"files": [
|
|
22
39
|
"*.md",
|
|
23
|
-
"
|
|
40
|
+
"eslint.config.mjs",
|
|
24
41
|
"configs/"
|
|
25
42
|
]
|
|
26
43
|
}
|
package/configs/typescript.cjs
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
env: {
|
|
5
|
-
es2020: true,
|
|
6
|
-
},
|
|
7
|
-
parser: '@typescript-eslint/parser',
|
|
8
|
-
parserOptions: {
|
|
9
|
-
ecmaVersion: 2020,
|
|
10
|
-
createDefaultProgram: false,
|
|
11
|
-
project: [
|
|
12
|
-
'./tsconfig.json',
|
|
13
|
-
'./test/tsconfig.json',
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
plugins: [
|
|
17
|
-
'@typescript-eslint',
|
|
18
|
-
'import',
|
|
19
|
-
'unicorn',
|
|
20
|
-
],
|
|
21
|
-
// Settings for "eslint-plugin-import"
|
|
22
|
-
settings: {
|
|
23
|
-
'import/extensions': [ '.ts', '.js', '.mjs', '.cjs' ],
|
|
24
|
-
'import/external-module-folders': [ 'node_modules', 'node_modules/@types' ],
|
|
25
|
-
'import/parsers': {
|
|
26
|
-
'@typescript-eslint/parser': [ '.ts' ],
|
|
27
|
-
'espree': [ '.js', '.mjs', '.cjs' ],
|
|
28
|
-
},
|
|
29
|
-
'import/resolver': {
|
|
30
|
-
'typescript': true,
|
|
31
|
-
'node': true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
extends: [
|
|
35
|
-
'google',
|
|
36
|
-
'eslint:recommended',
|
|
37
|
-
'plugin:@typescript-eslint/eslint-recommended',
|
|
38
|
-
],
|
|
39
|
-
rules: {
|
|
40
|
-
// No logging / no debugging
|
|
41
|
-
'no-console': [ 'warn' ],
|
|
42
|
-
'no-debugger': [ 'warn' ],
|
|
43
|
-
|
|
44
|
-
// Indenting, but for TypeScript
|
|
45
|
-
'indent': [ 'off' ],
|
|
46
|
-
'@typescript-eslint/indent': [ 'error', 2, {
|
|
47
|
-
'CallExpression': {
|
|
48
|
-
'arguments': 2,
|
|
49
|
-
},
|
|
50
|
-
'FunctionDeclaration': {
|
|
51
|
-
'body': 1,
|
|
52
|
-
'parameters': 2,
|
|
53
|
-
},
|
|
54
|
-
'FunctionExpression': {
|
|
55
|
-
'body': 1,
|
|
56
|
-
'parameters': 2,
|
|
57
|
-
},
|
|
58
|
-
'MemberExpression': 2,
|
|
59
|
-
'ObjectExpression': 1,
|
|
60
|
-
'SwitchCase': 1,
|
|
61
|
-
'ignoredNodes': [
|
|
62
|
-
'ConditionalExpression',
|
|
63
|
-
],
|
|
64
|
-
} ],
|
|
65
|
-
|
|
66
|
-
// Spaces before function parenthesis, for TypeScript
|
|
67
|
-
'space-before-function-paren': [ 'off' ],
|
|
68
|
-
'@typescript-eslint/space-before-function-paren': [ 'error', {
|
|
69
|
-
asyncArrow: 'always',
|
|
70
|
-
anonymous: 'never',
|
|
71
|
-
named: 'never',
|
|
72
|
-
} ],
|
|
73
|
-
|
|
74
|
-
// Always have spaces around arrays and objects
|
|
75
|
-
'array-bracket-spacing': [ 'error', 'always' ],
|
|
76
|
-
'object-curly-spacing': [ 'error', 'always' ],
|
|
77
|
-
|
|
78
|
-
// Always have newline character at the end of the file
|
|
79
|
-
'eol-last': [ 'error', 'always' ],
|
|
80
|
-
|
|
81
|
-
// No constraints for the max line length
|
|
82
|
-
'max-len': [ 'off' ],
|
|
83
|
-
|
|
84
|
-
// No more than 2 blank lines
|
|
85
|
-
'no-multiple-empty-lines': [ 'error', { 'max': 2, 'maxBOF': 0, 'maxEOF': 1 } ],
|
|
86
|
-
|
|
87
|
-
// Srings: either '...' or `... ${...} ...`, and no 'ab' + 'cd'
|
|
88
|
-
'no-template-curly-in-string': [ 'error' ],
|
|
89
|
-
'quotes': [ 'error', 'single', { 'allowTemplateLiterals': false } ],
|
|
90
|
-
'no-useless-concat': [ 'error' ],
|
|
91
|
-
|
|
92
|
-
// One variable per declaration, no "const x, y, ..."
|
|
93
|
-
'one-var': [ 'error', 'never' ],
|
|
94
|
-
|
|
95
|
-
// No semicolons
|
|
96
|
-
'semi': [ 'error', 'never' ],
|
|
97
|
-
|
|
98
|
-
// Allow TypeScript triple-slash comments
|
|
99
|
-
'spaced-comment': [ 'error', 'always', { 'markers': [ '/ <reference' ] } ],
|
|
100
|
-
|
|
101
|
-
// Remember our TODOs and FIXMEs
|
|
102
|
-
'no-warning-comments': [ 'warn' ],
|
|
103
|
-
|
|
104
|
-
// No "proper" JSDoc
|
|
105
|
-
'require-jsdoc': [ 'off' ], // nope!
|
|
106
|
-
'valid-jsdoc': [ 'off' ], // nope as well!
|
|
107
|
-
|
|
108
|
-
// TypeScript sanity
|
|
109
|
-
'@typescript-eslint/consistent-type-imports': [ 'error' ],
|
|
110
|
-
'@typescript-eslint/no-unused-vars': [ 'error' ],
|
|
111
|
-
'@typescript-eslint/no-dupe-class-members': [ 'error' ],
|
|
112
|
-
'@typescript-eslint/no-invalid-this': [ 'error' ],
|
|
113
|
-
'@typescript-eslint/no-floating-promises': [ 'error' ],
|
|
114
|
-
'@typescript-eslint/explicit-function-return-type': [ 'error', {
|
|
115
|
-
'allowExpressions': true,
|
|
116
|
-
'allowDirectConstAssertionInArrowFunctions': true,
|
|
117
|
-
'allowConciseArrowFunctionExpressionsStartingWithVoid': true,
|
|
118
|
-
} ],
|
|
119
|
-
|
|
120
|
-
// Import specifics
|
|
121
|
-
'import/no-cycle': [ 'error' ],
|
|
122
|
-
'import/no-duplicates': [ 'error' ],
|
|
123
|
-
'import/no-extraneous-dependencies': [ 'off' ],
|
|
124
|
-
'import/consistent-type-specifier-style': [ 'error', 'prefer-top-level' ],
|
|
125
|
-
'import/order': [ 'error', {
|
|
126
|
-
'groups': [ 'builtin', 'external', 'internal', [ 'parent', 'sibling' ], 'index', 'object', 'type' ],
|
|
127
|
-
'newlines-between': 'always',
|
|
128
|
-
'warnOnUnassignedImports': true,
|
|
129
|
-
} ],
|
|
130
|
-
|
|
131
|
-
// Unicorn extras
|
|
132
|
-
'unicorn/empty-brace-spaces': [ 'error' ],
|
|
133
|
-
'unicorn/no-instanceof-array': [ 'error' ],
|
|
134
|
-
'unicorn/prefer-node-protocol': [ 'error' ],
|
|
135
|
-
|
|
136
|
-
// Turn off specific JavaScript rules
|
|
137
|
-
'guard-for-in': [ 'off' ], // no errors on for ... in
|
|
138
|
-
'no-undef': [ 'off' ], // it'll mark global types as undefs
|
|
139
|
-
'no-redeclare': [ 'off' ], // use @typescript/no-redeclare
|
|
140
|
-
'no-unused-vars': [ 'off' ], // use @typescript/no-unused-vars
|
|
141
|
-
'no-dupe-class-members': [ 'off' ], // use @typescript/no-dupe-class-members
|
|
142
|
-
'no-invalid-this': [ 'off' ], // use @typescript/no-invalid-this
|
|
143
|
-
},
|
|
144
|
-
overrides: [ {
|
|
145
|
-
files: [ '*.js', '*.cjs', '*.mjs' ],
|
|
146
|
-
parser: 'espree',
|
|
147
|
-
env: {
|
|
148
|
-
node: true,
|
|
149
|
-
},
|
|
150
|
-
rules: {
|
|
151
|
-
'strict': [ 'error', 'global' ],
|
|
152
|
-
|
|
153
|
-
// JavaScript sanity
|
|
154
|
-
'no-undef': [ 'error' ],
|
|
155
|
-
'no-redeclare': [ 'error' ],
|
|
156
|
-
'no-unused-vars': [ 'error' ],
|
|
157
|
-
'no-dupe-class-members': [ 'error' ],
|
|
158
|
-
'no-invalid-this': [ 'error' ],
|
|
159
|
-
|
|
160
|
-
// Turn off specific TypeScript rules
|
|
161
|
-
'@typescript-eslint/consistent-type-imports': [ 'off' ],
|
|
162
|
-
'@typescript-eslint/explicit-function-return-type': [ 'off' ],
|
|
163
|
-
'@typescript-eslint/indent': [ 'off' ],
|
|
164
|
-
'@typescript-eslint/no-dupe-class-members': [ 'off' ],
|
|
165
|
-
'@typescript-eslint/no-floating-promises': [ 'off' ],
|
|
166
|
-
'@typescript-eslint/no-invalid-this': [ 'off' ],
|
|
167
|
-
'@typescript-eslint/no-unused-vars': [ 'off' ],
|
|
168
|
-
'@typescript-eslint/space-before-function-paren': [ 'off' ],
|
|
169
|
-
},
|
|
170
|
-
}, {
|
|
171
|
-
files: [ 'src/**' ],
|
|
172
|
-
rules: {
|
|
173
|
-
// Turn _ON_ dependencies checks only for sources
|
|
174
|
-
'import/no-extraneous-dependencies': [ 'error', {
|
|
175
|
-
'devDependencies': true,
|
|
176
|
-
'peerDependencies': true,
|
|
177
|
-
'optionalDependencies': true,
|
|
178
|
-
'bundledDependencies': false,
|
|
179
|
-
} ],
|
|
180
|
-
},
|
|
181
|
-
}, {
|
|
182
|
-
files: [ '*.cjs' ],
|
|
183
|
-
parserOptions: {
|
|
184
|
-
'sourceType': 'script',
|
|
185
|
-
},
|
|
186
|
-
}, {
|
|
187
|
-
files: [ '*.mjs' ],
|
|
188
|
-
parserOptions: {
|
|
189
|
-
'sourceType': 'module',
|
|
190
|
-
},
|
|
191
|
-
} ],
|
|
192
|
-
}
|