@fullstacksjs/eslint-config 12.3.1-next.1 → 12.4.1
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 +3 -2
- package/cjs/index.d.ts +31 -34
- package/cjs/index.js +10 -0
- package/cjs/modules/base.js +1 -1
- package/cjs/modules/ignore.js +11 -1
- package/cjs/modules/tailwind.js +11 -13
- package/cjs/utils/getGitignorePatterns.js +35 -0
- package/package.json +4 -3
- package/src/index.d.ts +31 -34
- package/src/index.mjs +9 -1
- package/src/modules/base.mjs +1 -1
- package/src/modules/ignore.mjs +15 -1
- package/src/modules/tailwind.mjs +11 -11
- package/src/utils/getGitignorePatterns.mjs +35 -0
package/README.md
CHANGED
|
@@ -69,10 +69,11 @@ interface Options {
|
|
|
69
69
|
cypress?: boolean; // controls cypress plugin
|
|
70
70
|
playwright?: boolean // controls playwright plugin
|
|
71
71
|
storybook?: boolean; // controls storybook plugin
|
|
72
|
-
tailwind?:
|
|
72
|
+
tailwind?: boolean | { callee?: string[] }; // controls tailwindcss plugin
|
|
73
73
|
next?: boolean; // controls next plugin
|
|
74
74
|
prettier?: boolean; // controls prettier plugin
|
|
75
75
|
disableExpensiveRules?: boolean; // controls expensive rules
|
|
76
|
+
gitignorePath?: string; // automatically ignore paths from .gitignore
|
|
76
77
|
}
|
|
77
78
|
```
|
|
78
79
|
|
|
@@ -177,7 +178,7 @@ export default defineConfig({
|
|
|
177
178
|
* [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)
|
|
178
179
|
* [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
|
|
179
180
|
* [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook#readme)
|
|
180
|
-
* [eslint-plugin-
|
|
181
|
+
* [eslint-plugin-tailwindcss](https://github.com/francoismassart/eslint-plugin-tailwindcss)
|
|
181
182
|
* [eslint-plugin-vitest](https://www.npmjs.com/package/eslint-plugin-vitest)
|
|
182
183
|
* [typescript-eslint](https://typescript-eslint.io/)
|
|
183
184
|
|
package/cjs/index.d.ts
CHANGED
|
@@ -7,17 +7,10 @@ interface ProjectService {
|
|
|
7
7
|
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type TailwindConfig = {
|
|
11
|
-
callees: string[];
|
|
12
|
-
variables?: string[];
|
|
13
|
-
attributes?: string[];
|
|
14
|
-
tags?: string[];
|
|
15
|
-
} & ({ entryPoint: string; tailwindConfig?: string } | { entryPoint?: string; tailwindConfig: string });
|
|
16
|
-
|
|
17
10
|
export interface Options extends Linter.Config {
|
|
18
11
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* Controls React plugin.
|
|
13
|
+
* @default true - If you have `react` or `react-dom` in your dependencies.
|
|
21
14
|
*/
|
|
22
15
|
react?: boolean;
|
|
23
16
|
/**
|
|
@@ -25,85 +18,89 @@ export interface Options extends Linter.Config {
|
|
|
25
18
|
*/
|
|
26
19
|
sort?: boolean;
|
|
27
20
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
21
|
+
* Controls Next plugin.
|
|
22
|
+
* @default true - If you have `next` in your dependencies.
|
|
30
23
|
*/
|
|
31
24
|
next?: boolean;
|
|
32
25
|
/**
|
|
33
26
|
* Controls Tailwind plugin.
|
|
34
|
-
* @default
|
|
35
|
-
* @see https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md
|
|
27
|
+
* @default true - If you have `tailwind` in your dependencies.
|
|
36
28
|
*/
|
|
37
|
-
tailwind?:
|
|
29
|
+
tailwind?: boolean | { callees: string[] };
|
|
38
30
|
/**
|
|
31
|
+
* Controls [Node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
39
32
|
* @default false
|
|
40
|
-
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
41
33
|
*/
|
|
42
34
|
node?: boolean;
|
|
43
35
|
/**
|
|
44
|
-
* @default false
|
|
45
36
|
* Enables all strict rules.
|
|
37
|
+
* @default false
|
|
46
38
|
*/
|
|
47
39
|
strict?: boolean;
|
|
48
40
|
/**
|
|
49
|
-
* @default true
|
|
50
41
|
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
42
|
+
* @default true
|
|
51
43
|
*/
|
|
52
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
53
45
|
/**
|
|
54
|
-
* @default true
|
|
46
|
+
* @default true - If you have `type: module` in your `package.json`.
|
|
55
47
|
*/
|
|
56
48
|
esm?: boolean;
|
|
57
49
|
/**
|
|
58
|
-
* @default true if you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
59
50
|
* Controls [test plugin](https://www.npmjs.com/package/eslint-plugin-jest-formatting).
|
|
51
|
+
* @default true - If you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
60
52
|
*/
|
|
61
53
|
test?: boolean;
|
|
62
54
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
55
|
+
* Controls [Jest plugin](https://www.npmjs.com/package/eslint-plugin-jest).
|
|
56
|
+
* @default true - If you have `jest` in your dependencies.
|
|
65
57
|
*/
|
|
66
58
|
jest?: boolean;
|
|
67
59
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
60
|
+
* Controls [Vitest plugin](https://www.npmjs.com/package/eslint-plugin-vitest).
|
|
61
|
+
* @default true - If you have `vitest` in your dependencies.
|
|
70
62
|
*/
|
|
71
63
|
vitest?: boolean;
|
|
72
64
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
65
|
+
* Controls [Cypress plugin](https://www.npmjs.com/package/eslint-plugin-cypress).
|
|
66
|
+
* @default true - If you have `cypress` in your dependencies.
|
|
75
67
|
*/
|
|
76
68
|
cypress?: boolean;
|
|
77
69
|
/**
|
|
70
|
+
* Controls [Storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
78
71
|
* @default true if you have `storybook` in your dependencies.
|
|
79
|
-
* Controls [storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
80
72
|
*/
|
|
81
73
|
storybook?: boolean;
|
|
82
74
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
75
|
+
* Controls [Prettier plugin](https://www.npmjs.com/package/eslint-plugin-prettier).
|
|
76
|
+
* @default true - If you have `prettier` in your dependencies.
|
|
85
77
|
*/
|
|
86
78
|
prettier?: boolean;
|
|
87
79
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
80
|
+
* Controls [Playwright plugin](https://www.npmjs.com/package/eslint-plugin-playwright).
|
|
81
|
+
* @default true - If you have `playwright` in your dependencies.
|
|
90
82
|
*/
|
|
91
83
|
playwright?: boolean;
|
|
92
84
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
85
|
+
* Controls [TypeScript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
86
|
+
* @default true - If you have `typescript` in your dependencies.
|
|
95
87
|
*/
|
|
96
88
|
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
97
89
|
/**
|
|
98
|
-
* @default false
|
|
99
90
|
* Disables expensive rules.
|
|
91
|
+
* @default false
|
|
100
92
|
*/
|
|
101
93
|
disableExpensiveRules?: boolean;
|
|
102
94
|
/**
|
|
95
|
+
* List of globs to ignore
|
|
103
96
|
* @default []
|
|
104
|
-
* List of globs to ignore.
|
|
105
97
|
*/
|
|
106
98
|
ignores?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* .gitignore file path relative to ESLint configuration file. Set to `false` to disable.
|
|
101
|
+
* @default './.gitignore'
|
|
102
|
+
*/
|
|
103
|
+
gitignore?: string | false;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
export declare function defineConfig(initOptions?: Options, ...extend: Linter.Config[]): Linter.Config[];
|
package/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defineConfig = defineConfig;
|
|
7
|
+
exports.init = void 0;
|
|
7
8
|
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
8
9
|
var _config = require("eslint/config");
|
|
9
10
|
var _localPkg = require("local-pkg");
|
|
@@ -38,6 +39,7 @@ const defaultOptions = {
|
|
|
38
39
|
disableExpensiveRules: false,
|
|
39
40
|
esm: false,
|
|
40
41
|
ignores: [],
|
|
42
|
+
gitignore: './.gitignore',
|
|
41
43
|
import: {},
|
|
42
44
|
jest: (0, _localPkg.isPackageExists)('jest'),
|
|
43
45
|
next: (0, _localPkg.isPackageExists)('next'),
|
|
@@ -49,6 +51,7 @@ const defaultOptions = {
|
|
|
49
51
|
storybook: (0, _localPkg.isPackageExists)('storybook'),
|
|
50
52
|
strict: false,
|
|
51
53
|
tailwind: false,
|
|
54
|
+
// ISSUE: https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/325,
|
|
52
55
|
test: testPackages.some(p => (0, _localPkg.isPackageExists)(p)),
|
|
53
56
|
typescript: (0, _localPkg.isPackageExists)('typescript') ? {
|
|
54
57
|
projectService: true
|
|
@@ -64,6 +67,9 @@ const defaultOptions = {
|
|
|
64
67
|
*/
|
|
65
68
|
function defineConfig(initOptions = {}, ...extend) {
|
|
66
69
|
const options = (0, _deepmerge.default)(defaultOptions, initOptions);
|
|
70
|
+
if (options.tailwind === true) {
|
|
71
|
+
options.tailwind = {};
|
|
72
|
+
}
|
|
67
73
|
if (options.import === true) {
|
|
68
74
|
options.import = {};
|
|
69
75
|
}
|
|
@@ -73,6 +79,7 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
73
79
|
disableExpensiveRules,
|
|
74
80
|
esm: enableEsm,
|
|
75
81
|
ignores: enableIgnores,
|
|
82
|
+
gitignore,
|
|
76
83
|
import: enableImport,
|
|
77
84
|
jest: enableJest,
|
|
78
85
|
next: enableNext,
|
|
@@ -107,3 +114,6 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
107
114
|
if (extend) Array.prototype.push.apply(rules, extend);
|
|
108
115
|
return (0, _config.defineConfig)(rules);
|
|
109
116
|
}
|
|
117
|
+
|
|
118
|
+
/** @deprecated Please use `defineConfig` from `@fullstacksjs/eslint-config` instead, this function will be removed in the next major release. */
|
|
119
|
+
const init = exports.init = defineConfig;
|
package/cjs/modules/base.js
CHANGED
package/cjs/modules/ignore.js
CHANGED
|
@@ -5,12 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
var _config = require("eslint/config");
|
|
8
|
+
var _getGitignorePatterns = require("../utils/getGitignorePatterns.js");
|
|
8
9
|
var _globs = require("../utils/globs.js");
|
|
9
10
|
/**
|
|
10
11
|
* @param { import('../index.js').Options } options
|
|
11
12
|
* @return { import('eslint').Linter.Config }
|
|
12
13
|
*/
|
|
13
14
|
function ignores(options = {}) {
|
|
14
|
-
|
|
15
|
+
const ignorePatterns = [..._globs.ignoreGlobs, ...(options.ignores ?? [])];
|
|
16
|
+
const shouldUseGitignore = options.gitignore && options.gitignore.length > 0;
|
|
17
|
+
if (shouldUseGitignore) {
|
|
18
|
+
const gitignorePatterns = (0, _getGitignorePatterns.getGitignorePatterns)(options.gitignore);
|
|
19
|
+
if (gitignorePatterns.length > 0) {
|
|
20
|
+
ignorePatterns.push(...gitignorePatterns);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const uniqueIgnorePatterns = [...new Set(ignorePatterns)];
|
|
24
|
+
return (0, _config.globalIgnores)(uniqueIgnorePatterns, 'ignores');
|
|
15
25
|
}
|
|
16
26
|
module.exports = ignores;
|
package/cjs/modules/tailwind.js
CHANGED
|
@@ -9,26 +9,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
* @return { Promise<import('eslint').Linter.Config> }
|
|
10
10
|
*/
|
|
11
11
|
async function tailwind(options = {}) {
|
|
12
|
-
const plugin = await Promise.resolve().then(() => require('eslint-plugin-
|
|
12
|
+
const plugin = await Promise.resolve().then(() => require('eslint-plugin-tailwindcss'));
|
|
13
13
|
return {
|
|
14
14
|
plugins: {
|
|
15
|
-
|
|
15
|
+
tailwindcss: plugin.default ?? plugin
|
|
16
16
|
},
|
|
17
17
|
settings: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
tailwindConfig: options.tailwindConfig
|
|
18
|
+
tailwindcss: {
|
|
19
|
+
callees: options.callees ?? ['cva', 'classnames', 'classNames', 'class', 'clsx', 'cn', 'cns', 'cx']
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
rules: {
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
|
|
31
|
-
}]
|
|
23
|
+
'tailwindcss/classnames-order': 'warn',
|
|
24
|
+
'tailwindcss/enforces-negative-arbitrary-values': 'warn',
|
|
25
|
+
'tailwindcss/enforces-shorthand': 'warn',
|
|
26
|
+
'tailwindcss/migration-from-tailwind-2': 'warn',
|
|
27
|
+
'tailwindcss/no-arbitrary-value': 'off',
|
|
28
|
+
'tailwindcss/no-custom-classname': 'warn',
|
|
29
|
+
'tailwindcss/no-contradicting-classname': 'error'
|
|
32
30
|
}
|
|
33
31
|
};
|
|
34
32
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getGitignorePatterns = getGitignorePatterns;
|
|
7
|
+
var _compat = require("@eslint/compat");
|
|
8
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
9
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/* eslint 'no-console': ['warn', { allow: ['warn'] }] */
|
|
12
|
+
|
|
13
|
+
const warningMessage = '\u001B[38;2;229;229;14mWarning:\u001B[0m';
|
|
14
|
+
const fallbackMessage = 'Falling back to default ignore patterns. You can suppress this warning by setting \u001B[48;5;234m`gitignore: false`\u001B[0m in the config.';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} gitignorePath relative path to the .gitignore file
|
|
18
|
+
* @returns {string[]}
|
|
19
|
+
*/
|
|
20
|
+
function getGitignorePatterns(gitignorePath) {
|
|
21
|
+
const gitignoreAbsolutePath = _nodePath.default.resolve(process.cwd(), gitignorePath);
|
|
22
|
+
const gitignoreExists = _nodeFs.default.existsSync(gitignoreAbsolutePath); // eslint-disable-line n/no-sync
|
|
23
|
+
const gitignorePatterns = [];
|
|
24
|
+
if (!gitignoreExists) {
|
|
25
|
+
console.warn(warningMessage, `No .gitignore file found at "${gitignoreAbsolutePath}".`, fallbackMessage);
|
|
26
|
+
return gitignorePatterns;
|
|
27
|
+
}
|
|
28
|
+
const ignorePatterns = (0, _compat.includeIgnoreFile)(gitignoreAbsolutePath).ignores ?? [];
|
|
29
|
+
if (ignorePatterns.length > 0) {
|
|
30
|
+
gitignorePatterns.push(...ignorePatterns);
|
|
31
|
+
} else {
|
|
32
|
+
console.warn(warningMessage, `No patterns found in .gitignore file at "${gitignoreAbsolutePath}".`, fallbackMessage);
|
|
33
|
+
}
|
|
34
|
+
return gitignorePatterns;
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstacksjs/eslint-config",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "fullstacks <fullstacksjs@gmail.com>",
|
|
6
6
|
"description": "fullstacks eslint config",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"postbuild": "./postbuild",
|
|
24
24
|
"prepublishOnly": "pinst --disable",
|
|
25
25
|
"postpublish": "pinst --enable",
|
|
26
|
-
"pre-commit": "npm run test && lint-staged"
|
|
26
|
+
"pre-commit": "npm run test && lint-staged && npm run spell"
|
|
27
27
|
},
|
|
28
28
|
"main": "./cjs/index.js",
|
|
29
29
|
"module": "./src/index.mjs",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@eslint-react/eslint-plugin": "1.50.0",
|
|
39
|
+
"@eslint/compat": "1.3.0",
|
|
39
40
|
"@next/eslint-plugin-next": "15.3.2",
|
|
40
41
|
"@stylistic/eslint-plugin": "4.4.0",
|
|
41
42
|
"deepmerge": "4.3.1",
|
|
42
|
-
"eslint-plugin-better-tailwindcss": "3.2.1",
|
|
43
43
|
"eslint-plugin-cypress": "4.3.0",
|
|
44
44
|
"eslint-plugin-import-x": "4.13.3",
|
|
45
45
|
"eslint-plugin-jest": "28.11.0",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"eslint-plugin-promise": "7.2.1",
|
|
53
53
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
54
54
|
"eslint-plugin-storybook": "0.12.0",
|
|
55
|
+
"eslint-plugin-tailwindcss": "3.18.0",
|
|
55
56
|
"eslint-plugin-vitest": "0.5.4",
|
|
56
57
|
"globals": "16.2.0",
|
|
57
58
|
"local-pkg": "1.1.1",
|
package/src/index.d.ts
CHANGED
|
@@ -7,17 +7,10 @@ interface ProjectService {
|
|
|
7
7
|
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: number;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
type TailwindConfig = {
|
|
11
|
-
callees: string[];
|
|
12
|
-
variables?: string[];
|
|
13
|
-
attributes?: string[];
|
|
14
|
-
tags?: string[];
|
|
15
|
-
} & ({ entryPoint: string; tailwindConfig?: string } | { entryPoint?: string; tailwindConfig: string });
|
|
16
|
-
|
|
17
10
|
export interface Options extends Linter.Config {
|
|
18
11
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
12
|
+
* Controls React plugin.
|
|
13
|
+
* @default true - If you have `react` or `react-dom` in your dependencies.
|
|
21
14
|
*/
|
|
22
15
|
react?: boolean;
|
|
23
16
|
/**
|
|
@@ -25,85 +18,89 @@ export interface Options extends Linter.Config {
|
|
|
25
18
|
*/
|
|
26
19
|
sort?: boolean;
|
|
27
20
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
21
|
+
* Controls Next plugin.
|
|
22
|
+
* @default true - If you have `next` in your dependencies.
|
|
30
23
|
*/
|
|
31
24
|
next?: boolean;
|
|
32
25
|
/**
|
|
33
26
|
* Controls Tailwind plugin.
|
|
34
|
-
* @default
|
|
35
|
-
* @see https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md
|
|
27
|
+
* @default true - If you have `tailwind` in your dependencies.
|
|
36
28
|
*/
|
|
37
|
-
tailwind?:
|
|
29
|
+
tailwind?: boolean | { callees: string[] };
|
|
38
30
|
/**
|
|
31
|
+
* Controls [Node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
39
32
|
* @default false
|
|
40
|
-
* Controls [node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
41
33
|
*/
|
|
42
34
|
node?: boolean;
|
|
43
35
|
/**
|
|
44
|
-
* @default false
|
|
45
36
|
* Enables all strict rules.
|
|
37
|
+
* @default false
|
|
46
38
|
*/
|
|
47
39
|
strict?: boolean;
|
|
48
40
|
/**
|
|
49
|
-
* @default true
|
|
50
41
|
* Controls [import plugin](https://www.npmjs.com/package/eslint-plugin-import-x).
|
|
42
|
+
* @default true
|
|
51
43
|
*/
|
|
52
44
|
import?: boolean | { internalRegExp?: string; lifetime?: number; projects?: string | string[] };
|
|
53
45
|
/**
|
|
54
|
-
* @default true
|
|
46
|
+
* @default true - If you have `type: module` in your `package.json`.
|
|
55
47
|
*/
|
|
56
48
|
esm?: boolean;
|
|
57
49
|
/**
|
|
58
|
-
* @default true if you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
59
50
|
* Controls [test plugin](https://www.npmjs.com/package/eslint-plugin-jest-formatting).
|
|
51
|
+
* @default true - If you have one of `jest`, `vitest`, `cypress`, `playwright`, `storybook`, `prettier` in your dependencies.
|
|
60
52
|
*/
|
|
61
53
|
test?: boolean;
|
|
62
54
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
55
|
+
* Controls [Jest plugin](https://www.npmjs.com/package/eslint-plugin-jest).
|
|
56
|
+
* @default true - If you have `jest` in your dependencies.
|
|
65
57
|
*/
|
|
66
58
|
jest?: boolean;
|
|
67
59
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
60
|
+
* Controls [Vitest plugin](https://www.npmjs.com/package/eslint-plugin-vitest).
|
|
61
|
+
* @default true - If you have `vitest` in your dependencies.
|
|
70
62
|
*/
|
|
71
63
|
vitest?: boolean;
|
|
72
64
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
65
|
+
* Controls [Cypress plugin](https://www.npmjs.com/package/eslint-plugin-cypress).
|
|
66
|
+
* @default true - If you have `cypress` in your dependencies.
|
|
75
67
|
*/
|
|
76
68
|
cypress?: boolean;
|
|
77
69
|
/**
|
|
70
|
+
* Controls [Storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
78
71
|
* @default true if you have `storybook` in your dependencies.
|
|
79
|
-
* Controls [storybook plugin](https://www.npmjs.com/package/eslint-plugin-storybook).
|
|
80
72
|
*/
|
|
81
73
|
storybook?: boolean;
|
|
82
74
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
75
|
+
* Controls [Prettier plugin](https://www.npmjs.com/package/eslint-plugin-prettier).
|
|
76
|
+
* @default true - If you have `prettier` in your dependencies.
|
|
85
77
|
*/
|
|
86
78
|
prettier?: boolean;
|
|
87
79
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
80
|
+
* Controls [Playwright plugin](https://www.npmjs.com/package/eslint-plugin-playwright).
|
|
81
|
+
* @default true - If you have `playwright` in your dependencies.
|
|
90
82
|
*/
|
|
91
83
|
playwright?: boolean;
|
|
92
84
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
85
|
+
* Controls [TypeScript plugin](https://www.npmjs.com/package/typescript-eslint).
|
|
86
|
+
* @default true - If you have `typescript` in your dependencies.
|
|
95
87
|
*/
|
|
96
88
|
typescript?: { projectService?: boolean | ProjectService; tsconfigRootDir: string; cacheLifetime?: number };
|
|
97
89
|
/**
|
|
98
|
-
* @default false
|
|
99
90
|
* Disables expensive rules.
|
|
91
|
+
* @default false
|
|
100
92
|
*/
|
|
101
93
|
disableExpensiveRules?: boolean;
|
|
102
94
|
/**
|
|
95
|
+
* List of globs to ignore
|
|
103
96
|
* @default []
|
|
104
|
-
* List of globs to ignore.
|
|
105
97
|
*/
|
|
106
98
|
ignores?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* .gitignore file path relative to ESLint configuration file. Set to `false` to disable.
|
|
101
|
+
* @default './.gitignore'
|
|
102
|
+
*/
|
|
103
|
+
gitignore?: string | false;
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
export declare function defineConfig(initOptions?: Options, ...extend: Linter.Config[]): Linter.Config[];
|
package/src/index.mjs
CHANGED
|
@@ -33,6 +33,7 @@ const defaultOptions = {
|
|
|
33
33
|
disableExpensiveRules: false,
|
|
34
34
|
esm: false,
|
|
35
35
|
ignores: [],
|
|
36
|
+
gitignore: './.gitignore',
|
|
36
37
|
import: {},
|
|
37
38
|
jest: isPackageExists('jest'),
|
|
38
39
|
next: isPackageExists('next'),
|
|
@@ -43,7 +44,7 @@ const defaultOptions = {
|
|
|
43
44
|
react: isPackageExists('react'),
|
|
44
45
|
storybook: isPackageExists('storybook'),
|
|
45
46
|
strict: false,
|
|
46
|
-
tailwind: false,
|
|
47
|
+
tailwind: false, // ISSUE: https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/325,
|
|
47
48
|
test: testPackages.some(p => isPackageExists(p)),
|
|
48
49
|
typescript: isPackageExists('typescript') ? { projectService: true } : false,
|
|
49
50
|
vitest: isPackageExists('vitest'),
|
|
@@ -58,6 +59,9 @@ const defaultOptions = {
|
|
|
58
59
|
export function defineConfig(initOptions = {}, ...extend) {
|
|
59
60
|
const options = merge(defaultOptions, initOptions);
|
|
60
61
|
|
|
62
|
+
if (options.tailwind === true) {
|
|
63
|
+
options.tailwind = {};
|
|
64
|
+
}
|
|
61
65
|
if (options.import === true) {
|
|
62
66
|
options.import = {};
|
|
63
67
|
}
|
|
@@ -68,6 +72,7 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
68
72
|
disableExpensiveRules,
|
|
69
73
|
esm: enableEsm,
|
|
70
74
|
ignores: enableIgnores,
|
|
75
|
+
gitignore,
|
|
71
76
|
import: enableImport,
|
|
72
77
|
jest: enableJest,
|
|
73
78
|
next: enableNext,
|
|
@@ -106,3 +111,6 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
106
111
|
|
|
107
112
|
return eslintConfig(rules);
|
|
108
113
|
}
|
|
114
|
+
|
|
115
|
+
/** @deprecated Please use `defineConfig` from `@fullstacksjs/eslint-config` instead, this function will be removed in the next major release. */
|
|
116
|
+
export const init = defineConfig;
|
package/src/modules/base.mjs
CHANGED
package/src/modules/ignore.mjs
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { globalIgnores } from 'eslint/config';
|
|
2
2
|
|
|
3
|
+
import { getGitignorePatterns } from '../utils/getGitignorePatterns.mjs';
|
|
3
4
|
import { ignoreGlobs } from '../utils/globs.mjs';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* @param { import('..').Options } options
|
|
6
8
|
* @return { import('eslint').Linter.Config }
|
|
7
9
|
*/
|
|
8
10
|
function ignores(options = {}) {
|
|
9
|
-
|
|
11
|
+
const ignorePatterns = [...ignoreGlobs, ...(options.ignores ?? [])];
|
|
12
|
+
|
|
13
|
+
const shouldUseGitignore = options.gitignore && options.gitignore.length > 0;
|
|
14
|
+
if (shouldUseGitignore) {
|
|
15
|
+
const gitignorePatterns = getGitignorePatterns(options.gitignore);
|
|
16
|
+
if (gitignorePatterns.length > 0) {
|
|
17
|
+
ignorePatterns.push(...gitignorePatterns);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const uniqueIgnorePatterns = [...new Set(ignorePatterns)];
|
|
22
|
+
|
|
23
|
+
return globalIgnores(uniqueIgnorePatterns, 'ignores');
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
export default ignores;
|
package/src/modules/tailwind.mjs
CHANGED
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
* @return { Promise<import('eslint').Linter.Config> }
|
|
4
4
|
*/
|
|
5
5
|
async function tailwind(options = {}) {
|
|
6
|
-
const plugin = await import('eslint-plugin-
|
|
6
|
+
const plugin = await import('eslint-plugin-tailwindcss');
|
|
7
7
|
return {
|
|
8
|
-
plugins: {
|
|
8
|
+
plugins: { tailwindcss: plugin.default ?? plugin },
|
|
9
9
|
settings: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
tailwindConfig: options.tailwindConfig,
|
|
10
|
+
tailwindcss: {
|
|
11
|
+
callees: options.callees ?? ['cva', 'classnames', 'classNames', 'class', 'clsx', 'cn', 'cns', 'cx'],
|
|
13
12
|
},
|
|
14
13
|
},
|
|
15
14
|
rules: {
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
15
|
+
'tailwindcss/classnames-order': 'warn',
|
|
16
|
+
'tailwindcss/enforces-negative-arbitrary-values': 'warn',
|
|
17
|
+
'tailwindcss/enforces-shorthand': 'warn',
|
|
18
|
+
'tailwindcss/migration-from-tailwind-2': 'warn',
|
|
19
|
+
'tailwindcss/no-arbitrary-value': 'off',
|
|
20
|
+
'tailwindcss/no-custom-classname': 'warn',
|
|
21
|
+
'tailwindcss/no-contradicting-classname': 'error',
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint 'no-console': ['warn', { allow: ['warn'] }] */
|
|
2
|
+
|
|
3
|
+
import { includeIgnoreFile } from '@eslint/compat';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
|
|
7
|
+
const warningMessage = '\u001B[38;2;229;229;14mWarning:\u001B[0m';
|
|
8
|
+
const fallbackMessage =
|
|
9
|
+
'Falling back to default ignore patterns. You can suppress this warning by setting \u001B[48;5;234m`gitignore: false`\u001B[0m in the config.';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} gitignorePath relative path to the .gitignore file
|
|
13
|
+
* @returns {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export function getGitignorePatterns(gitignorePath) {
|
|
16
|
+
const gitignoreAbsolutePath = path.resolve(process.cwd(), gitignorePath);
|
|
17
|
+
const gitignoreExists = fs.existsSync(gitignoreAbsolutePath); // eslint-disable-line n/no-sync
|
|
18
|
+
const gitignorePatterns = [];
|
|
19
|
+
|
|
20
|
+
if (!gitignoreExists) {
|
|
21
|
+
console.warn(warningMessage, `No .gitignore file found at "${gitignoreAbsolutePath}".`, fallbackMessage);
|
|
22
|
+
|
|
23
|
+
return gitignorePatterns;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ignorePatterns = includeIgnoreFile(gitignoreAbsolutePath).ignores ?? [];
|
|
27
|
+
|
|
28
|
+
if (ignorePatterns.length > 0) {
|
|
29
|
+
gitignorePatterns.push(...ignorePatterns);
|
|
30
|
+
} else {
|
|
31
|
+
console.warn(warningMessage, `No patterns found in .gitignore file at "${gitignoreAbsolutePath}".`, fallbackMessage);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return gitignorePatterns;
|
|
35
|
+
}
|