@codfish/eslint-config 0.0.0-PR-124--a65acf5 → 0.0.0-PR-124--0da7f69

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,7 @@
1
1
  # @codfish/eslint-config
2
2
 
3
- > Modern ESLint configuration with TypeScript, React, and testing framework support using ESLint v9+ flat config format.
3
+ > Modern ESLint configuration with TypeScript, React/Next.js, Tailwind CSS, YAML, Testing Library, and testing framework
4
+ > support using ESLint v9+ flat config format.
4
5
 
5
6
  [![version](https://img.shields.io/npm/v/@codfish/eslint-config.svg)](http://npm.im/@codfish/eslint-config)
6
7
  [![downloads](https://img.shields.io/npm/dm/@codfish/eslint-config.svg)](http://npm-stat.com/charts.html?package=@codfish/eslint-config&from=2015-08-01)
@@ -8,22 +9,26 @@
8
9
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
9
10
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
10
11
 
12
+ <!-- prettier-ignore-start -->
11
13
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
12
14
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
13
15
  ## Table of Contents
14
16
 
15
17
  - [Features](#features)
16
18
  - [Automatic Configuration](#automatic-configuration)
19
+ - [Opinionated Highlights](#opinionated-highlights)
17
20
  - [Installation](#installation)
18
21
  - [Usage](#usage)
19
- - [Prettier](#prettier)
20
- - [With dApps](#with-dapps)
21
22
  - [Docker Configuration](#docker-configuration)
22
- - [Blockchain/dApp Configuration](#blockchaindapp-configuration)
23
+ - [dApps Configuration](#dapps-configuration)
24
+ - [Prettier Configuration](#prettier-configuration)
25
+ - [Example scripts](#example-scripts)
26
+ - [Commitlint Configuration](#commitlint-configuration)
23
27
  - [Known issues](#known-issues)
24
28
  - [Migration from Legacy Config](#migration-from-legacy-config)
25
29
 
26
30
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
31
+ <!-- prettier-ignore-end -->
27
32
 
28
33
  ## Features
29
34
 
@@ -31,7 +36,11 @@
31
36
  - **Dynamic feature detection**: Automatically configures based on your project's dependencies
32
37
  - **TypeScript support**: Full TypeScript linting with modern typescript-eslint parser and rules
33
38
  - **React ecosystem**: React, React Hooks, and JSX accessibility rules when React is detected
39
+ - **Next.js support**: Automatically configures Next.js official plugin linting rules when detected
34
40
  - **Test framework agnostic**: Supports Jest and Vitest with automatic detection
41
+ - **Testing Library integration**: Automatically includes Testing Library rules for test files
42
+ - **Tailwind CSS support**: Automatically configures Tailwind CSS linting when detected
43
+ - **YAML/YML support**: Built-in linting for YAML configuration files
35
44
  - **Prettier integration**: Built-in Prettier configuration with conflict resolution via eslint-config-prettier
36
45
  - **ESM architecture**: Built with ECMAScript modules and full TypeScript typing
37
46
  - **Docker support**: Optional configuration for dockerized applications
@@ -42,16 +51,52 @@
42
51
  The config automatically detects and configures:
43
52
 
44
53
  - **React**: Includes React, React Hooks, and JSX a11y rules when `react` is installed
54
+ - **Next.js**: Includes Next.js recommended and Core Web Vitals rules when `next` is detected
45
55
  - **Jest**: Configures Jest-specific rules when `jest` is found in dependencies
46
56
  - **Vitest**: Configures Vitest-specific rules when `vitest` is detected
47
- - **Prettier**: Loads your project's Prettier config or falls back to built-in defaults
57
+ - **Testing Library**: Automatically adds Testing Library rules for test files in Jest/Vitest projects
58
+ - **Tailwind CSS**: Includes Tailwind CSS linting rules when `tailwindcss` is detected
59
+ - **YAML files**: Always includes YAML/YML file linting support
60
+ - **Prettier**: Loads your project's Prettier config or falls back to [my defaults](./prettier.js)
61
+
62
+ ### Opinionated Highlights
63
+
64
+ This configuration includes some opinionated settings that you might want to customize for your project:
65
+
66
+ **Prettier/Formatting:**
67
+
68
+ - **Semicolons**: Enforces semicolons (`;`)
69
+ - **120 character line width**: Wider than the common 80/100 - you might prefer shorter lines
70
+ - **2-space indentation**: Uses 2 spaces for tabs
71
+ - **Single quotes**: Prefers `'single'` over `"double"` quotes
72
+ - **Trailing commas**: Adds trailing commas everywhere
73
+ - **Arrow parentheses**: Avoids parens around single args (`x => x` not `(x) => x`)
74
+
75
+ **ESLint Rules:**
76
+
77
+ - **Import sorting**: Enforces automatic import organization with specific grouping rules
78
+ - **Lodash restrictions**: Requires direct imports (`import get from 'lodash-es/get'`) instead of full lodash
79
+ - **React hooks deps**: Disables `exhaustive-deps` rule - you might want this stricter
80
+ - **Console statements**: Disallows `console.log` in regular code (only allowed in test files) - some teams prefer
81
+ warnings instead of errors
82
+ - **Next.js rules**: Enforces Next.js best practices and Core Web Vitals optimization
83
+ - **Tailwind class sorting**: Automatically sorts Tailwind classes (can break dynamic class builds - see Known Issues)
84
+ - **Testing Library rules**: Enforces Testing Library best practices in test files
85
+
86
+ **File Ignores:**
87
+
88
+ - Ignores common build directories (`.next`, `coverage`, `.vercel`, etc.)
89
+ - Includes `.github` and `.vitepress` folders (not ignored like most configs)
90
+
91
+ See the [configuration examples below](#usage) for instructions on overriding these settings to match your team's
92
+ preferences.
48
93
 
49
94
  ## Installation
50
95
 
51
96
  Install the package and required peer dependencies:
52
97
 
53
98
  ```sh
54
- npm i -D @codfish/eslint-config eslint@9
99
+ npm i -D eslint@9 @codfish/eslint-config
55
100
  ```
56
101
 
57
102
  ## Usage
@@ -62,54 +107,89 @@ Create an `eslint.config.js` file in your project root:
62
107
  import { defineConfig } from 'eslint/config';
63
108
  import codfish from '@codfish/eslint-config';
64
109
 
65
- export default defineConfig([
110
+ export default defineConfig(
111
+ codfish,
112
+
66
113
  {
67
- files: ['**/*.{js,jsx,ts,tsx}'],
68
- extends: [codfish],
69
- // Your overrides here
114
+ rules: {
115
+ // Relax some rules for your project
116
+ 'react/prop-types': 'off',
117
+ 'import/prefer-default-export': 'off',
118
+ '@typescript-eslint/explicit-function-return-type': 'warn',
119
+ },
70
120
  },
71
- ]);
121
+ );
72
122
  ```
73
123
 
74
124
  > [!IMPORTANT] If you get ES module errors, you may need to set the `type` field in your `package.json` to `module` or
75
125
  > rename your config file to `eslint.config.mjs`.
76
126
 
77
- ### Prettier
78
-
79
- Prettier is automatically run through eslint with the [default configuration](./prettier.js). You can optionally add a
80
- prettier configuration file in the root of your project and it will take precedence over the
81
- [built-in config](./prettier.js). You can also choose to extend the Prettier config:
82
-
83
- **prettier.config.js**
127
+ Not using the `defineConfig` function, just spread the config object:
84
128
 
85
129
  ```js
86
- import codfishConfig from '@codfish/eslint-config/prettier.js';
130
+ import codfish from '@codfish/eslint-config';
87
131
 
88
- /**
89
- * @see https://prettier.io/docs/en/configuration.html
90
- * @type {import("prettier").Config}
91
- */
92
- const config = {
93
- ...codfishConfig,
94
- // your overrides here
95
- };
132
+ export default [
133
+ ...codfish,
96
134
 
97
- export default config;
135
+ {
136
+ // Your project-specific overrides
137
+ rules: {
138
+ // Override or add specific rules
139
+ 'no-console': 'warn',
140
+ '@typescript-eslint/no-unused-vars': 'error',
141
+ },
142
+ },
143
+ ];
98
144
  ```
99
145
 
100
- ### With dApps
146
+ **Use the config without any overrides:**
101
147
 
102
- Similar to the issues with docker, there may be rules you want to adjust for dApp's. This config will set some globals
103
- as well as ignore missing build artifact imports. While you obviously need those to run your app, sometimes you might
104
- want to run the linter in a ci/cd environment and build artifacts might not be present.
148
+ ```js
149
+ import codfish from '@codfish/eslint-config';
105
150
 
106
- **Note**: The dApp config also includes the `import/no-unresolved` rule found in the docker config.
151
+ export default codfish;
152
+ ```
107
153
 
108
- You can also directly import the Prettier config:
154
+ **Framework-specific customizations:**
109
155
 
110
156
  ```js
111
- import prettierConfig from '@codfish/eslint-config/prettier';
112
- export default prettierConfig;
157
+ import { defineConfig } from 'eslint/config';
158
+ import codfish from '@codfish/eslint-config';
159
+
160
+ export default defineConfig(
161
+ codfish,
162
+
163
+ {
164
+ files: ['**/*.spec.{js,ts,jsx,tsx}'],
165
+ rules: {
166
+ // Allow any in test files
167
+ '@typescript-eslint/no-explicit-any': 'off',
168
+ // Relax Testing Library rules if needed
169
+ 'testing-library/prefer-screen-queries': 'warn',
170
+ },
171
+ },
172
+
173
+ {
174
+ files: ['**/*.config.{js,ts}'],
175
+ rules: {
176
+ // Allow require in config files
177
+ '@typescript-eslint/no-require-imports': 'off',
178
+ },
179
+ },
180
+
181
+ {
182
+ files: ['**/*.{js,jsx,ts,tsx}'],
183
+ rules: {
184
+ // Customize Tailwind CSS rules
185
+ 'tailwindcss/classnames-order': 'warn',
186
+ 'tailwindcss/no-custom-classname': 'off',
187
+ // Customize Next.js rules
188
+ '@next/next/no-img-element': 'warn',
189
+ '@next/next/no-html-link-for-pages': 'off',
190
+ },
191
+ },
192
+ );
113
193
  ```
114
194
 
115
195
  ### Docker Configuration
@@ -131,22 +211,17 @@ export default defineConfig(
131
211
  );
132
212
  ```
133
213
 
134
- ### Blockchain/dApp Configuration
135
-
136
- For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config:
214
+ ### dApps Configuration
137
215
 
138
- ```js
139
- import codfish from '@codfish/eslint-config';
140
- import dappConfig from '@codfish/eslint-config/dapp';
216
+ For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config. This
217
+ config will set some globals as well as ignore missing build artifact imports. While you obviously need those to run
218
+ your app, sometimes you might want to run the linter in a ci/cd environment and build artifacts might not be present.
141
219
 
142
- export default defineConfig(
143
- codfish,
144
- dapp,
220
+ You can also directly import the Prettier config:
145
221
 
146
- {
147
- // Your app-specific overrides
148
- },
149
- );
222
+ ```js
223
+ import prettierConfig from '@codfish/eslint-config/prettier';
224
+ export default prettierConfig;
150
225
  ```
151
226
 
152
227
  The dApp configuration provides:
@@ -155,6 +230,166 @@ The dApp configuration provides:
155
230
  - Import resolution handling for smart contract build artifacts
156
231
  - Relaxed rules for generated contract files
157
232
 
233
+ ## Prettier Configuration
234
+
235
+ **Prettier is included and runs automatically** through ESLint for JavaScript, TypeScript, JSX, and TSX files using the
236
+ [built-in configuration](./prettier.js). **You don't need to install or configure Prettier separately** for basic usage.
237
+
238
+ However, if you want to format other file types (like Markdown, JSON, CSS, or YAML) or run Prettier directly, you can
239
+ install it as a dev dependency:
240
+
241
+ ```sh
242
+ npm i -D prettier
243
+ ```
244
+
245
+ You can then override the defaults by creating your own Prettier config file, or extend the built-in config:
246
+
247
+ **Option 1: Extend the built-in config (Recommended)**
248
+
249
+ Create a `prettier.config.js` file in your project root:
250
+
251
+ ```js
252
+ // prettier.config.js
253
+
254
+ import codfishConfig from '@codfish/eslint-config/prettier';
255
+
256
+ /**
257
+ * @see https://prettier.io/docs/en/configuration.html
258
+ * @type {import("prettier").Config}
259
+ */
260
+ export default {
261
+ ...codfishConfig,
262
+
263
+ // Override specific settings
264
+ printWidth: 80,
265
+ singleQuote: false,
266
+ tabWidth: 4,
267
+ trailingComma: 'none',
268
+ };
269
+ ```
270
+
271
+ **Option 2: Completely custom config**
272
+
273
+ This config will completely override the built-in config.
274
+
275
+ ```js
276
+ // prettier.config.js
277
+
278
+ /**
279
+ * @see https://prettier.io/docs/en/configuration.html
280
+ * @type {import("prettier").Config}
281
+ */
282
+ export default {
283
+ printWidth: 100,
284
+ tabWidth: 2,
285
+ useTabs: false,
286
+ semi: true,
287
+ singleQuote: true,
288
+ trailingComma: 'all',
289
+ bracketSpacing: true,
290
+ bracketSameLine: false,
291
+ arrowParens: 'avoid',
292
+ proseWrap: 'always',
293
+ };
294
+ ```
295
+
296
+ ## Example scripts
297
+
298
+ Optionally, you can add these scripts to your `package.json` for common linting workflows:
299
+
300
+ **Basic scripts (no separate Prettier installation needed):**
301
+
302
+ ```json
303
+ {
304
+ "scripts": {
305
+ "lint": "eslint .",
306
+ "fix": "eslint . --fix"
307
+ },
308
+ "lint-staged": {
309
+ "*.{js,jsx,ts,tsx}": ["eslint --fix"]
310
+ }
311
+ }
312
+ ```
313
+
314
+ **With Prettier installed separately (for formatting non-JS files):**
315
+
316
+ ```json
317
+ {
318
+ "scripts": {
319
+ "lint": "eslint .",
320
+ "fix": "eslint . --fix",
321
+ "format": "prettier --config ./node_modules/@codfish/eslint-config/prettier.js --write \"**/*.{json,css,md}\"",
322
+ "check": "npm run lint && npm run format -- --check --no-write"
323
+ },
324
+ "lint-staged": {
325
+ "*.{js,jsx,ts,tsx}": ["eslint --fix"],
326
+ "*.{json,css,md}": ["prettier --write --config ./node_modules/@codfish/eslint-config/prettier.js"]
327
+ }
328
+ }
329
+ ```
330
+
331
+ ## Commitlint Configuration
332
+
333
+ Extend from the shared codfish commitlint config.
334
+
335
+ ```js
336
+ import codfishConfig from '@codfish/eslint-config/commitlint.js';
337
+
338
+ export default Object.assign(codfishConfig, {
339
+ // your overrides here
340
+ rules: {
341
+ 'scope-case': [1],
342
+ },
343
+ });
344
+ ```
345
+
346
+ **Or just reference it in your package.json:**
347
+
348
+ ```json
349
+ {
350
+ "commitlint": {
351
+ "extends": ["./node_modules/@codfish/eslint-config/commitlint.js"]
352
+ }
353
+ }
354
+ ```
355
+
356
+ Run commitlint in your CI to validate your commits:
357
+
358
+ > [!NOTE]
359
+ >
360
+ > If you have @codfish/eslint-config as a dev dependency, and a commitlint config in your project, you can just call
361
+ > `npx commitlint` in your CI and it will use the shared config.
362
+ >
363
+ > - You just need to setup node & install your dependencies before running commitlint.
364
+ > - Don't forget to set the `fetch-depth` to `0` to ensure commitlint can work properly.
365
+
366
+ ```yaml
367
+ # .github/workflows/validate.yml
368
+
369
+ on: pull_request_target
370
+
371
+ jobs:
372
+ validate:
373
+ runs-on: ubuntu-latest
374
+
375
+ steps:
376
+ - uses: actions/checkout@v5
377
+ with:
378
+ ref: ${{ github.event.pull_request.head.sha || github.ref }}
379
+ fetch-depth: 0 # Important for commitlint to work
380
+
381
+ - uses: actions/setup-node@v5
382
+ with:
383
+ node-version: lts/*
384
+ registry-url: https://registry.npmjs.org
385
+
386
+ - run: npm ci # or npm install
387
+
388
+ - run:
389
+ npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}
390
+ --verbose
391
+ ```
392
+
158
393
  ## Known issues
159
394
 
160
395
  > https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/149
package/index.js CHANGED
@@ -2,6 +2,8 @@ import js from '@eslint/js';
2
2
  import { defineConfig } from 'eslint/config';
3
3
  import prettier from 'eslint-plugin-prettier/recommended';
4
4
  import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
5
+ import tailwindPlugin from 'eslint-plugin-tailwindcss';
6
+ import ymlPlugin from 'eslint-plugin-yml';
5
7
  import globals from 'globals';
6
8
  import tseslint from 'typescript-eslint';
7
9
 
@@ -16,7 +18,7 @@ const useBuiltinPrettierConfig = !hasLocalConfig('prettier');
16
18
 
17
19
  /**
18
20
  * Modern ESLint configuration with dynamic feature detection
19
- * Supports TypeScript, React, Jest, Vitest, and Prettier
21
+ * Supports TypeScript, React, Jest, Vitest, Prettier, YAML, Tailwind CSS, and Next.js
20
22
  */
21
23
  export default defineConfig([
22
24
  // Base JavaScript configuration
@@ -108,16 +110,49 @@ export default defineConfig([
108
110
  '**/coverage/',
109
111
  'cypress/screenshots/',
110
112
  'cypress/videos/',
111
- 'storybook-static/',
113
+ 'storybook-static',
114
+ '.nuxt',
115
+ '.svelte-kit',
116
+ '.docusaurus',
117
+ '.astro',
118
+ '.output',
119
+ '**/out/',
120
+ '.vite',
121
+ '.parcel-cache',
122
+ '.webpack',
123
+ '.turbo',
124
+ '.nyc_output',
125
+ 'playwright-report',
126
+ 'cypress/downloads/',
127
+ 'cypress/reports/',
128
+ '.serverless',
129
+ '.netlify',
130
+ '.wrangler',
131
+ '.firebase',
132
+ 'android',
133
+ 'ios',
134
+ '.expo',
135
+ '**/tmp/',
136
+ '**/temp/',
137
+ '.tmp',
138
+ '.eslintcache',
139
+ '*.tsbuildinfo',
112
140
  ],
113
141
  },
114
142
 
115
143
  // Configuration files (eslint, prettier, etc.)
116
144
  configFilesConfig,
117
145
 
146
+ // YML files
147
+ ymlPlugin.configs['flat/standard'],
148
+ ymlPlugin.configs['flat/prettier'], // handles conflicting rules with the yml plugin
149
+
118
150
  // React configuration (dynamic)
119
151
  ifAnyDep('react', reactConfig, []),
120
152
 
153
+ // Tailwind CSS configuration (dynamic)
154
+ ifAnyDep('tailwindcss', tailwindPlugin.configs['flat/recommended'], []),
155
+
121
156
  // Jest OR Vitest configuration (dynamic)
122
157
  ifAnyDep('jest', jestConfig, []),
123
158
 
package/package.json CHANGED
@@ -1,8 +1,27 @@
1
1
  {
2
2
  "name": "@codfish/eslint-config",
3
- "version": "0.0.0-PR-124--a65acf5",
3
+ "version": "0.0.0-PR-124--0da7f69",
4
4
  "description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
5
5
  "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/codfish/eslint-config.git"
9
+ },
10
+ "keywords": [
11
+ "eslint",
12
+ "eslintconfig",
13
+ "config",
14
+ "codfish",
15
+ "prettier",
16
+ "javascript",
17
+ "styleguide"
18
+ ],
19
+ "author": "Chris O'Donnell <chris@codfish.dev> (https://www.codfish.dev)",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/codfish/eslint-config/issues"
23
+ },
24
+ "homepage": "https://github.com/codfish/eslint-config#readme",
6
25
  "main": "index.js",
7
26
  "types": "dist/index.d.ts",
8
27
  "exports": {
@@ -28,50 +47,10 @@
28
47
  "dev": "tsc --watch",
29
48
  "type-check": "tsc --noEmit",
30
49
  "lint": "eslint .",
31
- "fix": "prettier --write \"**/*.{json,css,scss,md}\" && npm run lint -- --fix",
50
+ "fix": "prettier --write \"**/*.{json,css,scss,md}\" --config ./prettier.js && npm run lint -- --fix",
32
51
  "prepublishOnly": "npm run build",
33
52
  "prepare": "husky"
34
53
  },
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/codfish/eslint-config.git"
38
- },
39
- "keywords": [
40
- "eslint",
41
- "eslintconfig",
42
- "config",
43
- "codfish",
44
- "prettier",
45
- "javascript",
46
- "styleguide"
47
- ],
48
- "author": "Chris O'Donnell <chris@codfish.dev> (https://www.codfish.dev)",
49
- "license": "MIT",
50
- "bugs": {
51
- "url": "https://github.com/codfish/eslint-config-codfish/issues"
52
- },
53
- "homepage": "https://github.com/codfish/eslint-config-codfish#readme",
54
- "peerDependencies": {
55
- "eslint": ">= 9"
56
- },
57
- "peerDependenciesMeta": {
58
- "typescript": {
59
- "optional": true
60
- }
61
- },
62
- "engines": {
63
- "node": ">=20.0.0"
64
- },
65
- "files": [
66
- "dist",
67
- "rules",
68
- "index.js",
69
- "prettier.js",
70
- "dapp.js",
71
- "docker.js",
72
- "utils.js",
73
- "commitlint.js"
74
- ],
75
54
  "dependencies": {
76
55
  "@commitlint/cli": "^19.8.1",
77
56
  "@commitlint/config-conventional": "^19.8.1",
@@ -85,6 +64,10 @@
85
64
  "eslint-plugin-react": "^7.37.5",
86
65
  "eslint-plugin-react-hooks": "^5.2.0",
87
66
  "eslint-plugin-simple-import-sort": "^12.1.1",
67
+ "eslint-plugin-tailwindcss": "^3.18.2",
68
+ "eslint-plugin-testing-library": "^7.1.0",
69
+ "eslint-plugin-yml": "^1.16.0",
70
+ "@next/eslint-plugin-next": "^15.1.6",
88
71
  "globals": "^16.4.0",
89
72
  "lodash.has": "^4.5.2",
90
73
  "prettier": "^3.6.2",
@@ -98,13 +81,34 @@
98
81
  "lint-staged": "^16.1.6",
99
82
  "typescript": "^5.9.2"
100
83
  },
84
+ "engines": {
85
+ "node": ">=20.0.0"
86
+ },
87
+ "files": [
88
+ "dist",
89
+ "rules",
90
+ "index.js",
91
+ "prettier.js",
92
+ "dapp.js",
93
+ "docker.js",
94
+ "utils.js",
95
+ "commitlint.js"
96
+ ],
97
+ "peerDependencies": {
98
+ "eslint": ">= 9"
99
+ },
100
+ "peerDependenciesMeta": {
101
+ "typescript": {
102
+ "optional": true
103
+ }
104
+ },
101
105
  "commitlint": {
102
106
  "extends": [
103
107
  "./commitlint"
104
108
  ]
105
109
  },
106
110
  "lint-staged": {
107
- "*.{json,yml}": [
111
+ "*.{json,css,md,yml}": [
108
112
  "prettier --write --config ./prettier.js"
109
113
  ],
110
114
  "*.md": [
package/rules/jest.js CHANGED
@@ -1,9 +1,12 @@
1
1
  import { defineConfig } from 'eslint/config';
2
2
  import jest from 'eslint-plugin-jest';
3
+ import testingLibrary from 'eslint-plugin-testing-library';
4
+
5
+ import { ifAnyDep } from '../utils.js';
3
6
 
4
7
  /**
5
8
  * Jest ESLint configuration for flat config format
6
- * Includes Jest-specific rules and globals for test files
9
+ * Includes Jest-specific rules, globals, and Testing Library rules for test files
7
10
  */
8
11
  export default defineConfig([
9
12
  {
@@ -20,5 +23,13 @@ export default defineConfig([
20
23
  ],
21
24
 
22
25
  ...jest.configs['flat/recommended'],
26
+
27
+ ...ifAnyDep('react-testing-library', testingLibrary.configs['flat/react'], {}),
28
+ ...ifAnyDep('vue-testing-library', testingLibrary.configs['flat/vue'], {}),
29
+
30
+ rules: {
31
+ 'no-console': 'off',
32
+ ...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
33
+ },
23
34
  },
24
35
  ]);
package/rules/react.js CHANGED
@@ -1,9 +1,12 @@
1
+ import nextPlugin from '@next/eslint-plugin-next';
1
2
  import { defineConfig } from 'eslint/config';
2
3
  import jsxA11y from 'eslint-plugin-jsx-a11y';
3
4
  import react from 'eslint-plugin-react';
4
5
  import reactHooks from 'eslint-plugin-react-hooks';
5
6
  import globals from 'globals';
6
7
 
8
+ import { ifAnyDep } from '../utils.js';
9
+
7
10
  /**
8
11
  * React ESLint configuration. Includes React, React Hooks, and JSX accessibility rules.
9
12
  *
@@ -31,6 +34,18 @@ export default defineConfig([
31
34
  // React Hooks configuration
32
35
  reactHooks.configs['recommended-latest'],
33
36
 
37
+ // Next.js configuration (dynamic)
38
+ ifAnyDep(
39
+ 'next',
40
+ {
41
+ ...nextPlugin.flatConfig.recommended,
42
+ ...nextPlugin.flatConfig.coreWebVitals,
43
+
44
+ name: 'codfish/next',
45
+ },
46
+ {},
47
+ ),
48
+
34
49
  {
35
50
  rules: {
36
51
  'react-hooks/exhaustive-deps': 'off',
package/rules/vitest.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import vitest from '@vitest/eslint-plugin';
2
2
  import { defineConfig } from 'eslint/config';
3
+ import testingLibrary from 'eslint-plugin-testing-library';
3
4
  import globals from 'globals';
4
5
 
6
+ import { ifAnyDep } from '../utils.js';
7
+
5
8
  /**
6
9
  * Vitest ESLint configuration for flat config format
7
- * Includes Vitest-specific rules and globals for test files
10
+ * Includes Vitest-specific rules, globals, and Testing Library rules for test files
8
11
  */
9
12
  export default defineConfig([
10
13
  {
@@ -17,6 +20,9 @@ export default defineConfig([
17
20
 
18
21
  ...vitest.configs.recommended,
19
22
 
23
+ ...ifAnyDep('react-testing-library', testingLibrary.configs['flat/react'], {}),
24
+ ...ifAnyDep('vue-testing-library', testingLibrary.configs['flat/vue'], {}),
25
+
20
26
  name: 'codfish/vitest',
21
27
 
22
28
  languageOptions: {
@@ -28,7 +34,7 @@ export default defineConfig([
28
34
 
29
35
  rules: {
30
36
  'no-console': 'off',
31
- 'tailwindcss/no-custom-classname': 'off',
37
+ ...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
32
38
  },
33
39
  },
34
40
  ]);