@fullstacksjs/eslint-config 11.1.17 → 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 +114 -0
- package/cjs/modules/base.js +213 -0
- package/cjs/modules/cypress.js +30 -0
- package/cjs/modules/functional.js +27 -0
- package/cjs/modules/ignore.js +17 -0
- package/cjs/modules/imports.js +112 -0
- package/cjs/modules/jest.js +82 -0
- package/cjs/modules/next.js +40 -0
- package/cjs/modules/node.js +68 -0
- package/cjs/modules/perfectionist.js +41 -0
- package/cjs/modules/playwright.js +26 -0
- package/cjs/modules/prettier.js +96 -0
- package/cjs/modules/promise.js +34 -0
- package/cjs/modules/react.js +123 -0
- package/cjs/modules/storybook.js +39 -0
- package/cjs/modules/tailwind.js +26 -0
- package/cjs/modules/tests.js +54 -0
- package/cjs/modules/typescript.js +276 -0
- package/cjs/modules/vitest.js +91 -0
- package/cjs/option.d.ts +25 -0
- package/cjs/utils/conditions.js +25 -0
- package/cjs/utils/globs.js +37 -0
- package/cjs/utils/naming-convention.js +63 -0
- package/package.json +13 -4
- package/src/index.js +53 -25
- package/src/modules/ignore.js +12 -0
- package/src/option.d.ts +3 -1
- package/src/utils/compose.js +0 -12
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/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
|
-
}
|