@averay/codeformat 0.1.5 → 0.1.7
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/eslint.config.js +2 -63
- package/index.js +60 -4
- package/package.json +2 -1
- package/rulesets/ruleset-shared.js +12 -4
- package/rulesets/ruleset-typescript.js +37 -1
package/eslint.config.js
CHANGED
|
@@ -1,64 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import typescriptParser from '@typescript-eslint/parser';
|
|
3
|
-
import prettierConfig from 'eslint-config-prettier';
|
|
4
|
-
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
|
|
5
|
-
import importPlugin from 'eslint-plugin-import';
|
|
6
|
-
import promisePlugin from 'eslint-plugin-promise';
|
|
7
|
-
import regexpPlugin from 'eslint-plugin-regexp';
|
|
8
|
-
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
9
|
-
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
1
|
+
import { makeEslintConfig } from './index.js';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
import rulesetShared from './rulesets/ruleset-shared.js';
|
|
13
|
-
import rulesetTypescript from './rulesets/ruleset-typescript.js';
|
|
14
|
-
|
|
15
|
-
export const extensions = {
|
|
16
|
-
js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
|
|
17
|
-
ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default [
|
|
21
|
-
// JavaScript & TypeScript
|
|
22
|
-
{
|
|
23
|
-
files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
|
|
24
|
-
plugins: {
|
|
25
|
-
'eslint-comments': eslintCommentsPlugin,
|
|
26
|
-
import: importPlugin,
|
|
27
|
-
promise: promisePlugin,
|
|
28
|
-
regexp: regexpPlugin,
|
|
29
|
-
sonarjs: sonarjsPlugin,
|
|
30
|
-
unicorn: unicornPlugin,
|
|
31
|
-
},
|
|
32
|
-
languageOptions: {
|
|
33
|
-
parserOptions: {
|
|
34
|
-
...importPlugin.configs.recommended.parserOptions,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
settings: {
|
|
38
|
-
'import/parsers': {
|
|
39
|
-
espree: extensions.js.map((extension) => `.${extension}`),
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
rules: convertWarnsToErrors(rulesetShared),
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
// TypeScript
|
|
46
|
-
{
|
|
47
|
-
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
48
|
-
languageOptions: {
|
|
49
|
-
parser: typescriptParser,
|
|
50
|
-
},
|
|
51
|
-
plugins: {
|
|
52
|
-
'@typescript-eslint': typescriptPlugin,
|
|
53
|
-
},
|
|
54
|
-
settings: {
|
|
55
|
-
...importPlugin.configs.typescript.settings,
|
|
56
|
-
'import/parsers': {
|
|
57
|
-
'@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
rules: convertWarnsToErrors(rulesetTypescript),
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
prettierConfig,
|
|
64
|
-
];
|
|
3
|
+
export default makeEslintConfig();
|
package/index.js
CHANGED
|
@@ -1,15 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint sort-keys: "error" -- Organise rules */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
4
|
+
import typescriptParser from '@typescript-eslint/parser';
|
|
5
|
+
import prettierConfig from 'eslint-config-prettier';
|
|
6
|
+
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
|
|
7
|
+
import importPlugin from 'eslint-plugin-import';
|
|
8
|
+
import promisePlugin from 'eslint-plugin-promise';
|
|
9
|
+
import regexpPlugin from 'eslint-plugin-regexp';
|
|
10
|
+
import sonarjsPlugin from 'eslint-plugin-sonarjs';
|
|
11
|
+
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
import convertWarnsToErrors from './lib/convertWarnsToErrors.js';
|
|
14
|
+
import rulesetShared from './rulesets/ruleset-shared.js';
|
|
15
|
+
import rulesetTypescript from './rulesets/ruleset-typescript.js';
|
|
16
|
+
|
|
17
|
+
export { default as globals } from 'globals';
|
|
18
|
+
|
|
19
|
+
export const extensions = {
|
|
20
|
+
js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
|
|
21
|
+
ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function makeEslintConfig(options = {}) {
|
|
6
25
|
return [
|
|
7
|
-
|
|
26
|
+
// JavaScript & TypeScript
|
|
27
|
+
{
|
|
28
|
+
files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parserOptions: {
|
|
31
|
+
...importPlugin.configs.recommended.parserOptions,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
plugins: {
|
|
35
|
+
'eslint-comments': eslintCommentsPlugin,
|
|
36
|
+
import: importPlugin,
|
|
37
|
+
promise: promisePlugin,
|
|
38
|
+
regexp: regexpPlugin,
|
|
39
|
+
sonarjs: sonarjsPlugin,
|
|
40
|
+
unicorn: unicornPlugin,
|
|
41
|
+
},
|
|
42
|
+
rules: convertWarnsToErrors(rulesetShared),
|
|
43
|
+
settings: {
|
|
44
|
+
'import/parsers': {
|
|
45
|
+
espree: extensions.js.map((extension) => `.${extension}`),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// TypeScript
|
|
8
51
|
{
|
|
9
52
|
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
10
53
|
languageOptions: {
|
|
54
|
+
parser: typescriptParser,
|
|
11
55
|
parserOptions: { project: options.tsconfigPath },
|
|
12
56
|
},
|
|
57
|
+
plugins: {
|
|
58
|
+
'@typescript-eslint': typescriptPlugin,
|
|
59
|
+
},
|
|
60
|
+
rules: convertWarnsToErrors(rulesetTypescript),
|
|
61
|
+
settings: {
|
|
62
|
+
...importPlugin.configs.typescript.settings,
|
|
63
|
+
'import/parsers': {
|
|
64
|
+
'@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
13
67
|
},
|
|
68
|
+
|
|
69
|
+
prettierConfig,
|
|
14
70
|
];
|
|
15
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@averay/codeformat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"author": "Adam Averay (https://adamaveray.com.au/)",
|
|
5
5
|
"homepage": "https://github.com/adamaveray/codeformat",
|
|
6
6
|
"repository": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"eslint-plugin-regexp": "^1.12.0",
|
|
44
44
|
"eslint-plugin-sonarjs": "^0.18.0",
|
|
45
45
|
"eslint-plugin-unicorn": "^46.0.0",
|
|
46
|
+
"globals": "^13.20.0",
|
|
46
47
|
"prettier": "^2.8.4"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
@@ -29,7 +29,7 @@ export default {
|
|
|
29
29
|
'global-require': 'error',
|
|
30
30
|
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
|
|
31
31
|
'guard-for-in': 'error',
|
|
32
|
-
'id-denylist': ['error', 'e', '
|
|
32
|
+
'id-denylist': ['error', 'cb', 'e', 'enc', 'err', 'evt'],
|
|
33
33
|
'lines-between-class-members': 'error',
|
|
34
34
|
'logical-assignment-operators': ['error', 'always'],
|
|
35
35
|
'max-classes-per-file': ['error', 1],
|
|
@@ -165,7 +165,14 @@ export default {
|
|
|
165
165
|
'no-unused-expressions': 'error',
|
|
166
166
|
'no-unused-labels': 'error',
|
|
167
167
|
'no-unused-private-class-members': 'error',
|
|
168
|
-
'no-unused-vars':
|
|
168
|
+
'no-unused-vars': [
|
|
169
|
+
'error',
|
|
170
|
+
{
|
|
171
|
+
argsIgnorePattern: '^_\\w*$',
|
|
172
|
+
caughtErrorsIgnorePattern: '^_\\w*$',
|
|
173
|
+
varsIgnorePattern: '^(_\\d*|React)$',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
169
176
|
'no-use-before-define': 'error',
|
|
170
177
|
'no-useless-backreference': 'error',
|
|
171
178
|
'no-useless-call': 'error',
|
|
@@ -238,7 +245,7 @@ export default {
|
|
|
238
245
|
'import/no-self-import': 'error',
|
|
239
246
|
'import/no-unresolved': ['error', { caseSensitiveStrict: true }],
|
|
240
247
|
'import/no-unused-modules': 'error',
|
|
241
|
-
'import/no-useless-path-segments':
|
|
248
|
+
'import/no-useless-path-segments': 'error',
|
|
242
249
|
'import/no-webpack-loader-syntax': 'error',
|
|
243
250
|
'import/order': [
|
|
244
251
|
'error',
|
|
@@ -250,7 +257,6 @@ export default {
|
|
|
250
257
|
},
|
|
251
258
|
],
|
|
252
259
|
'import/prefer-default-export': 'error',
|
|
253
|
-
'import/unambiguous': 'error',
|
|
254
260
|
|
|
255
261
|
...promisePlugin.configs.recommended.rules,
|
|
256
262
|
'promise/no-multiple-resolved': 'error',
|
|
@@ -284,7 +290,9 @@ export default {
|
|
|
284
290
|
|
|
285
291
|
...unicornPlugin.configs.recommended.rules,
|
|
286
292
|
'unicorn/filename-case': 'off',
|
|
293
|
+
'unicorn/no-null': 'off',
|
|
287
294
|
'unicorn/no-unsafe-regex': 'error',
|
|
288
295
|
'unicorn/prefer-event-target': 'error',
|
|
296
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
289
297
|
'unicorn/require-post-message-target-origin': 'error',
|
|
290
298
|
};
|
|
@@ -12,6 +12,31 @@ export default {
|
|
|
12
12
|
...typescriptPlugin.configs['recommended-requiring-type-checking'].rules,
|
|
13
13
|
...typescriptPlugin.configs.strict.rules,
|
|
14
14
|
|
|
15
|
+
// eslint-disable-next-line unicorn/no-useless-spread -- Keeps the unprefixed core rules together
|
|
16
|
+
...{
|
|
17
|
+
'default-param-last': 'off',
|
|
18
|
+
'dot-notation': 'off',
|
|
19
|
+
'lines-between-class-members': 'off',
|
|
20
|
+
'no-array-constructor': 'off',
|
|
21
|
+
'no-dupe-class-members': 'off',
|
|
22
|
+
'no-empty-function': 'off',
|
|
23
|
+
'no-implied-eval': 'off',
|
|
24
|
+
'no-invalid-this': 'off',
|
|
25
|
+
'no-loop-func': 'off',
|
|
26
|
+
'no-loss-of-precision': 'off',
|
|
27
|
+
'no-magic-numbers': 'off',
|
|
28
|
+
'no-redeclare': 'off',
|
|
29
|
+
'no-restricted-imports': 'off',
|
|
30
|
+
'no-return-await': 'off',
|
|
31
|
+
'no-shadow': 'off',
|
|
32
|
+
'no-throw-literal': 'off',
|
|
33
|
+
'no-unused-expressions': 'off',
|
|
34
|
+
'no-unused-vars': 'off',
|
|
35
|
+
'no-use-before-define': 'off',
|
|
36
|
+
'no-useless-constructor': 'off',
|
|
37
|
+
'padding-line-between-statements': 'off',
|
|
38
|
+
},
|
|
39
|
+
|
|
15
40
|
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
16
41
|
'@typescript-eslint/array-type': 'error',
|
|
17
42
|
'@typescript-eslint/await-thenable': 'error',
|
|
@@ -112,6 +137,17 @@ export default {
|
|
|
112
137
|
'@typescript-eslint/no-invalid-void-type': 'error',
|
|
113
138
|
'@typescript-eslint/no-loop-func': 'error',
|
|
114
139
|
'@typescript-eslint/no-loss-of-precision': 'error',
|
|
140
|
+
'@typescript-eslint/no-magic-numbers': [
|
|
141
|
+
'error',
|
|
142
|
+
{
|
|
143
|
+
detectObjects: true,
|
|
144
|
+
enforceConst: true,
|
|
145
|
+
ignore: [-1, 0, 1],
|
|
146
|
+
ignoreArrayIndexes: true,
|
|
147
|
+
ignoreClassFieldInitialValues: true,
|
|
148
|
+
ignoreDefaultValues: true,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
115
151
|
'@typescript-eslint/no-meaningless-void-operator': 'error',
|
|
116
152
|
'@typescript-eslint/no-misused-new': 'error',
|
|
117
153
|
'@typescript-eslint/no-misused-promises': 'error',
|
|
@@ -122,7 +158,7 @@ export default {
|
|
|
122
158
|
'@typescript-eslint/no-redeclare': 'error',
|
|
123
159
|
'@typescript-eslint/no-require-imports': 'error',
|
|
124
160
|
'@typescript-eslint/no-restricted-imports': 'error',
|
|
125
|
-
'@typescript-eslint/no-shadow': 'error',
|
|
161
|
+
'@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
|
|
126
162
|
'@typescript-eslint/no-this-alias': 'error',
|
|
127
163
|
'@typescript-eslint/no-throw-literal': 'error',
|
|
128
164
|
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|