@soujvnunes/eslint-config 0.3.1 → 0.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 +8 -7
- package/dist/index.d.ts +10 -1
- package/dist/index.js +13 -2
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @soujvnunes/eslint-config
|
|
2
2
|
|
|
3
|
-
Shared flat ESLint config as factories.
|
|
3
|
+
Shared flat ESLint config as factories. It bundles the plugin set (typescript-eslint, import-x, import-helpers, unused-imports, security, and for the Next preset react, react-hooks, jsx-a11y, `@next/next`), so you only bring `eslint` and `typescript`. The Next preset also bundles the TypeScript import resolver (`eslint-import-resolver-typescript`, wired via `import-x/resolver-next`), so `@/...` path aliases and `.d.ts` types resolve out of the box, with no extra install and no `settings` wiring.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -11,11 +11,11 @@ pnpm add -D @soujvnunes/eslint-config eslint typescript
|
|
|
11
11
|
## Use
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
// eslint.config.mjs
|
|
14
|
+
// eslint.config.mjs, a Next.js app
|
|
15
15
|
import { createNextConfig } from '@soujvnunes/eslint-config'
|
|
16
16
|
|
|
17
17
|
export default createNextConfig({
|
|
18
|
-
// project-specific import-order groups (skeleton is react
|
|
18
|
+
// project-specific import-order groups (skeleton is react, next, module, parent, sibling, index)
|
|
19
19
|
importGroups: [
|
|
20
20
|
'/^react/',
|
|
21
21
|
'/^next/',
|
|
@@ -31,7 +31,7 @@ export default createNextConfig({
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
|
-
// eslint.config.mjs
|
|
34
|
+
// eslint.config.mjs, a TypeScript library
|
|
35
35
|
import { createBaseConfig } from '@soujvnunes/eslint-config'
|
|
36
36
|
|
|
37
37
|
export default createBaseConfig()
|
|
@@ -41,9 +41,10 @@ export default createBaseConfig()
|
|
|
41
41
|
|
|
42
42
|
| Option | Default | Purpose |
|
|
43
43
|
| --- | --- | --- |
|
|
44
|
-
| `importGroups` | react
|
|
45
|
-
| `ignores` |
|
|
44
|
+
| `importGroups` | react, next, module, parent, sibling, index | Full import-order groups; insert your `@/...` paths |
|
|
45
|
+
| `ignores` | (none) | Extra ignore globs, merged after the built-in defaults |
|
|
46
46
|
| `tsconfigRootDir` | `process.cwd()` | Root for typescript-eslint's project service |
|
|
47
|
+
| `tailwindEntryPoint` | (none) | Tailwind v4 CSS entry path. When set on the Next preset, wires `eslint-plugin-better-tailwindcss` correctness rules such as `no-unknown-classes`, which flags a class not registered in the theme |
|
|
47
48
|
| `extend` | `[]` | Extra flat-config objects appended at the end |
|
|
48
49
|
|
|
49
|
-
Type-aware rules use typescript-eslint's **project service**, so no `parserOptions.project` wiring is needed
|
|
50
|
+
Type-aware rules use typescript-eslint's **project service**, so no `parserOptions.project` wiring is needed. It discovers the nearest `tsconfig.json` per file.
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,21 @@ interface ConfigOptions {
|
|
|
7
7
|
importGroups?: (string | string[])[];
|
|
8
8
|
/** Root for typescript-eslint's project service. Defaults to cwd. */
|
|
9
9
|
tsconfigRootDir?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Path to the Tailwind v4 CSS entry (the file with `@import "tailwindcss"` + `@theme`, e.g.
|
|
12
|
+
* `./app/tailwind.config.css`). When set on the Next preset, it wires the bundled
|
|
13
|
+
* `eslint-plugin-better-tailwindcss` correctness rules, chiefly `no-unknown-classes`, which flags a
|
|
14
|
+
* class not registered in the theme (a dead token `tsc`/build cannot see; see DESIGN-TOKENS). Leave it
|
|
15
|
+
* unset and the plugin stays off, since without the entry the rule cannot resolve the theme and would
|
|
16
|
+
* flag every class.
|
|
17
|
+
*/
|
|
18
|
+
tailwindEntryPoint?: string;
|
|
10
19
|
/** Extra flat-config objects appended at the end. */
|
|
11
20
|
extend?: Linter.Config[];
|
|
12
21
|
}
|
|
13
22
|
/** Base config for TypeScript libraries (no React/Next layers). */
|
|
14
23
|
declare const createBaseConfig: (options?: ConfigOptions) => any[];
|
|
15
|
-
/** Full config for Next.js apps
|
|
24
|
+
/** Full config for Next.js apps: base plus React, React Hooks, jsx-a11y and Next plugins. */
|
|
16
25
|
declare const createNextConfig: (options?: ConfigOptions) => any[];
|
|
17
26
|
|
|
18
27
|
export { type ConfigOptions, createBaseConfig, createNextConfig };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import js from "@eslint/js";
|
|
|
3
3
|
import nextPlugin from "@next/eslint-plugin-next";
|
|
4
4
|
import prettier from "eslint-config-prettier";
|
|
5
5
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
6
|
+
import betterTailwind from "eslint-plugin-better-tailwindcss";
|
|
6
7
|
import importHelpers from "eslint-plugin-import-helpers";
|
|
7
8
|
import importXPlugin from "eslint-plugin-import-x";
|
|
8
9
|
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
@@ -153,11 +154,11 @@ var restrictedSyntaxRule = {
|
|
|
153
154
|
},
|
|
154
155
|
{
|
|
155
156
|
selector: "ImportDeclaration[source.value='react'] > ImportDefaultSpecifier",
|
|
156
|
-
message: "Do not import the React default
|
|
157
|
+
message: "Do not import the React default. Use the ambient `React.*` namespace (the react-jsx runtime needs no React import)."
|
|
157
158
|
},
|
|
158
159
|
{
|
|
159
160
|
selector: "ImportDeclaration[source.value='react'] > ImportNamespaceSpecifier",
|
|
160
|
-
message: "Do not `import * as React
|
|
161
|
+
message: "Do not `import * as React`. Use the ambient `React.*` namespace."
|
|
161
162
|
},
|
|
162
163
|
{
|
|
163
164
|
selector: "ImportDeclaration[source.value='react'] > ImportSpecifier[importKind='type']",
|
|
@@ -203,6 +204,7 @@ var buildConfig = ({
|
|
|
203
204
|
ignores = [],
|
|
204
205
|
importGroups = DEFAULT_IMPORT_GROUPS,
|
|
205
206
|
tsconfigRootDir = process.cwd(),
|
|
207
|
+
tailwindEntryPoint,
|
|
206
208
|
extend = []
|
|
207
209
|
} = {}) => {
|
|
208
210
|
const plugins = {
|
|
@@ -236,6 +238,15 @@ var buildConfig = ({
|
|
|
236
238
|
});
|
|
237
239
|
settings.react = { version: "detect" };
|
|
238
240
|
settings["import-x/resolver-next"] = [createTypeScriptImportResolver({ alwaysTryTypes: true })];
|
|
241
|
+
if (tailwindEntryPoint) {
|
|
242
|
+
plugins["better-tailwindcss"] = betterTailwind;
|
|
243
|
+
Object.assign(rules, {
|
|
244
|
+
"better-tailwindcss/no-unknown-classes": "error",
|
|
245
|
+
"better-tailwindcss/no-conflicting-classes": "error",
|
|
246
|
+
"better-tailwindcss/no-concatenated-classes": "error"
|
|
247
|
+
});
|
|
248
|
+
settings["better-tailwindcss"] = { entryPoint: tailwindEntryPoint };
|
|
249
|
+
}
|
|
239
250
|
}
|
|
240
251
|
const rootConfigOverride = {
|
|
241
252
|
files: ["*.{mjs,js,ts,mts,cts}"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soujvnunes/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Shared flat ESLint config factories (base + Next.js).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "soujvnunes",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@next/eslint-plugin-next": "^16.2.2",
|
|
41
41
|
"eslint-config-prettier": "^10.1.8",
|
|
42
42
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
43
|
+
"eslint-plugin-better-tailwindcss": "^4.7.0",
|
|
43
44
|
"eslint-plugin-import-helpers": "^2.0.1",
|
|
44
45
|
"eslint-plugin-import-x": "^4.16.2",
|
|
45
46
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
@@ -52,10 +53,17 @@
|
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
55
|
"eslint": ">=9",
|
|
56
|
+
"tailwindcss": ">=3.3",
|
|
55
57
|
"typescript": ">=5.4"
|
|
56
58
|
},
|
|
59
|
+
"peerDependenciesMeta": {
|
|
60
|
+
"tailwindcss": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
57
64
|
"devDependencies": {
|
|
58
|
-
"@types/node": "^20.19.39"
|
|
65
|
+
"@types/node": "^20.19.39",
|
|
66
|
+
"tailwindcss": "^4.2.2"
|
|
59
67
|
},
|
|
60
68
|
"publishConfig": {
|
|
61
69
|
"access": "public"
|