@w5s/eslint-config 1.1.1 → 1.2.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/dist/es.js +4 -9
- package/dist/index.js +24 -0
- package/dist/jest.js +16 -54
- package/dist/json.js +14 -0
- package/dist/{es → rules/es}/base.js +2 -2
- package/dist/rules/es.js +15 -0
- package/dist/{ignore.js → rules/ignore.js} +3 -0
- package/dist/rules/jest.d.ts +3 -0
- package/dist/rules/jest.js +58 -0
- package/dist/rules/jsonc.d.ts +3 -0
- package/dist/rules/prettier.d.ts +3 -0
- package/dist/rules/prettier.js +13 -0
- package/dist/rules/typescript.d.ts +3 -0
- package/dist/{typescript.js → rules/typescript.js} +0 -1
- package/dist/rules/yml.d.ts +3 -0
- package/dist/rules/yml.js +7 -0
- package/dist/ts.d.ts +3 -0
- package/dist/ts.js +17 -0
- package/dist/yml.js +10 -3
- package/package.json +18 -21
- package/src/es.ts +6 -12
- package/src/index.ts +31 -0
- package/src/jest.ts +14 -58
- package/src/json.ts +12 -0
- package/src/{es → rules/es}/base.ts +3 -3
- package/src/rules/es.ts +18 -0
- package/src/{ignore.ts → rules/ignore.ts} +3 -0
- package/src/rules/jest.ts +62 -0
- package/src/rules/prettier.ts +11 -0
- package/src/{typescript.ts → rules/typescript.ts} +0 -1
- package/src/rules/yml.ts +8 -0
- package/src/ts.ts +19 -0
- package/src/yml.ts +7 -3
- package/dist/prettier.js +0 -43
- package/es.js +0 -4
- package/ignore.js +0 -1
- package/index.js +0 -33
- package/jest.js +0 -17
- package/json.js +0 -10
- package/src/prettier.ts +0 -47
- package/ts.js +0 -15
- package/yml.js +0 -9
- /package/dist/{es/import.d.ts → index.d.ts} +0 -0
- /package/dist/{es/jsdoc.d.ts → json.d.ts} +0 -0
- /package/dist/{es → rules/es}/base.d.ts +0 -0
- /package/dist/{es/unicorn.d.ts → rules/es/import.d.ts} +0 -0
- /package/dist/{es → rules/es}/import.js +0 -0
- /package/dist/{ignore.d.ts → rules/es/jsdoc.d.ts} +0 -0
- /package/dist/{es → rules/es}/jsdoc.js +0 -0
- /package/dist/{jsonc.d.ts → rules/es/promise.d.ts} +0 -0
- /package/dist/{es → rules/es}/promise.js +0 -0
- /package/dist/{prettier.d.ts → rules/es/unicorn.d.ts} +0 -0
- /package/dist/{es → rules/es}/unicorn.js +0 -0
- /package/dist/{es/promise.d.ts → rules/es.d.ts} +0 -0
- /package/dist/{typescript.d.ts → rules/ignore.d.ts} +0 -0
- /package/dist/{jsonc.js → rules/jsonc.js} +0 -0
- /package/src/{es → rules/es}/import.ts +0 -0
- /package/src/{es → rules/es}/jsdoc.ts +0 -0
- /package/src/{es → rules/es}/promise.ts +0 -0
- /package/src/{es → rules/es}/unicorn.ts +0 -0
- /package/src/{jsonc.ts → rules/jsonc.ts} +0 -0
package/dist/es.js
CHANGED
|
@@ -3,13 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
const dev_1 = require("@w5s/dev");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const unicorn_js_1 = __importDefault(require("./es/unicorn.js"));
|
|
11
|
-
// import prettierConfig from './prettier.js';
|
|
12
|
-
const config = dev_1.ESLintConfig.concat(base_js_1.default, promise_js_1.default, jsdoc_js_1.default, import_js_1.default, unicorn_js_1.default
|
|
13
|
-
// prettierConfig
|
|
14
|
-
);
|
|
6
|
+
const prettier_js_1 = __importDefault(require("./rules/prettier.js"));
|
|
7
|
+
const config = dev_1.ESLintConfig.concat({
|
|
8
|
+
extends: [require.resolve('./rules/es.js')],
|
|
9
|
+
}, prettier_js_1.default);
|
|
15
10
|
module.exports = config;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const dev_1 = require("@w5s/dev");
|
|
6
|
+
const ignore_js_1 = __importDefault(require("./rules/ignore.js"));
|
|
7
|
+
const es_js_1 = __importDefault(require("./es.js"));
|
|
8
|
+
const ts_js_1 = __importDefault(require("./ts.js"));
|
|
9
|
+
const jest_js_1 = __importDefault(require("./jest.js"));
|
|
10
|
+
const json_js_1 = __importDefault(require("./json.js"));
|
|
11
|
+
const yml_js_1 = __importDefault(require("./yml.js"));
|
|
12
|
+
function tryResolve(name) {
|
|
13
|
+
try {
|
|
14
|
+
require.resolve(name);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const config = dev_1.ESLintConfig.concat(ignore_js_1.default, es_js_1.default, tryResolve('typescript') ? ts_js_1.default : {}, jest_js_1.default, json_js_1.default, yml_js_1.default, {
|
|
22
|
+
root: true,
|
|
23
|
+
});
|
|
24
|
+
module.exports = config;
|
package/dist/jest.js
CHANGED
|
@@ -1,58 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
const dev_1 = require("@w5s/dev");
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'jest/expect-expect': 'off',
|
|
15
|
-
'jest/no-alias-methods': 'error',
|
|
16
|
-
'jest/prefer-spy-on': 'error',
|
|
17
|
-
'jest/prefer-to-contain': 'error',
|
|
18
|
-
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
19
|
-
},
|
|
20
|
-
settings: {
|
|
21
|
-
jest: {
|
|
22
|
-
// Compatibility with mocha, cypress, etc.
|
|
23
|
-
globalAliases: {
|
|
24
|
-
describe: ['context'],
|
|
25
|
-
fdescribe: ['fcontext'],
|
|
26
|
-
xdescribe: ['xcontext'],
|
|
27
|
-
},
|
|
28
|
-
version: 'latest',
|
|
6
|
+
const jest_js_1 = __importDefault(require("./rules/jest.js"));
|
|
7
|
+
const extensions = dev_1.EXTENSIONS_WITHOUT_DOT.join('|');
|
|
8
|
+
const config = {
|
|
9
|
+
overrides: [
|
|
10
|
+
{
|
|
11
|
+
...jest_js_1.default,
|
|
12
|
+
files: [
|
|
13
|
+
`**/__mocks__/**/*.+(${extensions})`,
|
|
14
|
+
`**/__tests__/**/*.+(${extensions})`,
|
|
15
|
+
`**/?(*.)+(spec|test).+(${extensions})`,
|
|
16
|
+
],
|
|
29
17
|
},
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Unicorn less strict to help writing tests
|
|
34
|
-
*/
|
|
35
|
-
{
|
|
36
|
-
rules: {
|
|
37
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
38
|
-
'unicorn/no-useless-undefined': 'off',
|
|
39
|
-
'unicorn/prefer-module': 'off',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
44
|
-
*/
|
|
45
|
-
{
|
|
46
|
-
rules: {
|
|
47
|
-
'@typescript-eslint/dot-notation': dev_1.ESLintConfig.fixme(undefined),
|
|
48
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
49
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
50
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
51
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
52
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
53
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
54
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
55
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
56
|
-
},
|
|
57
|
-
});
|
|
18
|
+
],
|
|
19
|
+
};
|
|
58
20
|
module.exports = config;
|
package/dist/json.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const jsonc_js_1 = __importDefault(require("./rules/jsonc.js"));
|
|
6
|
+
const config = {
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
...jsonc_js_1.default,
|
|
10
|
+
files: ['*.json', '*.json5', '*.jsonc'],
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
module.exports = config;
|
|
@@ -25,7 +25,7 @@ const config = dev_1.ESLintConfig.concat(baseConfig,
|
|
|
25
25
|
// overrides
|
|
26
26
|
{
|
|
27
27
|
env: {
|
|
28
|
-
[`es${dev_1.
|
|
28
|
+
[`es${dev_1.Project.ecmaVersion()}`]: true,
|
|
29
29
|
},
|
|
30
30
|
globals: {
|
|
31
31
|
__DEV__: 'readonly',
|
|
@@ -37,7 +37,7 @@ const config = dev_1.ESLintConfig.concat(baseConfig,
|
|
|
37
37
|
ecmaFeatures: {
|
|
38
38
|
jsx: true,
|
|
39
39
|
},
|
|
40
|
-
ecmaVersion: dev_1.
|
|
40
|
+
ecmaVersion: dev_1.Project.ecmaVersion(),
|
|
41
41
|
sourceType: 'module',
|
|
42
42
|
},
|
|
43
43
|
reportUnusedDisableDirectives: true,
|
package/dist/rules/es.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const dev_1 = require("@w5s/dev");
|
|
6
|
+
const base_js_1 = __importDefault(require("./es/base.js"));
|
|
7
|
+
const promise_js_1 = __importDefault(require("./es/promise.js"));
|
|
8
|
+
const jsdoc_js_1 = __importDefault(require("./es/jsdoc.js"));
|
|
9
|
+
const import_js_1 = __importDefault(require("./es/import.js"));
|
|
10
|
+
const unicorn_js_1 = __importDefault(require("./es/unicorn.js"));
|
|
11
|
+
// import prettierConfig from './prettier.js';
|
|
12
|
+
const config = dev_1.ESLintConfig.concat(base_js_1.default, promise_js_1.default, jsdoc_js_1.default, import_js_1.default, unicorn_js_1.default
|
|
13
|
+
// prettierConfig
|
|
14
|
+
);
|
|
15
|
+
module.exports = config;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const dev_1 = require("@w5s/dev");
|
|
3
|
+
const config = dev_1.ESLintConfig.concat({
|
|
4
|
+
env: {
|
|
5
|
+
'jest/globals': true,
|
|
6
|
+
},
|
|
7
|
+
extends: ['plugin:jest/recommended'],
|
|
8
|
+
globals: {
|
|
9
|
+
context: true,
|
|
10
|
+
},
|
|
11
|
+
plugins: ['jest'],
|
|
12
|
+
rules: {
|
|
13
|
+
'jest/consistent-test-it': 'error',
|
|
14
|
+
'jest/expect-expect': 'off',
|
|
15
|
+
'jest/no-alias-methods': 'error',
|
|
16
|
+
'jest/prefer-spy-on': 'error',
|
|
17
|
+
'jest/prefer-to-contain': 'error',
|
|
18
|
+
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
19
|
+
},
|
|
20
|
+
settings: {
|
|
21
|
+
jest: {
|
|
22
|
+
// Compatibility with mocha, cypress, etc.
|
|
23
|
+
globalAliases: {
|
|
24
|
+
describe: ['context'],
|
|
25
|
+
fdescribe: ['fcontext'],
|
|
26
|
+
xdescribe: ['xcontext'],
|
|
27
|
+
},
|
|
28
|
+
version: 'latest',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Unicorn less strict to help writing tests
|
|
34
|
+
*/
|
|
35
|
+
{
|
|
36
|
+
rules: {
|
|
37
|
+
'unicorn/consistent-function-scoping': 'off',
|
|
38
|
+
'unicorn/no-useless-undefined': 'off',
|
|
39
|
+
'unicorn/prefer-module': 'off',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
44
|
+
*/
|
|
45
|
+
{
|
|
46
|
+
rules: {
|
|
47
|
+
'@typescript-eslint/dot-notation': dev_1.ESLintConfig.fixme(undefined),
|
|
48
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
49
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
50
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
51
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
52
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
53
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
54
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
55
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
module.exports = config;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const prettier_config_1 = __importDefault(require("@w5s/prettier-config"));
|
|
6
|
+
const config = {
|
|
7
|
+
extends: ['prettier'],
|
|
8
|
+
plugins: ['prettier'],
|
|
9
|
+
rules: {
|
|
10
|
+
'prettier/prettier': ['error', prettier_config_1.default],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
module.exports = config;
|
|
@@ -92,7 +92,6 @@ const config = dev_1.ESLintConfig.concat(
|
|
|
92
92
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
93
93
|
'@typescript-eslint/no-extra-parens': baseRules['no-extra-parens'],
|
|
94
94
|
'@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'],
|
|
95
|
-
'@typescript-eslint/no-implicit-any-catch': 'error',
|
|
96
95
|
'@typescript-eslint/no-inferrable-types': 'error',
|
|
97
96
|
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
|
|
98
97
|
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
|
package/dist/ts.d.ts
ADDED
package/dist/ts.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const dev_1 = require("@w5s/dev");
|
|
6
|
+
const prettier_js_1 = __importDefault(require("./rules/prettier.js"));
|
|
7
|
+
const config = {
|
|
8
|
+
overrides: [
|
|
9
|
+
{
|
|
10
|
+
...dev_1.ESLintConfig.concat({
|
|
11
|
+
extends: [require.resolve('./rules/typescript.js')],
|
|
12
|
+
}, prettier_js_1.default),
|
|
13
|
+
files: [`*.+(${dev_1.EXTENSIONS_WITHOUT_DOT.filter((_) => _.includes('ts')).join('|')})`],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
module.exports = config;
|
package/dist/yml.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const yml_js_1 = __importDefault(require("./rules/yml.js"));
|
|
2
6
|
const config = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
...yml_js_1.default,
|
|
10
|
+
files: ['*.yml', '*.yaml'],
|
|
11
|
+
},
|
|
12
|
+
],
|
|
6
13
|
};
|
|
7
14
|
module.exports = config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "ESLint configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "Julien Polo <julien.polo@gmail.com>",
|
|
21
21
|
"type": "commonjs",
|
|
22
|
-
"main": "index.js",
|
|
22
|
+
"main": "dist/index.js",
|
|
23
23
|
"files": [
|
|
24
24
|
"dist/",
|
|
25
25
|
"src/",
|
|
26
|
-
"*.js",
|
|
27
26
|
"index.js",
|
|
28
27
|
"index.d.ts",
|
|
29
28
|
"!**/*.spec.*",
|
|
@@ -48,41 +47,39 @@
|
|
|
48
47
|
},
|
|
49
48
|
"dependencies": {
|
|
50
49
|
"@rushstack/eslint-patch": "^1.1.0",
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
52
|
-
"@typescript-eslint/parser": "^
|
|
53
|
-
"@w5s/dev": "^1.
|
|
54
|
-
"@w5s/prettier-config": "^1.1.
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
51
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
52
|
+
"@w5s/dev": "^1.2.0",
|
|
53
|
+
"@w5s/prettier-config": "^1.1.2",
|
|
55
54
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
56
55
|
"eslint-config-prettier": "^8.0.0",
|
|
57
56
|
"eslint-plugin-import": "^2.25.0",
|
|
58
57
|
"eslint-plugin-jest": "^27.0.0",
|
|
59
58
|
"eslint-plugin-jsdoc": "^46.0.0",
|
|
60
59
|
"eslint-plugin-jsonc": "^2.4.0",
|
|
61
|
-
"eslint-plugin-prettier": "^
|
|
60
|
+
"eslint-plugin-prettier": "^5.0.0-alpha.0",
|
|
62
61
|
"eslint-plugin-promise": "^6.0.0",
|
|
63
|
-
"eslint-plugin-unicorn": "^
|
|
62
|
+
"eslint-plugin-unicorn": "^48.0.0",
|
|
64
63
|
"eslint-plugin-yml": "^1.1.0",
|
|
65
64
|
"find-up": "^5.0.0",
|
|
66
65
|
"parse-gitignore": "^2.0.0"
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
|
-
"@types/eslint": "8.
|
|
70
|
-
"@types/eslint-plugin-prettier": "3.1.0",
|
|
68
|
+
"@types/eslint": "8.44.1",
|
|
71
69
|
"@types/parse-gitignore": "1.0.0",
|
|
72
|
-
"@types/
|
|
73
|
-
"@
|
|
74
|
-
"
|
|
75
|
-
"eslint": "8.
|
|
76
|
-
"eslint-config-prettier": "8.8.0",
|
|
70
|
+
"@types/react": "18.2.17",
|
|
71
|
+
"@typescript-eslint/parser": "6.2.0",
|
|
72
|
+
"eslint": "8.45.0",
|
|
73
|
+
"eslint-config-prettier": "8.9.0",
|
|
77
74
|
"eslint-find-rules": "4.1.0",
|
|
78
|
-
"prettier": "
|
|
75
|
+
"prettier": "3.0.0",
|
|
79
76
|
"react": "18.2.0",
|
|
80
|
-
"vite": "4.
|
|
81
|
-
"vitest": "0.
|
|
77
|
+
"vite": "4.4.7",
|
|
78
|
+
"vitest": "0.33.0"
|
|
82
79
|
},
|
|
83
80
|
"peerDependencies": {
|
|
84
81
|
"eslint": "8.x",
|
|
85
|
-
"prettier": "2.x",
|
|
82
|
+
"prettier": "2.x || 3.x",
|
|
86
83
|
"typescript": "4.x || 5.x"
|
|
87
84
|
},
|
|
88
85
|
"peerDependenciesMeta": {
|
|
@@ -99,5 +96,5 @@
|
|
|
99
96
|
"publishConfig": {
|
|
100
97
|
"access": "public"
|
|
101
98
|
},
|
|
102
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "d3b4d1bae7d8b5b8f066ac5fc8ac196d282396bf"
|
|
103
100
|
}
|
package/src/es.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type eslint from 'eslint';
|
|
2
2
|
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
-
import
|
|
4
|
-
import promiseConfig from './es/promise.js';
|
|
5
|
-
import jsdocConfig from './es/jsdoc.js';
|
|
6
|
-
import importConfig from './es/import.js';
|
|
7
|
-
import unicornConfig from './es/unicorn.js';
|
|
8
|
-
// import prettierConfig from './prettier.js';
|
|
3
|
+
import prettierConfig from './rules/prettier.js';
|
|
9
4
|
|
|
10
5
|
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
unicornConfig
|
|
16
|
-
// prettierConfig
|
|
6
|
+
{
|
|
7
|
+
extends: [require.resolve('./rules/es.js')],
|
|
8
|
+
},
|
|
9
|
+
prettierConfig
|
|
17
10
|
);
|
|
11
|
+
|
|
18
12
|
export = config;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type eslint from 'eslint';
|
|
2
|
+
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
+
import ignoreConfig from './rules/ignore.js';
|
|
4
|
+
import esConfig from './es.js';
|
|
5
|
+
import tsConfig from './ts.js';
|
|
6
|
+
import jestConfig from './jest.js';
|
|
7
|
+
import jsonConfig from './json.js';
|
|
8
|
+
import ymlConfig from './yml.js';
|
|
9
|
+
|
|
10
|
+
function tryResolve(name: string) {
|
|
11
|
+
try {
|
|
12
|
+
require.resolve(name);
|
|
13
|
+
return true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
20
|
+
ignoreConfig,
|
|
21
|
+
esConfig,
|
|
22
|
+
tryResolve('typescript') ? tsConfig : {},
|
|
23
|
+
jestConfig,
|
|
24
|
+
jsonConfig,
|
|
25
|
+
ymlConfig,
|
|
26
|
+
{
|
|
27
|
+
root: true,
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export = config;
|
package/src/jest.ts
CHANGED
|
@@ -1,62 +1,18 @@
|
|
|
1
|
-
import { ESLintConfig } from '@w5s/dev';
|
|
2
1
|
import type eslint from 'eslint';
|
|
2
|
+
import { EXTENSIONS_WITHOUT_DOT } from '@w5s/dev';
|
|
3
|
+
import jestConfig from './rules/jest.js';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const extensions = EXTENSIONS_WITHOUT_DOT.join('|');
|
|
6
|
+
const config: eslint.Linter.Config = {
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
...jestConfig,
|
|
10
|
+
files: [
|
|
11
|
+
`**/__mocks__/**/*.+(${extensions})`,
|
|
12
|
+
`**/__tests__/**/*.+(${extensions})`,
|
|
13
|
+
`**/?(*.)+(spec|test).+(${extensions})`,
|
|
14
|
+
],
|
|
8
15
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
context: true,
|
|
12
|
-
},
|
|
13
|
-
plugins: ['jest'],
|
|
14
|
-
rules: {
|
|
15
|
-
'jest/consistent-test-it': 'error',
|
|
16
|
-
'jest/expect-expect': 'off', // Disabled because it does not handle functions that does the expect
|
|
17
|
-
'jest/no-alias-methods': 'error',
|
|
18
|
-
'jest/prefer-spy-on': 'error',
|
|
19
|
-
'jest/prefer-to-contain': 'error',
|
|
20
|
-
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
21
|
-
},
|
|
22
|
-
settings: {
|
|
23
|
-
jest: {
|
|
24
|
-
// Compatibility with mocha, cypress, etc.
|
|
25
|
-
globalAliases: {
|
|
26
|
-
describe: ['context'],
|
|
27
|
-
fdescribe: ['fcontext'],
|
|
28
|
-
xdescribe: ['xcontext'],
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
version: 'latest',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Unicorn less strict to help writing tests
|
|
37
|
-
*/
|
|
38
|
-
{
|
|
39
|
-
rules: {
|
|
40
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
41
|
-
'unicorn/no-useless-undefined': 'off',
|
|
42
|
-
'unicorn/prefer-module': 'off',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
47
|
-
*/
|
|
48
|
-
{
|
|
49
|
-
rules: {
|
|
50
|
-
'@typescript-eslint/dot-notation': ESLintConfig.fixme(undefined), // eslint-plugin-jest seems to break this rule
|
|
51
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
52
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
53
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
54
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
55
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
56
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
57
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
58
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
);
|
|
16
|
+
],
|
|
17
|
+
};
|
|
62
18
|
export = config;
|
package/src/json.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type eslint from 'eslint';
|
|
2
|
-
import {
|
|
2
|
+
import { Project, ESLintConfig } from '@w5s/dev';
|
|
3
3
|
|
|
4
4
|
// Fix eslint shareable config (https://github.com/eslint/eslint/issues/3458)
|
|
5
5
|
// @ts-ignore No typing available
|
|
@@ -34,7 +34,7 @@ const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
|
34
34
|
// overrides
|
|
35
35
|
{
|
|
36
36
|
env: {
|
|
37
|
-
[`es${
|
|
37
|
+
[`es${Project.ecmaVersion()}`]: true,
|
|
38
38
|
},
|
|
39
39
|
globals: {
|
|
40
40
|
__DEV__: 'readonly',
|
|
@@ -46,7 +46,7 @@ const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
|
46
46
|
ecmaFeatures: {
|
|
47
47
|
jsx: true,
|
|
48
48
|
},
|
|
49
|
-
ecmaVersion:
|
|
49
|
+
ecmaVersion: Project.ecmaVersion(),
|
|
50
50
|
sourceType: 'module',
|
|
51
51
|
},
|
|
52
52
|
reportUnusedDisableDirectives: true,
|
package/src/rules/es.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type eslint from 'eslint';
|
|
2
|
+
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
+
import baseConfig from './es/base.js';
|
|
4
|
+
import promiseConfig from './es/promise.js';
|
|
5
|
+
import jsdocConfig from './es/jsdoc.js';
|
|
6
|
+
import importConfig from './es/import.js';
|
|
7
|
+
import unicornConfig from './es/unicorn.js';
|
|
8
|
+
// import prettierConfig from './prettier.js';
|
|
9
|
+
|
|
10
|
+
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
11
|
+
baseConfig,
|
|
12
|
+
promiseConfig,
|
|
13
|
+
jsdocConfig,
|
|
14
|
+
importConfig,
|
|
15
|
+
unicornConfig
|
|
16
|
+
// prettierConfig
|
|
17
|
+
);
|
|
18
|
+
export = config;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ESLintConfig } from '@w5s/dev';
|
|
2
|
+
import type eslint from 'eslint';
|
|
3
|
+
|
|
4
|
+
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
5
|
+
{
|
|
6
|
+
env: {
|
|
7
|
+
'jest/globals': true,
|
|
8
|
+
},
|
|
9
|
+
extends: ['plugin:jest/recommended'],
|
|
10
|
+
globals: {
|
|
11
|
+
context: true,
|
|
12
|
+
},
|
|
13
|
+
plugins: ['jest'],
|
|
14
|
+
rules: {
|
|
15
|
+
'jest/consistent-test-it': 'error',
|
|
16
|
+
'jest/expect-expect': 'off', // Disabled because it does not handle functions that does the expect
|
|
17
|
+
'jest/no-alias-methods': 'error',
|
|
18
|
+
'jest/prefer-spy-on': 'error',
|
|
19
|
+
'jest/prefer-to-contain': 'error',
|
|
20
|
+
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
21
|
+
},
|
|
22
|
+
settings: {
|
|
23
|
+
jest: {
|
|
24
|
+
// Compatibility with mocha, cypress, etc.
|
|
25
|
+
globalAliases: {
|
|
26
|
+
describe: ['context'],
|
|
27
|
+
fdescribe: ['fcontext'],
|
|
28
|
+
xdescribe: ['xcontext'],
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
version: 'latest',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Unicorn less strict to help writing tests
|
|
37
|
+
*/
|
|
38
|
+
{
|
|
39
|
+
rules: {
|
|
40
|
+
'unicorn/consistent-function-scoping': 'off',
|
|
41
|
+
'unicorn/no-useless-undefined': 'off',
|
|
42
|
+
'unicorn/prefer-module': 'off',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
47
|
+
*/
|
|
48
|
+
{
|
|
49
|
+
rules: {
|
|
50
|
+
'@typescript-eslint/dot-notation': ESLintConfig.fixme(undefined), // eslint-plugin-jest seems to break this rule
|
|
51
|
+
'@typescript-eslint/naming-convention': 'off',
|
|
52
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
53
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
54
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
55
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
56
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
57
|
+
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
58
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
export = config;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type eslint from 'eslint';
|
|
2
|
+
import prettierConfig from '@w5s/prettier-config';
|
|
3
|
+
|
|
4
|
+
const config: eslint.Linter.Config = {
|
|
5
|
+
extends: ['prettier'],
|
|
6
|
+
plugins: ['prettier'],
|
|
7
|
+
rules: {
|
|
8
|
+
'prettier/prettier': ['error', prettierConfig],
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export = config;
|
|
@@ -93,7 +93,6 @@ const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
|
93
93
|
'@typescript-eslint/no-explicit-any': 'off', // if any is explicit then it's wanted
|
|
94
94
|
'@typescript-eslint/no-extra-parens': baseRules['no-extra-parens'],
|
|
95
95
|
'@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'],
|
|
96
|
-
'@typescript-eslint/no-implicit-any-catch': 'error',
|
|
97
96
|
'@typescript-eslint/no-inferrable-types': 'error',
|
|
98
97
|
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
|
|
99
98
|
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
|
package/src/rules/yml.ts
ADDED
package/src/ts.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type eslint from 'eslint';
|
|
2
|
+
import { EXTENSIONS_WITHOUT_DOT, ESLintConfig } from '@w5s/dev';
|
|
3
|
+
import prettierConfig from './rules/prettier.js';
|
|
4
|
+
|
|
5
|
+
const config: eslint.Linter.Config = {
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
...ESLintConfig.concat(
|
|
9
|
+
{
|
|
10
|
+
extends: [require.resolve('./rules/typescript.js')],
|
|
11
|
+
},
|
|
12
|
+
prettierConfig
|
|
13
|
+
),
|
|
14
|
+
files: [`*.+(${EXTENSIONS_WITHOUT_DOT.filter((_) => _.includes('ts')).join('|')})`],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export = config;
|
package/src/yml.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type eslint from 'eslint';
|
|
2
|
+
import ymlConfig from './rules/yml.js';
|
|
2
3
|
|
|
3
4
|
const config: eslint.Linter.Config = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
...ymlConfig,
|
|
8
|
+
files: ['*.yml', '*.yaml'],
|
|
9
|
+
},
|
|
10
|
+
],
|
|
7
11
|
};
|
|
8
12
|
export = config;
|
package/dist/prettier.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable global-require */
|
|
3
|
-
/* eslint-disable import/no-dynamic-require */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
6
|
-
const getPackageScope = () => {
|
|
7
|
-
try {
|
|
8
|
-
const { name } = require('../package.json');
|
|
9
|
-
const prefixMatch = (name ?? '').match(/(@\w+)\//);
|
|
10
|
-
const packageScope = prefixMatch == null ? undefined : prefixMatch[1];
|
|
11
|
-
return packageScope;
|
|
12
|
-
}
|
|
13
|
-
catch (error_) {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.warn(error_);
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const getPrettierConfig = (moduleName) => {
|
|
20
|
-
try {
|
|
21
|
-
const moduleConfig = require(moduleName);
|
|
22
|
-
return moduleConfig;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
// Try require '@my-organization/prettier-config'
|
|
29
|
-
const getPrettierConfigDefault = () => {
|
|
30
|
-
const defaultConfig = {
|
|
31
|
-
trailingComma: 'es5',
|
|
32
|
-
};
|
|
33
|
-
const packageScope = getPackageScope();
|
|
34
|
-
return (packageScope == null ? undefined : getPrettierConfig(`${packageScope}/prettier-config`)) ?? defaultConfig;
|
|
35
|
-
};
|
|
36
|
-
const config = {
|
|
37
|
-
extends: ['prettier'],
|
|
38
|
-
plugins: ['prettier'],
|
|
39
|
-
rules: {
|
|
40
|
-
'prettier/prettier': ['error', getPrettierConfigDefault()],
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
module.exports = config;
|
package/es.js
DELETED
package/ignore.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/ignore.js');
|
package/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// http://eslint.org/docs/user-guide/configuring
|
|
2
|
-
/**
|
|
3
|
-
* @param {string} name
|
|
4
|
-
*/
|
|
5
|
-
function tryResolve(name) {
|
|
6
|
-
try {
|
|
7
|
-
require.resolve(name);
|
|
8
|
-
return true;
|
|
9
|
-
} catch {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @template T
|
|
16
|
-
* @param {boolean} condition
|
|
17
|
-
* @param {() => T} getValue
|
|
18
|
-
*/
|
|
19
|
-
function includeIf(condition, getValue) {
|
|
20
|
-
return condition ? [getValue()] : [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
extends: [
|
|
25
|
-
require.resolve('./ignore.js'),
|
|
26
|
-
require.resolve('./es.js'),
|
|
27
|
-
...includeIf(tryResolve('typescript'), () => require.resolve('./ts.js')),
|
|
28
|
-
require.resolve('./json.js'),
|
|
29
|
-
require.resolve('./yml.js'),
|
|
30
|
-
require.resolve('./jest.js'),
|
|
31
|
-
],
|
|
32
|
-
root: true,
|
|
33
|
-
};
|
package/jest.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-unresolved
|
|
2
|
-
const { EXTENSIONS_WITHOUT_DOT } = require('@w5s/dev');
|
|
3
|
-
|
|
4
|
-
const extensions = EXTENSIONS_WITHOUT_DOT.join('|');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
extends: [require.resolve('./dist/jest.js')],
|
|
10
|
-
files: [
|
|
11
|
-
`**/__mocks__/**/*.+(${extensions})`,
|
|
12
|
-
`**/__tests__/**/*.+(${extensions})`,
|
|
13
|
-
`**/?(*.)+(spec|test).+(${extensions})`,
|
|
14
|
-
],
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
};
|
package/json.js
DELETED
package/src/prettier.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/* eslint-disable global-require */
|
|
2
|
-
/* eslint-disable import/no-dynamic-require */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
5
|
-
|
|
6
|
-
import type eslint from 'eslint';
|
|
7
|
-
import type * as prettier from 'prettier';
|
|
8
|
-
|
|
9
|
-
const getPackageScope = (): string | undefined => {
|
|
10
|
-
try {
|
|
11
|
-
const { name } = require('../package.json') as { name?: string };
|
|
12
|
-
const prefixMatch = (name ?? '').match(/(@\w+)\//);
|
|
13
|
-
const packageScope = prefixMatch == null ? undefined : prefixMatch[1];
|
|
14
|
-
return packageScope;
|
|
15
|
-
} catch (error_: unknown) {
|
|
16
|
-
// eslint-disable-next-line no-console
|
|
17
|
-
console.warn(error_);
|
|
18
|
-
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getPrettierConfig = (moduleName: string): prettier.Config | undefined => {
|
|
23
|
-
try {
|
|
24
|
-
const moduleConfig = require(moduleName);
|
|
25
|
-
return moduleConfig as prettier.Config | undefined;
|
|
26
|
-
} catch {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Try require '@my-organization/prettier-config'
|
|
32
|
-
const getPrettierConfigDefault = () => {
|
|
33
|
-
const defaultConfig: prettier.Config = {
|
|
34
|
-
trailingComma: 'es5',
|
|
35
|
-
};
|
|
36
|
-
const packageScope = getPackageScope();
|
|
37
|
-
return (packageScope == null ? undefined : getPrettierConfig(`${packageScope}/prettier-config`)) ?? defaultConfig;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const config: eslint.Linter.Config = {
|
|
41
|
-
extends: ['prettier'],
|
|
42
|
-
plugins: ['prettier'],
|
|
43
|
-
rules: {
|
|
44
|
-
'prettier/prettier': ['error', getPrettierConfigDefault()],
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
export = config;
|
package/ts.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-unresolved
|
|
2
|
-
const { EXTENSIONS_WITHOUT_DOT } = require('@w5s/dev');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
overrides: [
|
|
6
|
-
{
|
|
7
|
-
extends: [
|
|
8
|
-
// require.resolve('./dist/es.js'),
|
|
9
|
-
require.resolve('./dist/typescript.js'),
|
|
10
|
-
require.resolve('./dist/prettier.js'),
|
|
11
|
-
],
|
|
12
|
-
files: [`*.+(${EXTENSIONS_WITHOUT_DOT.filter((_) => _.includes('ts')).join('|')})`],
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
};
|
package/yml.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|