@averay/codeformat 0.1.5 → 0.1.6
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 +58 -4
- package/package.json +2 -1
- package/rulesets/ruleset-shared.js +3 -2
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,69 @@
|
|
|
1
|
-
import
|
|
1
|
+
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
|
|
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';
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
import convertWarnsToErrors from './lib/convertWarnsToErrors.js';
|
|
12
|
+
import rulesetShared from './rulesets/ruleset-shared.js';
|
|
13
|
+
import rulesetTypescript from './rulesets/ruleset-typescript.js';
|
|
4
14
|
|
|
5
|
-
export
|
|
15
|
+
export { default as globals } from 'globals';
|
|
16
|
+
|
|
17
|
+
export const extensions = {
|
|
18
|
+
js: ['js', 'jsx', 'cjs', 'cjs', 'mjs', 'mjsx'],
|
|
19
|
+
ts: ['ts', 'tsx', 'cts', 'cts', 'mts', 'mtsx'],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function makeEslintConfig(options = {}) {
|
|
6
23
|
return [
|
|
7
|
-
|
|
24
|
+
// JavaScript & TypeScript
|
|
25
|
+
{
|
|
26
|
+
files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
|
|
27
|
+
plugins: {
|
|
28
|
+
'eslint-comments': eslintCommentsPlugin,
|
|
29
|
+
import: importPlugin,
|
|
30
|
+
promise: promisePlugin,
|
|
31
|
+
regexp: regexpPlugin,
|
|
32
|
+
sonarjs: sonarjsPlugin,
|
|
33
|
+
unicorn: unicornPlugin,
|
|
34
|
+
},
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
...importPlugin.configs.recommended.parserOptions,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
settings: {
|
|
41
|
+
'import/parsers': {
|
|
42
|
+
espree: extensions.js.map((extension) => `.${extension}`),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
rules: convertWarnsToErrors(rulesetShared),
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// TypeScript
|
|
8
49
|
{
|
|
9
50
|
files: [`**/*.{${extensions.ts.join(',')}}`],
|
|
10
51
|
languageOptions: {
|
|
52
|
+
parser: typescriptParser,
|
|
11
53
|
parserOptions: { project: options.tsconfigPath },
|
|
12
54
|
},
|
|
55
|
+
plugins: {
|
|
56
|
+
'@typescript-eslint': typescriptPlugin,
|
|
57
|
+
},
|
|
58
|
+
settings: {
|
|
59
|
+
...importPlugin.configs.typescript.settings,
|
|
60
|
+
'import/parsers': {
|
|
61
|
+
'@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
rules: convertWarnsToErrors(rulesetTypescript),
|
|
13
65
|
},
|
|
66
|
+
|
|
67
|
+
prettierConfig,
|
|
14
68
|
];
|
|
15
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@averay/codeformat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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": {
|
|
@@ -238,7 +238,7 @@ export default {
|
|
|
238
238
|
'import/no-self-import': 'error',
|
|
239
239
|
'import/no-unresolved': ['error', { caseSensitiveStrict: true }],
|
|
240
240
|
'import/no-unused-modules': 'error',
|
|
241
|
-
'import/no-useless-path-segments':
|
|
241
|
+
'import/no-useless-path-segments': 'error',
|
|
242
242
|
'import/no-webpack-loader-syntax': 'error',
|
|
243
243
|
'import/order': [
|
|
244
244
|
'error',
|
|
@@ -250,7 +250,6 @@ export default {
|
|
|
250
250
|
},
|
|
251
251
|
],
|
|
252
252
|
'import/prefer-default-export': 'error',
|
|
253
|
-
'import/unambiguous': 'error',
|
|
254
253
|
|
|
255
254
|
...promisePlugin.configs.recommended.rules,
|
|
256
255
|
'promise/no-multiple-resolved': 'error',
|
|
@@ -284,7 +283,9 @@ export default {
|
|
|
284
283
|
|
|
285
284
|
...unicornPlugin.configs.recommended.rules,
|
|
286
285
|
'unicorn/filename-case': 'off',
|
|
286
|
+
'unicorn/no-null': 'off',
|
|
287
287
|
'unicorn/no-unsafe-regex': 'error',
|
|
288
288
|
'unicorn/prefer-event-target': 'error',
|
|
289
|
+
'unicorn/prevent-abbreviations': 'off',
|
|
289
290
|
'unicorn/require-post-message-target-origin': 'error',
|
|
290
291
|
};
|