@fullstacksjs/eslint-config 11.1.18 → 11.1.19
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 +52 -25
- package/cjs/modules/ignore.js +17 -0
- package/cjs/option.d.ts +3 -1
- package/package.json +3 -3
- package/src/index.js +53 -25
- package/src/modules/ignore.js +12 -0
- package/src/option.d.ts +3 -1
- package/cjs/utils/compose.js +0 -17
- package/src/utils/compose.js +0 -12
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
|
@@ -9,6 +9,7 @@ var _localPkg = require("local-pkg");
|
|
|
9
9
|
var _base = _interopRequireDefault(require("./modules/base.js"));
|
|
10
10
|
var _cypress = _interopRequireDefault(require("./modules/cypress.js"));
|
|
11
11
|
var _functional = _interopRequireDefault(require("./modules/functional.js"));
|
|
12
|
+
var _ignore = _interopRequireDefault(require("./modules/ignore.js"));
|
|
12
13
|
var _imports = _interopRequireDefault(require("./modules/imports.js"));
|
|
13
14
|
var _jest = _interopRequireDefault(require("./modules/jest.js"));
|
|
14
15
|
var _next = _interopRequireDefault(require("./modules/next.js"));
|
|
@@ -22,11 +23,15 @@ var _tailwind = _interopRequireDefault(require("./modules/tailwind.js"));
|
|
|
22
23
|
var _tests = _interopRequireDefault(require("./modules/tests.js"));
|
|
23
24
|
var _typescript = _interopRequireDefault(require("./modules/typescript.js"));
|
|
24
25
|
var _vitest = _interopRequireDefault(require("./modules/vitest.js"));
|
|
25
|
-
var _compose = require("./utils/compose.js");
|
|
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.d.ts').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
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _globs = require("../utils/globs.js");
|
|
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/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.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "fullstacks <fullstacksjs@gmail.com>",
|
|
6
6
|
"description": "fullstacks eslint config",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"module": "./src/index.js",
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
|
-
"import": "./
|
|
32
|
-
"require": "./
|
|
31
|
+
"import": "./src/index.js",
|
|
32
|
+
"require": "./cjs/index.js"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"type": "module",
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { isPackageExists } from 'local-pkg';
|
|
|
4
4
|
import base from './modules/base.js';
|
|
5
5
|
import cypress from './modules/cypress.js';
|
|
6
6
|
import fp from './modules/functional.js';
|
|
7
|
+
import ignores from './modules/ignore.js';
|
|
7
8
|
import imports from './modules/imports.js';
|
|
8
9
|
import jest from './modules/jest.js';
|
|
9
10
|
import next from './modules/next.js';
|
|
@@ -17,11 +18,15 @@ import tailwind from './modules/tailwind.js';
|
|
|
17
18
|
import tests from './modules/tests.js';
|
|
18
19
|
import typescript from './modules/typescript.js';
|
|
19
20
|
import vitest from './modules/vitest.js';
|
|
20
|
-
import { compose } from './utils/compose.js';
|
|
21
21
|
|
|
22
22
|
const testPackages = ['jest', 'vitest', 'cypress', 'playwright'];
|
|
23
23
|
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import('eslint').Linter.Config} Config
|
|
26
|
+
* @typedef {import('./option.d.ts').Options} Options
|
|
27
|
+
* /
|
|
28
|
+
|
|
29
|
+
/** @type {Options} */
|
|
25
30
|
const defaultOptions = {
|
|
26
31
|
cypress: isPackageExists('cypress'),
|
|
27
32
|
disableExpensiveRules: false,
|
|
@@ -41,18 +46,16 @@ const defaultOptions = {
|
|
|
41
46
|
tailwind: isPackageExists('tailwindcss'),
|
|
42
47
|
test: testPackages.some(p => isPackageExists(p)),
|
|
43
48
|
typescript: isPackageExists('typescript') ? { projects: true } : false,
|
|
44
|
-
unocss: isPackageExists('unocss'),
|
|
45
49
|
vitest: isPackageExists('vitest'),
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* Initialize eslint config
|
|
50
|
-
*
|
|
51
|
-
* @param {
|
|
52
|
-
* @
|
|
53
|
-
* @returns {import('eslint').Linter.Config[]}
|
|
54
|
+
* @param {Options} initOptions
|
|
55
|
+
* @param {...Config} extend
|
|
56
|
+
* @returns {Config[]}
|
|
54
57
|
*/
|
|
55
|
-
export function init(initOptions, ...extend) {
|
|
58
|
+
export function init(initOptions = {}, ...extend) {
|
|
56
59
|
const options = merge(defaultOptions, initOptions);
|
|
57
60
|
if (options.typescript === true) {
|
|
58
61
|
options.typescript = {};
|
|
@@ -61,24 +64,49 @@ export function init(initOptions, ...extend) {
|
|
|
61
64
|
options.import = {};
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
const
|
|
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)];
|
|
65
91
|
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
68
|
-
if (
|
|
69
|
-
if (
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
-
if (
|
|
73
|
-
if (
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
-
if (
|
|
79
|
-
if (
|
|
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));
|
|
80
107
|
|
|
81
|
-
if (
|
|
108
|
+
if (Object.keys(eslintOptions).length > 0) rules.push(eslintOptions);
|
|
109
|
+
if (extend) Array.prototype.push.apply(rules, extend);
|
|
82
110
|
|
|
83
|
-
return rules
|
|
111
|
+
return rules;
|
|
84
112
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ignoreGlobs } from '../utils/globs.js';
|
|
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;
|
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/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
|
-
}
|