@soujvnunes/eslint-config 0.3.0 → 0.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @soujvnunes/eslint-config
2
2
 
3
- Shared flat ESLint config as factories. 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`); you only bring `eslint` + `typescript`.
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 — a Next.js app
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 → next → module → parent → sibling → index)
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 — a TypeScript library
34
+ // eslint.config.mjs, a TypeScript library
35
35
  import { createBaseConfig } from '@soujvnunes/eslint-config'
36
36
 
37
37
  export default createBaseConfig()
@@ -39,11 +39,12 @@ export default createBaseConfig()
39
39
 
40
40
  ## Options
41
41
 
42
- | Option | Default | Purpose |
43
- | ----------------- | ------------------------------------------------ | ------------------------------------------------------ |
44
- | `importGroups` | react → next → module → parent → sibling → index | Full import-order groups; insert your `@/…` paths |
45
- | `ignores` | — | Extra ignore globs, merged after the built-in defaults |
46
- | `tsconfigRootDir` | `process.cwd()` | Root for typescript-eslint's project service |
47
- | `extend` | `[]` | Extra flat-config objects appended at the end |
42
+ | Option | Default | Purpose |
43
+ | --- | --- | --- |
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
+ | `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 |
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 — it discovers the nearest `tsconfig.json` per file.
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 — base plus React, React Hooks, jsx-a11y and Next plugins. */
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 \u2014 use the ambient `React.*` namespace (the react-jsx runtime needs no React import)."
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` \u2014 use the ambient `React.*` namespace."
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,9 +1,23 @@
1
1
  {
2
2
  "name": "@soujvnunes/eslint-config",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Shared flat ESLint config factories (base + Next.js).",
5
5
  "license": "MIT",
6
6
  "author": "soujvnunes",
7
+ "keywords": [
8
+ "eslint",
9
+ "eslint-config",
10
+ "eslintconfig",
11
+ "flat-config",
12
+ "typescript",
13
+ "typescript-eslint",
14
+ "nextjs",
15
+ "react",
16
+ "import-order",
17
+ "prettier"
18
+ ],
19
+ "homepage": "https://github.com/soujvnunes/packages/tree/main/eslint-config#readme",
20
+ "bugs": "https://github.com/soujvnunes/packages/issues",
7
21
  "repository": {
8
22
  "type": "git",
9
23
  "url": "git+https://github.com/soujvnunes/packages.git",
@@ -26,6 +40,7 @@
26
40
  "@next/eslint-plugin-next": "^16.2.2",
27
41
  "eslint-config-prettier": "^10.1.8",
28
42
  "eslint-import-resolver-typescript": "^4.4.5",
43
+ "eslint-plugin-better-tailwindcss": "^4.7.0",
29
44
  "eslint-plugin-import-helpers": "^2.0.1",
30
45
  "eslint-plugin-import-x": "^4.16.2",
31
46
  "eslint-plugin-jsx-a11y": "^6.10.2",
@@ -38,10 +53,17 @@
38
53
  },
39
54
  "peerDependencies": {
40
55
  "eslint": ">=9",
56
+ "tailwindcss": ">=3.3",
41
57
  "typescript": ">=5.4"
42
58
  },
59
+ "peerDependenciesMeta": {
60
+ "tailwindcss": {
61
+ "optional": true
62
+ }
63
+ },
43
64
  "devDependencies": {
44
- "@types/node": "^20.19.39"
65
+ "@types/node": "^20.19.39",
66
+ "tailwindcss": "^4.2.2"
45
67
  },
46
68
  "publishConfig": {
47
69
  "access": "public"