@fullstacksjs/eslint-config 12.4.0 → 12.4.2-next.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 +30 -2
- package/cjs/index.d.ts +12 -4
- package/cjs/index.js +2 -10
- package/cjs/modules/base.js +1 -1
- package/cjs/modules/ignore.js +11 -6
- package/cjs/modules/tailwind.js +13 -11
- package/cjs/utils/getGitignorePatterns.js +35 -0
- package/package.json +3 -3
- package/src/index.d.ts +12 -4
- package/src/index.mjs +3 -9
- package/src/modules/base.mjs +1 -1
- package/src/modules/ignore.mjs +14 -5
- package/src/modules/tailwind.mjs +11 -11
- package/src/utils/getGitignorePatterns.mjs +35 -0
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ 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?: false | TailwindConfig; // controls tailwindcss plugin
|
|
73
73
|
next?: boolean; // controls next plugin
|
|
74
74
|
prettier?: boolean; // controls prettier plugin
|
|
75
75
|
disableExpensiveRules?: boolean; // controls expensive rules
|
|
@@ -115,6 +115,34 @@ export default defineConfig(
|
|
|
115
115
|
)
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
## Tailwind
|
|
119
|
+
|
|
120
|
+
To enable Tailwind CSS in your project, specify the path to your CSS file in the module configuration:
|
|
121
|
+
|
|
122
|
+
Tailwind 4:
|
|
123
|
+
```typescript
|
|
124
|
+
export default defineConfig({
|
|
125
|
+
tailwind: { entryPoint: './src/global.css' },
|
|
126
|
+
})
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Tailwind 3:
|
|
130
|
+
```typescript
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
tailwind: { tailwindConfig: './tailwind.config.js' },
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## GitIgnore
|
|
137
|
+
|
|
138
|
+
By default, FullstacksJS checks for a `.gitignore` file at the root of the project. If the file exists, it will be used automatically. You can override this behavior by updating the configuration.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
gitignore: './packages/acme/.gitignore', // use `false` to disable
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
118
146
|
## I'm Getting a Next.js Warning: Plugin Was Not Detected
|
|
119
147
|
|
|
120
148
|
This configuration includes built-in support for [Next.js](https://nextjs.org). The warning you're seeing from Next.js is misleading—it simply checks whether the plugin is explicitly listed in your package.json.
|
|
@@ -178,7 +206,7 @@ export default defineConfig({
|
|
|
178
206
|
* [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)
|
|
179
207
|
* [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
|
|
180
208
|
* [eslint-plugin-storybook](https://github.com/storybookjs/eslint-plugin-storybook#readme)
|
|
181
|
-
* [eslint-plugin-tailwindcss](https://github.com/
|
|
209
|
+
* [eslint-plugin-better-tailwindcss](https://github.com/schoero/eslint-plugin-better-tailwindcss)
|
|
182
210
|
* [eslint-plugin-vitest](https://www.npmjs.com/package/eslint-plugin-vitest)
|
|
183
211
|
* [typescript-eslint](https://typescript-eslint.io/)
|
|
184
212
|
|
package/cjs/index.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ 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
|
+
|
|
10
17
|
export interface Options extends Linter.Config {
|
|
11
18
|
/**
|
|
12
19
|
* Controls React plugin.
|
|
@@ -24,9 +31,10 @@ export interface Options extends Linter.Config {
|
|
|
24
31
|
next?: boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Controls Tailwind plugin.
|
|
27
|
-
* @default
|
|
34
|
+
* @default false
|
|
35
|
+
* @see https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md
|
|
28
36
|
*/
|
|
29
|
-
tailwind?:
|
|
37
|
+
tailwind?: false | TailwindConfig;
|
|
30
38
|
/**
|
|
31
39
|
* Controls [Node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
32
40
|
* @default false
|
|
@@ -97,10 +105,10 @@ export interface Options extends Linter.Config {
|
|
|
97
105
|
*/
|
|
98
106
|
ignores?: string[];
|
|
99
107
|
/**
|
|
100
|
-
* .gitignore file path relative to ESLint configuration file.
|
|
108
|
+
* .gitignore file path relative to ESLint configuration file. Set to `false` to disable.
|
|
101
109
|
* @default './.gitignore'
|
|
102
110
|
*/
|
|
103
|
-
|
|
111
|
+
gitignore?: string | false;
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
export declare function defineConfig(initOptions?: Options, ...extend: Linter.Config[]): Linter.Config[];
|
package/cjs/index.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defineConfig = defineConfig;
|
|
7
|
-
exports.init = void 0;
|
|
8
7
|
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
9
8
|
var _config = require("eslint/config");
|
|
10
9
|
var _localPkg = require("local-pkg");
|
|
@@ -39,7 +38,7 @@ const defaultOptions = {
|
|
|
39
38
|
disableExpensiveRules: false,
|
|
40
39
|
esm: false,
|
|
41
40
|
ignores: [],
|
|
42
|
-
|
|
41
|
+
gitignore: './.gitignore',
|
|
43
42
|
import: {},
|
|
44
43
|
jest: (0, _localPkg.isPackageExists)('jest'),
|
|
45
44
|
next: (0, _localPkg.isPackageExists)('next'),
|
|
@@ -51,7 +50,6 @@ const defaultOptions = {
|
|
|
51
50
|
storybook: (0, _localPkg.isPackageExists)('storybook'),
|
|
52
51
|
strict: false,
|
|
53
52
|
tailwind: false,
|
|
54
|
-
// ISSUE: https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/325,
|
|
55
53
|
test: testPackages.some(p => (0, _localPkg.isPackageExists)(p)),
|
|
56
54
|
typescript: (0, _localPkg.isPackageExists)('typescript') ? {
|
|
57
55
|
projectService: true
|
|
@@ -67,9 +65,6 @@ const defaultOptions = {
|
|
|
67
65
|
*/
|
|
68
66
|
function defineConfig(initOptions = {}, ...extend) {
|
|
69
67
|
const options = (0, _deepmerge.default)(defaultOptions, initOptions);
|
|
70
|
-
if (options.tailwind === true) {
|
|
71
|
-
options.tailwind = {};
|
|
72
|
-
}
|
|
73
68
|
if (options.import === true) {
|
|
74
69
|
options.import = {};
|
|
75
70
|
}
|
|
@@ -79,7 +74,7 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
79
74
|
disableExpensiveRules,
|
|
80
75
|
esm: enableEsm,
|
|
81
76
|
ignores: enableIgnores,
|
|
82
|
-
|
|
77
|
+
gitignore,
|
|
83
78
|
import: enableImport,
|
|
84
79
|
jest: enableJest,
|
|
85
80
|
next: enableNext,
|
|
@@ -114,6 +109,3 @@ function defineConfig(initOptions = {}, ...extend) {
|
|
|
114
109
|
if (extend) Array.prototype.push.apply(rules, extend);
|
|
115
110
|
return (0, _config.defineConfig)(rules);
|
|
116
111
|
}
|
|
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
|
@@ -4,18 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _compat = require("@eslint/compat");
|
|
8
7
|
var _config = require("eslint/config");
|
|
9
|
-
var
|
|
8
|
+
var _getGitignorePatterns = require("../utils/getGitignorePatterns.js");
|
|
10
9
|
var _globs = require("../utils/globs.js");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
10
|
/**
|
|
13
11
|
* @param { import('../index.js').Options } options
|
|
14
12
|
* @return { import('eslint').Linter.Config }
|
|
15
13
|
*/
|
|
16
14
|
function ignores(options = {}) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
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');
|
|
20
25
|
}
|
|
21
26
|
module.exports = ignores;
|
package/cjs/modules/tailwind.js
CHANGED
|
@@ -9,24 +9,26 @@ 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-tailwindcss'));
|
|
12
|
+
const plugin = await Promise.resolve().then(() => require('eslint-plugin-better-tailwindcss'));
|
|
13
13
|
return {
|
|
14
14
|
plugins: {
|
|
15
|
-
tailwindcss: plugin.default ?? plugin
|
|
15
|
+
'better-tailwindcss': plugin.default ?? plugin
|
|
16
16
|
},
|
|
17
17
|
settings: {
|
|
18
|
-
tailwindcss: {
|
|
19
|
-
|
|
18
|
+
'better-tailwindcss': {
|
|
19
|
+
entryPoint: options.tailwind.entryPoint,
|
|
20
|
+
tailwindConfig: options.tailwind.tailwindConfig
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
rules: {
|
|
23
|
-
'tailwindcss/
|
|
24
|
-
'tailwindcss/
|
|
25
|
-
'tailwindcss/
|
|
26
|
-
'tailwindcss/
|
|
27
|
-
'tailwindcss/
|
|
28
|
-
'tailwindcss/
|
|
29
|
-
|
|
24
|
+
'better-tailwindcss/sort-classes': 'warn',
|
|
25
|
+
'better-tailwindcss/no-duplicate-classes': 'error',
|
|
26
|
+
'better-tailwindcss/no-conflicting-classes': 'error',
|
|
27
|
+
'better-tailwindcss/no-unnecessary-whitespace': 'warn',
|
|
28
|
+
'better-tailwindcss/enforce-consistent-variable-syntax': 'error',
|
|
29
|
+
'better-tailwindcss/multiline': ['error', {
|
|
30
|
+
printWidth: 140
|
|
31
|
+
}]
|
|
30
32
|
}
|
|
31
33
|
};
|
|
32
34
|
}
|
|
@@ -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.4.
|
|
3
|
+
"version": "12.4.2-next.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",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@next/eslint-plugin-next": "15.3.2",
|
|
41
41
|
"@stylistic/eslint-plugin": "4.4.0",
|
|
42
42
|
"deepmerge": "4.3.1",
|
|
43
|
+
"eslint-plugin-better-tailwindcss": "3.2.1",
|
|
43
44
|
"eslint-plugin-cypress": "4.3.0",
|
|
44
45
|
"eslint-plugin-import-x": "4.13.3",
|
|
45
46
|
"eslint-plugin-jest": "28.11.0",
|
|
@@ -52,7 +53,6 @@
|
|
|
52
53
|
"eslint-plugin-promise": "7.2.1",
|
|
53
54
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
54
55
|
"eslint-plugin-storybook": "0.12.0",
|
|
55
|
-
"eslint-plugin-tailwindcss": "3.18.0",
|
|
56
56
|
"eslint-plugin-vitest": "0.5.4",
|
|
57
57
|
"globals": "16.2.0",
|
|
58
58
|
"local-pkg": "1.1.1",
|
package/src/index.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ 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
|
+
|
|
10
17
|
export interface Options extends Linter.Config {
|
|
11
18
|
/**
|
|
12
19
|
* Controls React plugin.
|
|
@@ -24,9 +31,10 @@ export interface Options extends Linter.Config {
|
|
|
24
31
|
next?: boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Controls Tailwind plugin.
|
|
27
|
-
* @default
|
|
34
|
+
* @default false
|
|
35
|
+
* @see https://github.com/schoero/eslint-plugin-better-tailwindcss/blob/main/docs/settings/settings.md
|
|
28
36
|
*/
|
|
29
|
-
tailwind?:
|
|
37
|
+
tailwind?: false | TailwindConfig;
|
|
30
38
|
/**
|
|
31
39
|
* Controls [Node plugin](https://www.npmjs.com/package/eslint-plugin-n).
|
|
32
40
|
* @default false
|
|
@@ -97,10 +105,10 @@ export interface Options extends Linter.Config {
|
|
|
97
105
|
*/
|
|
98
106
|
ignores?: string[];
|
|
99
107
|
/**
|
|
100
|
-
* .gitignore file path relative to ESLint configuration file.
|
|
108
|
+
* .gitignore file path relative to ESLint configuration file. Set to `false` to disable.
|
|
101
109
|
* @default './.gitignore'
|
|
102
110
|
*/
|
|
103
|
-
|
|
111
|
+
gitignore?: string | false;
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
export declare function defineConfig(initOptions?: Options, ...extend: Linter.Config[]): Linter.Config[];
|
package/src/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ const defaultOptions = {
|
|
|
33
33
|
disableExpensiveRules: false,
|
|
34
34
|
esm: false,
|
|
35
35
|
ignores: [],
|
|
36
|
-
|
|
36
|
+
gitignore: './.gitignore',
|
|
37
37
|
import: {},
|
|
38
38
|
jest: isPackageExists('jest'),
|
|
39
39
|
next: isPackageExists('next'),
|
|
@@ -44,7 +44,7 @@ const defaultOptions = {
|
|
|
44
44
|
react: isPackageExists('react'),
|
|
45
45
|
storybook: isPackageExists('storybook'),
|
|
46
46
|
strict: false,
|
|
47
|
-
tailwind: false,
|
|
47
|
+
tailwind: false,
|
|
48
48
|
test: testPackages.some(p => isPackageExists(p)),
|
|
49
49
|
typescript: isPackageExists('typescript') ? { projectService: true } : false,
|
|
50
50
|
vitest: isPackageExists('vitest'),
|
|
@@ -59,9 +59,6 @@ const defaultOptions = {
|
|
|
59
59
|
export function defineConfig(initOptions = {}, ...extend) {
|
|
60
60
|
const options = merge(defaultOptions, initOptions);
|
|
61
61
|
|
|
62
|
-
if (options.tailwind === true) {
|
|
63
|
-
options.tailwind = {};
|
|
64
|
-
}
|
|
65
62
|
if (options.import === true) {
|
|
66
63
|
options.import = {};
|
|
67
64
|
}
|
|
@@ -72,7 +69,7 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
72
69
|
disableExpensiveRules,
|
|
73
70
|
esm: enableEsm,
|
|
74
71
|
ignores: enableIgnores,
|
|
75
|
-
|
|
72
|
+
gitignore,
|
|
76
73
|
import: enableImport,
|
|
77
74
|
jest: enableJest,
|
|
78
75
|
next: enableNext,
|
|
@@ -111,6 +108,3 @@ export function defineConfig(initOptions = {}, ...extend) {
|
|
|
111
108
|
|
|
112
109
|
return eslintConfig(rules);
|
|
113
110
|
}
|
|
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,7 +1,6 @@
|
|
|
1
|
-
import { includeIgnoreFile } from '@eslint/compat';
|
|
2
1
|
import { globalIgnores } from 'eslint/config';
|
|
3
|
-
import path from 'node:path';
|
|
4
2
|
|
|
3
|
+
import { getGitignorePatterns } from '../utils/getGitignorePatterns.mjs';
|
|
5
4
|
import { ignoreGlobs } from '../utils/globs.mjs';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -9,9 +8,19 @@ import { ignoreGlobs } from '../utils/globs.mjs';
|
|
|
9
8
|
* @return { import('eslint').Linter.Config }
|
|
10
9
|
*/
|
|
11
10
|
function ignores(options = {}) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
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');
|
|
15
24
|
}
|
|
16
25
|
|
|
17
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-tailwindcss');
|
|
6
|
+
const plugin = await import('eslint-plugin-better-tailwindcss');
|
|
7
7
|
return {
|
|
8
|
-
plugins: { tailwindcss: plugin.default ?? plugin },
|
|
8
|
+
plugins: { 'better-tailwindcss': plugin.default ?? plugin },
|
|
9
9
|
settings: {
|
|
10
|
-
tailwindcss: {
|
|
11
|
-
|
|
10
|
+
'better-tailwindcss': {
|
|
11
|
+
entryPoint: options.tailwind.entryPoint,
|
|
12
|
+
tailwindConfig: options.tailwind.tailwindConfig,
|
|
12
13
|
},
|
|
13
14
|
},
|
|
14
15
|
rules: {
|
|
15
|
-
'tailwindcss/
|
|
16
|
-
'tailwindcss/
|
|
17
|
-
'tailwindcss/
|
|
18
|
-
'tailwindcss/
|
|
19
|
-
'tailwindcss/
|
|
20
|
-
'tailwindcss/
|
|
21
|
-
'tailwindcss/no-contradicting-classname': 'error',
|
|
16
|
+
'better-tailwindcss/sort-classes': 'warn',
|
|
17
|
+
'better-tailwindcss/no-duplicate-classes': 'error',
|
|
18
|
+
'better-tailwindcss/no-conflicting-classes': 'error',
|
|
19
|
+
'better-tailwindcss/no-unnecessary-whitespace': 'warn',
|
|
20
|
+
'better-tailwindcss/enforce-consistent-variable-syntax': 'error',
|
|
21
|
+
'better-tailwindcss/multiline': ['error', { printWidth: 140 }],
|
|
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
|
+
}
|