@fullstacksjs/eslint-config 11.1.18 → 11.1.20
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 +17 -1
- package/cjs/index.js +68 -41
- package/cjs/modules/base.js +2 -2
- package/cjs/modules/cypress.js +1 -1
- package/cjs/modules/ignore.js +17 -0
- package/cjs/modules/imports.js +2 -2
- package/cjs/modules/jest.js +2 -2
- package/cjs/modules/node.js +2 -2
- package/cjs/modules/playwright.js +1 -1
- package/cjs/modules/storybook.js +1 -1
- package/cjs/modules/tests.js +3 -3
- package/cjs/modules/typescript.js +4 -4
- package/cjs/modules/vitest.js +1 -1
- package/cjs/option.d.ts +3 -1
- package/package.json +4 -5
- package/src/index.mjs +112 -0
- package/src/modules/{base.js → base.mjs} +2 -2
- package/src/modules/{cypress.js → cypress.mjs} +1 -1
- package/src/modules/ignore.mjs +12 -0
- package/src/modules/{imports.js → imports.mjs} +2 -2
- package/src/modules/{jest.js → jest.mjs} +2 -2
- package/src/modules/{node.js → node.mjs} +2 -2
- package/src/modules/{playwright.js → playwright.mjs} +1 -1
- package/src/modules/{storybook.js → storybook.mjs} +1 -1
- package/src/modules/{tests.js → tests.mjs} +3 -3
- package/src/modules/{typescript.js → typescript.mjs} +4 -4
- package/src/modules/{vitest.js → vitest.mjs} +1 -1
- package/src/option.d.ts +3 -1
- package/cjs/utils/compose.js +0 -17
- package/src/index.js +0 -84
- package/src/utils/compose.js +0 -12
- /package/src/modules/{functional.js → functional.mjs} +0 -0
- /package/src/modules/{next.js → next.mjs} +0 -0
- /package/src/modules/{perfectionist.js → perfectionist.mjs} +0 -0
- /package/src/modules/{prettier.js → prettier.mjs} +0 -0
- /package/src/modules/{promise.js → promise.mjs} +0 -0
- /package/src/modules/{react.js → react.mjs} +0 -0
- /package/src/modules/{tailwind.js → tailwind.mjs} +0 -0
- /package/src/utils/{conditions.js → conditions.mjs} +0 -0
- /package/src/utils/{globs.js → globs.mjs} +0 -0
- /package/src/utils/{naming-convention.js → naming-convention.mjs} +0 -0
package/README.md
CHANGED
|
@@ -20,12 +20,22 @@ $ npm install --save-dev @fullstacksjs/eslint-config eslint prettier
|
|
|
20
20
|
|
|
21
21
|
To use the configuration all you need is exporting generated config by `init` function. The configuration reads the metadata from your root `package.json` file and automatically adds the rules and plugins that are needed.
|
|
22
22
|
|
|
23
|
+
### ESM
|
|
24
|
+
|
|
23
25
|
```js
|
|
24
26
|
import { init } from '@fullstacksjs/eslint-config';
|
|
25
27
|
|
|
26
28
|
export default init();
|
|
27
29
|
```
|
|
28
30
|
|
|
31
|
+
### CJS
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const { init } = require('@fullstacksjs/eslint-config');
|
|
35
|
+
|
|
36
|
+
module.exports = init();
|
|
37
|
+
```
|
|
38
|
+
|
|
29
39
|
## Modules API
|
|
30
40
|
|
|
31
41
|
You can fine tune module detection by overriding it, `init` function accepts options as its first argument to control enabled modules.
|
|
@@ -70,7 +80,13 @@ import { init } from '@fullstacksjs/eslint-config';
|
|
|
70
80
|
export default init(
|
|
71
81
|
{
|
|
72
82
|
typescript: true,
|
|
73
|
-
|
|
83
|
+
// You can pass extends here
|
|
84
|
+
rules {
|
|
85
|
+
'no-console': 'error'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
// And any number of extra configurations
|
|
89
|
+
{
|
|
74
90
|
files: ['**/*.ts'],
|
|
75
91
|
rules: {},
|
|
76
92
|
}, {
|
package/cjs/index.js
CHANGED
|
@@ -6,27 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.init = init;
|
|
7
7
|
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
8
8
|
var _localPkg = require("local-pkg");
|
|
9
|
-
var _base = _interopRequireDefault(require("./modules/base.
|
|
10
|
-
var _cypress = _interopRequireDefault(require("./modules/cypress.
|
|
11
|
-
var _functional = _interopRequireDefault(require("./modules/functional.
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
9
|
+
var _base = _interopRequireDefault(require("./modules/base.mjs"));
|
|
10
|
+
var _cypress = _interopRequireDefault(require("./modules/cypress.mjs"));
|
|
11
|
+
var _functional = _interopRequireDefault(require("./modules/functional.mjs"));
|
|
12
|
+
var _ignore = _interopRequireDefault(require("./modules/ignore.mjs"));
|
|
13
|
+
var _imports = _interopRequireDefault(require("./modules/imports.mjs"));
|
|
14
|
+
var _jest = _interopRequireDefault(require("./modules/jest.mjs"));
|
|
15
|
+
var _next = _interopRequireDefault(require("./modules/next.mjs"));
|
|
16
|
+
var _node = _interopRequireDefault(require("./modules/node.mjs"));
|
|
17
|
+
var _perfectionist = _interopRequireDefault(require("./modules/perfectionist.mjs"));
|
|
18
|
+
var _playwright = _interopRequireDefault(require("./modules/playwright.mjs"));
|
|
19
|
+
var _prettier = _interopRequireDefault(require("./modules/prettier.mjs"));
|
|
20
|
+
var _react = _interopRequireDefault(require("./modules/react.mjs"));
|
|
21
|
+
var _storybook = _interopRequireDefault(require("./modules/storybook.mjs"));
|
|
22
|
+
var _tailwind = _interopRequireDefault(require("./modules/tailwind.mjs"));
|
|
23
|
+
var _tests = _interopRequireDefault(require("./modules/tests.mjs"));
|
|
24
|
+
var _typescript = _interopRequireDefault(require("./modules/typescript.mjs"));
|
|
25
|
+
var _vitest = _interopRequireDefault(require("./modules/vitest.mjs"));
|
|
26
26
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
27
|
const testPackages = ['jest', 'vitest', 'cypress', 'playwright'];
|
|
28
28
|
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {import('eslint').Linter.Config} Config
|
|
31
|
+
* @typedef {import('./option').Options} Options
|
|
32
|
+
* /
|
|
33
|
+
|
|
34
|
+
/** @type {Options} */
|
|
30
35
|
const defaultOptions = {
|
|
31
36
|
cypress: (0, _localPkg.isPackageExists)('cypress'),
|
|
32
37
|
disableExpensiveRules: false,
|
|
@@ -48,18 +53,16 @@ const defaultOptions = {
|
|
|
48
53
|
typescript: (0, _localPkg.isPackageExists)('typescript') ? {
|
|
49
54
|
projects: true
|
|
50
55
|
} : false,
|
|
51
|
-
unocss: (0, _localPkg.isPackageExists)('unocss'),
|
|
52
56
|
vitest: (0, _localPkg.isPackageExists)('vitest')
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
/**
|
|
56
60
|
* Initialize eslint config
|
|
57
|
-
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
60
|
-
* @returns {import('eslint').Linter.Config[]}
|
|
61
|
+
* @param {Options} initOptions
|
|
62
|
+
* @param {...Config} extend
|
|
63
|
+
* @returns {Config[]}
|
|
61
64
|
*/
|
|
62
|
-
function init(initOptions, ...extend) {
|
|
65
|
+
function init(initOptions = {}, ...extend) {
|
|
63
66
|
const options = (0, _deepmerge.default)(defaultOptions, initOptions);
|
|
64
67
|
if (options.typescript === true) {
|
|
65
68
|
options.typescript = {};
|
|
@@ -67,21 +70,45 @@ function init(initOptions, ...extend) {
|
|
|
67
70
|
if (options.import === true) {
|
|
68
71
|
options.import = {};
|
|
69
72
|
}
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
73
|
+
const {
|
|
74
|
+
sort: enableSort,
|
|
75
|
+
cypress: enableCypress,
|
|
76
|
+
disableExpensiveRules,
|
|
77
|
+
esm: enableEsm,
|
|
78
|
+
fp: enableFp,
|
|
79
|
+
ignores: enableIgnores,
|
|
80
|
+
import: enableImport,
|
|
81
|
+
jest: enableJest,
|
|
82
|
+
next: enableNext,
|
|
83
|
+
node: enableNode,
|
|
84
|
+
playwright: enablePlaywright,
|
|
85
|
+
prettier: enablePrettier,
|
|
86
|
+
react: enableReact,
|
|
87
|
+
storybook: enableStorybook,
|
|
88
|
+
strict: enableStrict,
|
|
89
|
+
tailwind: enableTailwind,
|
|
90
|
+
test: enableTest,
|
|
91
|
+
typescript: enableTypescript,
|
|
92
|
+
vitest: enableVitest,
|
|
93
|
+
...eslintOptions
|
|
94
|
+
} = options;
|
|
95
|
+
const rules = [(0, _ignore.default)(options), (0, _base.default)(options)];
|
|
96
|
+
if (enableFp) rules.push((0, _functional.default)(options));
|
|
97
|
+
if (enableSort) rules.push((0, _perfectionist.default)(options));
|
|
98
|
+
if (enableImport) rules.push((0, _imports.default)(options));
|
|
99
|
+
if (enableTailwind) rules.push((0, _tailwind.default)(options));
|
|
100
|
+
if (enableTest) rules.push((0, _tests.default)(options));
|
|
101
|
+
if (enableNode) rules.push((0, _node.default)(options));
|
|
102
|
+
if (enableJest) rules.push((0, _jest.default)(options));
|
|
103
|
+
if (enableVitest) rules.push((0, _vitest.default)(options));
|
|
104
|
+
if (enableCypress) rules.push((0, _cypress.default)(options));
|
|
105
|
+
if (enableReact) rules.push((0, _react.default)(options));
|
|
106
|
+
if (enableStorybook) rules.push((0, _storybook.default)(options));
|
|
107
|
+
if (enableTypescript) rules.push((0, _typescript.default)(options));
|
|
108
|
+
if (enablePlaywright) rules.push((0, _playwright.default)(options));
|
|
109
|
+
if (enableNext && enableNext) rules.push((0, _next.default)(options));
|
|
110
|
+
if (enablePrettier) rules.push((0, _prettier.default)(options));
|
|
111
|
+
if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
|
|
112
|
+
if (extend) Array.prototype.push.apply(rules, extend);
|
|
113
|
+
return rules;
|
|
87
114
|
}
|
package/cjs/modules/base.js
CHANGED
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _globals = _interopRequireDefault(require("globals"));
|
|
8
|
-
var _conditions = require("../utils/conditions.
|
|
8
|
+
var _conditions = require("../utils/conditions.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
|
-
* @param { import('../option
|
|
11
|
+
* @param { import('../option').Options } options
|
|
12
12
|
* @return { import('eslint').Linter.Config }
|
|
13
13
|
*/
|
|
14
14
|
function base(options = {}) {
|
package/cjs/modules/cypress.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _flat = _interopRequireDefault(require("eslint-plugin-cypress/flat"));
|
|
8
|
-
var _globs = require("../utils/globs.
|
|
8
|
+
var _globs = require("../utils/globs.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/** @return { import('eslint').Linter.Config } */
|
|
11
11
|
function cypress() {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _globs = require("../utils/globs.mjs");
|
|
8
|
+
/**
|
|
9
|
+
* @param { import('../option').Options } options
|
|
10
|
+
* @return { import('eslint').Linter.Config }
|
|
11
|
+
*/
|
|
12
|
+
function ignores(options = {}) {
|
|
13
|
+
return {
|
|
14
|
+
ignores: [..._globs.ignoreGlobs, ...(options.ignores ?? [])]
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
module.exports = ignores;
|
package/cjs/modules/imports.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginImportX = _interopRequireDefault(require("eslint-plugin-import-x"));
|
|
8
|
-
var _conditions = require("../utils/conditions.
|
|
8
|
+
var _conditions = require("../utils/conditions.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
const tsExtensions = ['.ts', '.tsx', '.cts', '.mts', '.ctsx', '.mtsx'];
|
|
11
11
|
const jsExtensions = ['.mjs', '.js', '.jsx', '.cjs'];
|
|
12
12
|
const allExtensions = [...jsExtensions, ...tsExtensions];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param { import('../option
|
|
15
|
+
* @param { import('../option').Options } options
|
|
16
16
|
* @return { import('eslint').Linter.Config }
|
|
17
17
|
*/
|
|
18
18
|
function imports(options = {}) {
|
package/cjs/modules/jest.js
CHANGED
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginJest = _interopRequireDefault(require("eslint-plugin-jest"));
|
|
8
|
-
var _globs = require("../utils/globs.
|
|
8
|
+
var _globs = require("../utils/globs.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
|
-
* @param { import('../option
|
|
11
|
+
* @param { import('../option').Options } options
|
|
12
12
|
* @return { import('eslint').Linter.Config } */
|
|
13
13
|
function jest() {
|
|
14
14
|
return {
|
package/cjs/modules/node.js
CHANGED
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginN = _interopRequireDefault(require("eslint-plugin-n"));
|
|
8
|
-
var _conditions = require("../utils/conditions.
|
|
8
|
+
var _conditions = require("../utils/conditions.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
|
-
* @param { import('../option
|
|
11
|
+
* @param { import('../option').Options } options
|
|
12
12
|
* @return { import('eslint').Linter.Config }
|
|
13
13
|
*/
|
|
14
14
|
function node(options = {}) {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginPlaywright = _interopRequireDefault(require("eslint-plugin-playwright"));
|
|
8
|
-
var _globs = require("../utils/globs.
|
|
8
|
+
var _globs = require("../utils/globs.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/** @return { import('eslint').Linter.Config } */
|
|
11
11
|
function playwright() {
|
package/cjs/modules/storybook.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginStorybook = _interopRequireDefault(require("eslint-plugin-storybook"));
|
|
8
|
-
var _globs = require("../utils/globs.
|
|
8
|
+
var _globs = require("../utils/globs.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/** @return { import('eslint').Linter.Config } */
|
|
11
11
|
function storybook() {
|
package/cjs/modules/tests.js
CHANGED
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
|
|
7
7
|
var _eslintPluginJestFormatting = _interopRequireDefault(require("eslint-plugin-jest-formatting"));
|
|
8
8
|
var _globals = _interopRequireDefault(require("globals"));
|
|
9
|
-
var _conditions = require("../utils/conditions.
|
|
10
|
-
var _globs = require("../utils/globs.
|
|
9
|
+
var _conditions = require("../utils/conditions.mjs");
|
|
10
|
+
var _globs = require("../utils/globs.mjs");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
/**
|
|
13
|
-
* @param { import('../option
|
|
13
|
+
* @param { import('../option').Options } options
|
|
14
14
|
* @return { import('eslint').Linter.Config }
|
|
15
15
|
*/
|
|
16
16
|
function tests(options = {}) {
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _typescriptEslint = require("typescript-eslint");
|
|
8
|
-
var _conditions = require("../utils/conditions.
|
|
9
|
-
var _globs = require("../utils/globs.
|
|
10
|
-
var _namingConvention = require("../utils/naming-convention.
|
|
8
|
+
var _conditions = require("../utils/conditions.mjs");
|
|
9
|
+
var _globs = require("../utils/globs.mjs");
|
|
10
|
+
var _namingConvention = require("../utils/naming-convention.mjs");
|
|
11
11
|
/**
|
|
12
|
-
* @param { import('../option
|
|
12
|
+
* @param { import('../option').Options } options
|
|
13
13
|
* @return { import('eslint').Linter.Config }
|
|
14
14
|
*/
|
|
15
15
|
function typescript(options = {}) {
|
package/cjs/modules/vitest.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _eslintPluginVitest = _interopRequireDefault(require("eslint-plugin-vitest"));
|
|
8
|
-
var _globs = require("../utils/globs.
|
|
8
|
+
var _globs = require("../utils/globs.mjs");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
/**
|
|
11
11
|
* @return { import('eslint').Linter.Config }
|
package/cjs/option.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstacksjs/eslint-config",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "fullstacks <fullstacksjs@gmail.com>",
|
|
6
6
|
"description": "fullstacks eslint config",
|
|
@@ -25,14 +25,13 @@
|
|
|
25
25
|
"pre-commit": "npm run test && lint-staged"
|
|
26
26
|
},
|
|
27
27
|
"main": "./cjs/index.js",
|
|
28
|
-
"module": "./src/index.
|
|
28
|
+
"module": "./src/index.mjs",
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"import": "./
|
|
32
|
-
"require": "./
|
|
31
|
+
"import": "./src/index.mjs",
|
|
32
|
+
"require": "./cjs/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"type": "module",
|
|
36
35
|
"dependencies": {
|
|
37
36
|
"@eslint-react/eslint-plugin": "1.15.0",
|
|
38
37
|
"@next/eslint-plugin-next": "14.2.15",
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import merge from 'deepmerge';
|
|
2
|
+
import { isPackageExists } from 'local-pkg';
|
|
3
|
+
|
|
4
|
+
import base from './modules/base.mjs';
|
|
5
|
+
import cypress from './modules/cypress.mjs';
|
|
6
|
+
import fp from './modules/functional.mjs';
|
|
7
|
+
import ignores from './modules/ignore.mjs';
|
|
8
|
+
import imports from './modules/imports.mjs';
|
|
9
|
+
import jest from './modules/jest.mjs';
|
|
10
|
+
import next from './modules/next.mjs';
|
|
11
|
+
import node from './modules/node.mjs';
|
|
12
|
+
import perfectionist from './modules/perfectionist.mjs';
|
|
13
|
+
import playwright from './modules/playwright.mjs';
|
|
14
|
+
import prettier from './modules/prettier.mjs';
|
|
15
|
+
import react from './modules/react.mjs';
|
|
16
|
+
import storybook from './modules/storybook.mjs';
|
|
17
|
+
import tailwind from './modules/tailwind.mjs';
|
|
18
|
+
import tests from './modules/tests.mjs';
|
|
19
|
+
import typescript from './modules/typescript.mjs';
|
|
20
|
+
import vitest from './modules/vitest.mjs';
|
|
21
|
+
|
|
22
|
+
const testPackages = ['jest', 'vitest', 'cypress', 'playwright'];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import('eslint').Linter.Config} Config
|
|
26
|
+
* @typedef {import('./option').Options} Options
|
|
27
|
+
* /
|
|
28
|
+
|
|
29
|
+
/** @type {Options} */
|
|
30
|
+
const defaultOptions = {
|
|
31
|
+
cypress: isPackageExists('cypress'),
|
|
32
|
+
disableExpensiveRules: false,
|
|
33
|
+
esm: false,
|
|
34
|
+
fp: true,
|
|
35
|
+
ignores: [],
|
|
36
|
+
import: {},
|
|
37
|
+
jest: isPackageExists('jest'),
|
|
38
|
+
next: isPackageExists('next'),
|
|
39
|
+
node: false,
|
|
40
|
+
sort: true,
|
|
41
|
+
playwright: isPackageExists('playwright'),
|
|
42
|
+
prettier: isPackageExists('prettier'),
|
|
43
|
+
react: isPackageExists('react'),
|
|
44
|
+
storybook: isPackageExists('storybook'),
|
|
45
|
+
strict: false,
|
|
46
|
+
tailwind: isPackageExists('tailwindcss'),
|
|
47
|
+
test: testPackages.some(p => isPackageExists(p)),
|
|
48
|
+
typescript: isPackageExists('typescript') ? { projects: true } : false,
|
|
49
|
+
vitest: isPackageExists('vitest'),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initialize eslint config
|
|
54
|
+
* @param {Options} initOptions
|
|
55
|
+
* @param {...Config} extend
|
|
56
|
+
* @returns {Config[]}
|
|
57
|
+
*/
|
|
58
|
+
export function init(initOptions = {}, ...extend) {
|
|
59
|
+
const options = merge(defaultOptions, initOptions);
|
|
60
|
+
if (options.typescript === true) {
|
|
61
|
+
options.typescript = {};
|
|
62
|
+
}
|
|
63
|
+
if (options.import === true) {
|
|
64
|
+
options.import = {};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
sort: enableSort,
|
|
69
|
+
cypress: enableCypress,
|
|
70
|
+
disableExpensiveRules,
|
|
71
|
+
esm: enableEsm,
|
|
72
|
+
fp: enableFp,
|
|
73
|
+
ignores: enableIgnores,
|
|
74
|
+
import: enableImport,
|
|
75
|
+
jest: enableJest,
|
|
76
|
+
next: enableNext,
|
|
77
|
+
node: enableNode,
|
|
78
|
+
playwright: enablePlaywright,
|
|
79
|
+
prettier: enablePrettier,
|
|
80
|
+
react: enableReact,
|
|
81
|
+
storybook: enableStorybook,
|
|
82
|
+
strict: enableStrict,
|
|
83
|
+
tailwind: enableTailwind,
|
|
84
|
+
test: enableTest,
|
|
85
|
+
typescript: enableTypescript,
|
|
86
|
+
vitest: enableVitest,
|
|
87
|
+
...eslintOptions
|
|
88
|
+
} = options;
|
|
89
|
+
|
|
90
|
+
const rules = [ignores(options), base(options)];
|
|
91
|
+
|
|
92
|
+
if (enableFp) rules.push(fp(options));
|
|
93
|
+
if (enableSort) rules.push(perfectionist(options));
|
|
94
|
+
if (enableImport) rules.push(imports(options));
|
|
95
|
+
if (enableTailwind) rules.push(tailwind(options));
|
|
96
|
+
if (enableTest) rules.push(tests(options));
|
|
97
|
+
if (enableNode) rules.push(node(options));
|
|
98
|
+
if (enableJest) rules.push(jest(options));
|
|
99
|
+
if (enableVitest) rules.push(vitest(options));
|
|
100
|
+
if (enableCypress) rules.push(cypress(options));
|
|
101
|
+
if (enableReact) rules.push(react(options));
|
|
102
|
+
if (enableStorybook) rules.push(storybook(options));
|
|
103
|
+
if (enableTypescript) rules.push(typescript(options));
|
|
104
|
+
if (enablePlaywright) rules.push(playwright(options));
|
|
105
|
+
if (enableNext && enableNext) rules.push(next(options));
|
|
106
|
+
if (enablePrettier) rules.push(prettier(options));
|
|
107
|
+
|
|
108
|
+
if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
|
|
109
|
+
if (extend) Array.prototype.push.apply(rules, extend);
|
|
110
|
+
|
|
111
|
+
return rules;
|
|
112
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import globals from 'globals';
|
|
2
2
|
|
|
3
|
-
import { strict } from '../utils/conditions.
|
|
3
|
+
import { strict } from '../utils/conditions.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @param { import('../option
|
|
6
|
+
* @param { import('../option').Options } options
|
|
7
7
|
* @return { import('eslint').Linter.Config }
|
|
8
8
|
*/
|
|
9
9
|
function base(options = {}) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ignoreGlobs } from '../utils/globs.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* @param { import('../option').Options } options
|
|
4
|
+
* @return { import('eslint').Linter.Config }
|
|
5
|
+
*/
|
|
6
|
+
function ignores(options = {}) {
|
|
7
|
+
return {
|
|
8
|
+
ignores: [...ignoreGlobs, ...(options.ignores ?? [])],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default ignores;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import plugin from 'eslint-plugin-import-x';
|
|
2
2
|
|
|
3
|
-
import { predicate } from '../utils/conditions.
|
|
3
|
+
import { predicate } from '../utils/conditions.mjs';
|
|
4
4
|
|
|
5
5
|
const tsExtensions = ['.ts', '.tsx', '.cts', '.mts', '.ctsx', '.mtsx'];
|
|
6
6
|
const jsExtensions = ['.mjs', '.js', '.jsx', '.cjs'];
|
|
7
7
|
const allExtensions = [...jsExtensions, ...tsExtensions];
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @param { import('../option
|
|
10
|
+
* @param { import('../option').Options } options
|
|
11
11
|
* @return { import('eslint').Linter.Config }
|
|
12
12
|
*/
|
|
13
13
|
function imports(options = {}) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import plugin from 'eslint-plugin-jest';
|
|
2
2
|
|
|
3
|
-
import { globs } from '../utils/globs.
|
|
3
|
+
import { globs } from '../utils/globs.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @param { import('../option
|
|
6
|
+
* @param { import('../option').Options } options
|
|
7
7
|
* @return { import('eslint').Linter.Config } */
|
|
8
8
|
function jest() {
|
|
9
9
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import plugin from 'eslint-plugin-n';
|
|
2
2
|
|
|
3
|
-
import { strict } from '../utils/conditions.
|
|
3
|
+
import { strict } from '../utils/conditions.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @param { import('../option
|
|
6
|
+
* @param { import('../option').Options } options
|
|
7
7
|
* @return { import('eslint').Linter.Config }
|
|
8
8
|
*/
|
|
9
9
|
function node(options = {}) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import plugin from 'eslint-plugin-jest-formatting';
|
|
2
2
|
import globals from 'globals';
|
|
3
3
|
|
|
4
|
-
import { predicate } from '../utils/conditions.
|
|
5
|
-
import { globs } from '../utils/globs.
|
|
4
|
+
import { predicate } from '../utils/conditions.mjs';
|
|
5
|
+
import { globs } from '../utils/globs.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param { import('../option
|
|
8
|
+
* @param { import('../option').Options } options
|
|
9
9
|
* @return { import('eslint').Linter.Config }
|
|
10
10
|
*/
|
|
11
11
|
function tests(options = {}) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parser, plugin } from 'typescript-eslint';
|
|
2
2
|
|
|
3
|
-
import { predicate } from '../utils/conditions.
|
|
4
|
-
import { globs } from '../utils/globs.
|
|
5
|
-
import { namingConvention } from '../utils/naming-convention.
|
|
3
|
+
import { predicate } from '../utils/conditions.mjs';
|
|
4
|
+
import { globs } from '../utils/globs.mjs';
|
|
5
|
+
import { namingConvention } from '../utils/naming-convention.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param { import('../option
|
|
8
|
+
* @param { import('../option').Options } options
|
|
9
9
|
* @return { import('eslint').Linter.Config }
|
|
10
10
|
*/
|
|
11
11
|
function typescript(options = {}) {
|
package/src/option.d.ts
CHANGED
package/cjs/utils/compose.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.compose = compose;
|
|
7
|
-
var _globs = require("./globs.js");
|
|
8
|
-
/**
|
|
9
|
-
* @param { (options: import('eslint').Linter.Config) => import('eslint').Linter.Config } module
|
|
10
|
-
* @param { import('../option').Options } options
|
|
11
|
-
* @return { import('eslint').Linter.Config }
|
|
12
|
-
*/
|
|
13
|
-
function compose(module, options) {
|
|
14
|
-
const config = module(options);
|
|
15
|
-
config.ignores = [...(config.ignores ?? []), ...(options.ignores ?? []), ...(_globs.ignoreGlobs ?? [])];
|
|
16
|
-
return config;
|
|
17
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import merge from 'deepmerge';
|
|
2
|
-
import { isPackageExists } from 'local-pkg';
|
|
3
|
-
|
|
4
|
-
import base from './modules/base.js';
|
|
5
|
-
import cypress from './modules/cypress.js';
|
|
6
|
-
import fp from './modules/functional.js';
|
|
7
|
-
import imports from './modules/imports.js';
|
|
8
|
-
import jest from './modules/jest.js';
|
|
9
|
-
import next from './modules/next.js';
|
|
10
|
-
import node from './modules/node.js';
|
|
11
|
-
import perfectionist from './modules/perfectionist.js';
|
|
12
|
-
import playwright from './modules/playwright.js';
|
|
13
|
-
import prettier from './modules/prettier.js';
|
|
14
|
-
import react from './modules/react.js';
|
|
15
|
-
import storybook from './modules/storybook.js';
|
|
16
|
-
import tailwind from './modules/tailwind.js';
|
|
17
|
-
import tests from './modules/tests.js';
|
|
18
|
-
import typescript from './modules/typescript.js';
|
|
19
|
-
import vitest from './modules/vitest.js';
|
|
20
|
-
import { compose } from './utils/compose.js';
|
|
21
|
-
|
|
22
|
-
const testPackages = ['jest', 'vitest', 'cypress', 'playwright'];
|
|
23
|
-
|
|
24
|
-
/** @type {import('./option.d.ts').Options} */
|
|
25
|
-
const defaultOptions = {
|
|
26
|
-
cypress: isPackageExists('cypress'),
|
|
27
|
-
disableExpensiveRules: false,
|
|
28
|
-
esm: false,
|
|
29
|
-
fp: true,
|
|
30
|
-
ignores: [],
|
|
31
|
-
import: {},
|
|
32
|
-
jest: isPackageExists('jest'),
|
|
33
|
-
next: isPackageExists('next'),
|
|
34
|
-
node: false,
|
|
35
|
-
sort: true,
|
|
36
|
-
playwright: isPackageExists('playwright'),
|
|
37
|
-
prettier: isPackageExists('prettier'),
|
|
38
|
-
react: isPackageExists('react'),
|
|
39
|
-
storybook: isPackageExists('storybook'),
|
|
40
|
-
strict: false,
|
|
41
|
-
tailwind: isPackageExists('tailwindcss'),
|
|
42
|
-
test: testPackages.some(p => isPackageExists(p)),
|
|
43
|
-
typescript: isPackageExists('typescript') ? { projects: true } : false,
|
|
44
|
-
unocss: isPackageExists('unocss'),
|
|
45
|
-
vitest: isPackageExists('vitest'),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Initialize eslint config
|
|
50
|
-
*
|
|
51
|
-
* @param {import('./option.d.ts').Options} initOptions
|
|
52
|
-
* @param {...(import('eslint').Linter.Config)} extend
|
|
53
|
-
* @returns {import('eslint').Linter.Config[]}
|
|
54
|
-
*/
|
|
55
|
-
export function init(initOptions, ...extend) {
|
|
56
|
-
const options = merge(defaultOptions, initOptions);
|
|
57
|
-
if (options.typescript === true) {
|
|
58
|
-
options.typescript = {};
|
|
59
|
-
}
|
|
60
|
-
if (options.import === true) {
|
|
61
|
-
options.import = {};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const rules = [compose(base, options)];
|
|
65
|
-
|
|
66
|
-
if (options.fp) rules.push(compose(fp, options));
|
|
67
|
-
if (options.sort) rules.push(compose(perfectionist, options));
|
|
68
|
-
if (options.import) rules.push(compose(imports, options));
|
|
69
|
-
if (options.tailwind) rules.push(compose(tailwind, options));
|
|
70
|
-
if (options.test) rules.push(compose(tests, options));
|
|
71
|
-
if (options.node) rules.push(compose(node, options));
|
|
72
|
-
if (options.jest) rules.push(compose(jest, options));
|
|
73
|
-
if (options.vitest) rules.push(compose(vitest, options));
|
|
74
|
-
if (options.cypress) rules.push(compose(cypress, options));
|
|
75
|
-
if (options.react) rules.push(compose(react, options));
|
|
76
|
-
if (options.storybook) rules.push(compose(storybook, options));
|
|
77
|
-
if (options.typescript) rules.push(compose(typescript, options));
|
|
78
|
-
if (options.playwright) rules.push(compose(playwright, options));
|
|
79
|
-
if (options.next && options.next) rules.push(compose(next, options));
|
|
80
|
-
|
|
81
|
-
if (options.prettier) rules.push(compose(prettier, options));
|
|
82
|
-
|
|
83
|
-
return rules.concat(extend);
|
|
84
|
-
}
|
package/src/utils/compose.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ignoreGlobs } from './globs.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param { (options: import('eslint').Linter.Config) => import('eslint').Linter.Config } module
|
|
5
|
-
* @param { import('../option').Options } options
|
|
6
|
-
* @return { import('eslint').Linter.Config }
|
|
7
|
-
*/
|
|
8
|
-
export function compose(module, options) {
|
|
9
|
-
const config = module(options);
|
|
10
|
-
config.ignores = [...(config.ignores ?? []), ...(options.ignores ?? []), ...(ignoreGlobs ?? [])];
|
|
11
|
-
return config;
|
|
12
|
-
}
|
|
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
|