@codfish/eslint-config 0.0.0-PR-124--0da7f69 → 0.0.0-PR-125--8d3b55f

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,7 +1,7 @@
1
1
  # @codfish/eslint-config
2
2
 
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.
3
+ > Modern ESLint configuration with TypeScript, React/Next.js, YAML, Testing Library, and testing framework support using
4
+ > ESLint v9+ flat config format.
5
5
 
6
6
  [![version](https://img.shields.io/npm/v/@codfish/eslint-config.svg)](http://npm.im/@codfish/eslint-config)
7
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)
@@ -15,16 +15,13 @@
15
15
  ## Table of Contents
16
16
 
17
17
  - [Features](#features)
18
- - [Automatic Configuration](#automatic-configuration)
19
- - [Opinionated Highlights](#opinionated-highlights)
20
18
  - [Installation](#installation)
21
19
  - [Usage](#usage)
22
- - [Docker Configuration](#docker-configuration)
23
- - [dApps Configuration](#dapps-configuration)
20
+ - [Opinionated Highlights](#opinionated-highlights)
24
21
  - [Prettier Configuration](#prettier-configuration)
22
+ - [Use in combination with prettier-plugin-tailwindcss](#use-in-combination-with-prettier-plugin-tailwindcss)
25
23
  - [Example scripts](#example-scripts)
26
24
  - [Commitlint Configuration](#commitlint-configuration)
27
- - [Known issues](#known-issues)
28
25
  - [Migration from Legacy Config](#migration-from-legacy-config)
29
26
 
30
27
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -39,58 +36,12 @@
39
36
  - **Next.js support**: Automatically configures Next.js official plugin linting rules when detected
40
37
  - **Test framework agnostic**: Supports Jest and Vitest with automatic detection
41
38
  - **Testing Library integration**: Automatically includes Testing Library rules for test files
42
- - **Tailwind CSS support**: Automatically configures Tailwind CSS linting when detected
43
39
  - **YAML/YML support**: Built-in linting for YAML configuration files
44
40
  - **Prettier integration**: Built-in Prettier configuration with conflict resolution via eslint-config-prettier
45
41
  - **ESM architecture**: Built with ECMAScript modules and full TypeScript typing
46
42
  - **Docker support**: Optional configuration for dockerized applications
47
43
  - **Blockchain/dApp support**: Optional configuration for decentralized applications
48
44
 
49
- ### Automatic Configuration
50
-
51
- The config automatically detects and configures:
52
-
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
55
- - **Jest**: Configures Jest-specific rules when `jest` is found in dependencies
56
- - **Vitest**: Configures Vitest-specific rules when `vitest` is detected
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.
93
-
94
45
  ## Installation
95
46
 
96
47
  Install the package and required peer dependencies:
@@ -124,7 +75,41 @@ export default defineConfig(
124
75
  > [!IMPORTANT] If you get ES module errors, you may need to set the `type` field in your `package.json` to `module` or
125
76
  > rename your config file to `eslint.config.mjs`.
126
77
 
127
- Not using the `defineConfig` function, just spread the config object:
78
+ **Using extends and targetting all files:**
79
+
80
+ ```js
81
+ import codfish from '@codfish/eslint-config';
82
+
83
+ export default defineConfig({
84
+ extends: [codfish],
85
+ rules: {
86
+ // temporary
87
+ '@typescript-eslint/no-explicit-any': 'off',
88
+ },
89
+ });
90
+ ```
91
+
92
+ **Using extends and targetting specific files:**
93
+
94
+ > [!WARNING]
95
+ >
96
+ > **Not recommended.** This will prevent it from using the `files` specified in the main config, so rules around test
97
+ > files, yml files, etc. will not be applied.
98
+
99
+ ```js
100
+ import codfish from '@codfish/eslint-config';
101
+
102
+ export default defineConfig({
103
+ files: ['**/*.{js,jsx,ts,tsx}'],
104
+ extends: [codfish],
105
+ rules: {
106
+ // temporary
107
+ '@typescript-eslint/no-explicit-any': 'off',
108
+ },
109
+ });
110
+ ```
111
+
112
+ **Not using the `defineConfig` function, just spread the config object:**
128
113
 
129
114
  ```js
130
115
  import codfish from '@codfish/eslint-config';
@@ -181,9 +166,6 @@ export default defineConfig(
181
166
  {
182
167
  files: ['**/*.{js,jsx,ts,tsx}'],
183
168
  rules: {
184
- // Customize Tailwind CSS rules
185
- 'tailwindcss/classnames-order': 'warn',
186
- 'tailwindcss/no-custom-classname': 'off',
187
169
  // Customize Next.js rules
188
170
  '@next/next/no-img-element': 'warn',
189
171
  '@next/next/no-html-link-for-pages': 'off',
@@ -192,7 +174,7 @@ export default defineConfig(
192
174
  );
193
175
  ```
194
176
 
195
- ### Docker Configuration
177
+ **Docker Configuration:**
196
178
 
197
179
  For projects leveraging Docker containers, you may want to disable import resolution errors for `node_modules` if
198
180
  packages are only available in the container but you're running the linter locally.
@@ -211,17 +193,24 @@ export default defineConfig(
211
193
  );
212
194
  ```
213
195
 
214
- ### dApps Configuration
196
+ **dApps Configuration:**
215
197
 
216
198
  For decentralized applications that use build artifacts and blockchain globals, use the specialized dApp config. This
217
199
  config will set some globals as well as ignore missing build artifact imports. While you obviously need those to run
218
200
  your app, sometimes you might want to run the linter in a ci/cd environment and build artifacts might not be present.
219
201
 
220
- You can also directly import the Prettier config:
221
-
222
202
  ```js
223
- import prettierConfig from '@codfish/eslint-config/prettier';
224
- export default prettierConfig;
203
+ import codfish from '@codfish/eslint-config';
204
+ import dapp from '@codfish/eslint-config/dapp';
205
+
206
+ export default defineConfig(
207
+ codfish,
208
+ dapp,
209
+
210
+ {
211
+ // Your app-specific overrides
212
+ },
213
+ );
225
214
  ```
226
215
 
227
216
  The dApp configuration provides:
@@ -230,19 +219,43 @@ The dApp configuration provides:
230
219
  - Import resolution handling for smart contract build artifacts
231
220
  - Relaxed rules for generated contract files
232
221
 
222
+ ### Opinionated Highlights
223
+
224
+ This configuration includes some opinionated settings that you might want to customize for your project:
225
+
226
+ **Prettier/Formatting:**
227
+
228
+ - **Semicolons**: Enforces semicolons (`;`)
229
+ - **120 character line width**: Wider than the common 80/100 - you might prefer shorter lines
230
+ - **2-space indentation**: Uses 2 spaces for tabs
231
+ - **Single quotes**: Prefers `'single'` over `"double"` quotes
232
+ - **Trailing commas**: Adds trailing commas everywhere
233
+ - **Arrow parentheses**: Avoids parens around single args (`x => x` not `(x) => x`)
234
+
235
+ **ESLint Rules:**
236
+
237
+ - **Import sorting**: Enforces automatic import organization with specific grouping rules
238
+ - **Lodash restrictions**: Requires direct imports (`import get from 'lodash-es/get'`) instead of full lodash
239
+ - **React hooks deps**: Disables `exhaustive-deps` rule - you might want this stricter
240
+ - **Console statements**: Disallows `console.log` in regular code (only allowed in test files) - some teams prefer
241
+ warnings instead of errors
242
+ - **Next.js rules**: Enforces Next.js best practices and Core Web Vitals optimization
243
+ - **Testing Library rules**: Enforces Testing Library best practices in test files
244
+
245
+ **File Ignores:**
246
+
247
+ - Ignores common build directories (`.next`, `coverage`, `.vercel`, etc.)
248
+ - Includes `.github` and `.vitepress` folders (not ignored like most configs)
249
+
250
+ See the [configuration examples below](#usage) for instructions on overriding these settings to match your team's
251
+ preferences.
252
+
233
253
  ## Prettier Configuration
234
254
 
235
255
  **Prettier is included and runs automatically** through ESLint for JavaScript, TypeScript, JSX, and TSX files using the
236
256
  [built-in configuration](./prettier.js). **You don't need to install or configure Prettier separately** for basic usage.
237
257
 
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:
258
+ You can then override the default config by creating your own Prettier config file, or extend the built-in config:
246
259
 
247
260
  **Option 1: Extend the built-in config (Recommended)**
248
261
 
@@ -293,6 +306,31 @@ export default {
293
306
  };
294
307
  ```
295
308
 
309
+ > [!TIP]
310
+ >
311
+ > If you want to format other file types (like Markdown, JSON, CSS, or YAML) or run Prettier directly, you can install
312
+ > it as a dev dependency: `npm i -D prettier`.
313
+
314
+ ### Use in combination with prettier-plugin-tailwindcss
315
+
316
+ ```sh
317
+ npm i -D eslint@9 @codfish/eslint-config prettier-plugin-tailwindcss
318
+ ```
319
+
320
+ ```js
321
+ // prettier.config.js
322
+
323
+ import codfishPrettier from '@codfish/eslint-config/prettier';
324
+
325
+ /** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
326
+ export default {
327
+ ...codfishPrettier,
328
+ plugins: ['prettier-plugin-tailwindcss'],
329
+ tailwindStylesheet: './src/styles/app.css',
330
+ tailwindFunctions: ['clsx'], // optional
331
+ };
332
+ ```
333
+
296
334
  ## Example scripts
297
335
 
298
336
  Optionally, you can add these scripts to your `package.json` for common linting workflows:
@@ -390,18 +428,6 @@ jobs:
390
428
  --verbose
391
429
  ```
392
430
 
393
- ## Known issues
394
-
395
- > https://github.com/francoismassart/eslint-plugin-tailwindcss/issues/149
396
-
397
- When building dynamic classes, the auto sorting of tailwind classes can break things so beware.
398
-
399
- To avoid this happening you can re-wrap the dynamic class expression like so:
400
-
401
- ```vue-html
402
- class="`p-0 ${`tw-border-${accentColor}`}`"
403
- ```
404
-
405
431
  ## Migration from Legacy Config
406
432
 
407
433
  If you're upgrading from an older version that used Airbnb presets:
package/index.js CHANGED
@@ -2,7 +2,6 @@ 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
5
  import ymlPlugin from 'eslint-plugin-yml';
7
6
  import globals from 'globals';
8
7
  import tseslint from 'typescript-eslint';
@@ -18,7 +17,7 @@ const useBuiltinPrettierConfig = !hasLocalConfig('prettier');
18
17
 
19
18
  /**
20
19
  * Modern ESLint configuration with dynamic feature detection
21
- * Supports TypeScript, React, Jest, Vitest, Prettier, YAML, Tailwind CSS, and Next.js
20
+ * Supports TypeScript, React, Jest, Vitest, Prettier, YAML, and Next.js
22
21
  */
23
22
  export default defineConfig([
24
23
  // Base JavaScript configuration
@@ -147,12 +146,19 @@ export default defineConfig([
147
146
  ymlPlugin.configs['flat/standard'],
148
147
  ymlPlugin.configs['flat/prettier'], // handles conflicting rules with the yml plugin
149
148
 
149
+ {
150
+ name: 'codfish/github-yml-overrides',
151
+
152
+ files: ['.github/**/*.yml', '.github/**/*.yaml'],
153
+
154
+ rules: {
155
+ 'yml/no-empty-mapping-value': 'off', // somewhat common in github workflows
156
+ },
157
+ },
158
+
150
159
  // React configuration (dynamic)
151
160
  ifAnyDep('react', reactConfig, []),
152
161
 
153
- // Tailwind CSS configuration (dynamic)
154
- ifAnyDep('tailwindcss', tailwindPlugin.configs['flat/recommended'], []),
155
-
156
162
  // Jest OR Vitest configuration (dynamic)
157
163
  ifAnyDep('jest', jestConfig, []),
158
164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codfish/eslint-config",
3
- "version": "0.0.0-PR-124--0da7f69",
3
+ "version": "0.0.0-PR-125--8d3b55f",
4
4
  "description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -64,7 +64,6 @@
64
64
  "eslint-plugin-react": "^7.37.5",
65
65
  "eslint-plugin-react-hooks": "^5.2.0",
66
66
  "eslint-plugin-simple-import-sort": "^12.1.1",
67
- "eslint-plugin-tailwindcss": "^3.18.2",
68
67
  "eslint-plugin-testing-library": "^7.1.0",
69
68
  "eslint-plugin-yml": "^1.16.0",
70
69
  "@next/eslint-plugin-next": "^15.1.6",
package/rules/jest.js CHANGED
@@ -29,7 +29,6 @@ export default defineConfig([
29
29
 
30
30
  rules: {
31
31
  'no-console': 'off',
32
- ...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
33
32
  },
34
33
  },
35
34
  ]);
package/rules/vitest.js CHANGED
@@ -34,7 +34,6 @@ export default defineConfig([
34
34
 
35
35
  rules: {
36
36
  'no-console': 'off',
37
- ...ifAnyDep('tailwindcss', { 'tailwindcss/no-custom-classname': 'off' }, {}),
38
37
  },
39
38
  },
40
39
  ]);