@ovh-ux/manager-static-analysis-kit 0.2.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +108 -0
  3. package/bin/lint-cli.js +73 -0
  4. package/eslint.config.mjs +53 -0
  5. package/package.json +127 -0
  6. package/scripts/build.ts +44 -0
  7. package/src/adapters/code-health-meter/README.md +1 -0
  8. package/src/adapters/code-health-meter/config/.gitkeep +0 -0
  9. package/src/adapters/code-health-meter/rules/.gitkeep +0 -0
  10. package/src/adapters/eslint/README.md +317 -0
  11. package/src/adapters/eslint/config/eslint-shared-config.ts +60 -0
  12. package/src/adapters/eslint/rules/eslint-a11y.ts +30 -0
  13. package/src/adapters/eslint/rules/eslint-complexity.ts +87 -0
  14. package/src/adapters/eslint/rules/eslint-css.ts +35 -0
  15. package/src/adapters/eslint/rules/eslint-html.ts +32 -0
  16. package/src/adapters/eslint/rules/eslint-imports.ts +84 -0
  17. package/src/adapters/eslint/rules/eslint-javascript.ts +27 -0
  18. package/src/adapters/eslint/rules/eslint-naming-conventions.ts +49 -0
  19. package/src/adapters/eslint/rules/eslint-prettier.ts +29 -0
  20. package/src/adapters/eslint/rules/eslint-react.ts +50 -0
  21. package/src/adapters/eslint/rules/eslint-storybook.ts +29 -0
  22. package/src/adapters/eslint/rules/eslint-tailwind-jsx.ts +21 -0
  23. package/src/adapters/eslint/rules/eslint-tanstack.ts +25 -0
  24. package/src/adapters/eslint/rules/eslint-tests.ts +35 -0
  25. package/src/adapters/eslint/rules/eslint-typescript.ts +33 -0
  26. package/src/adapters/eslint/types/eslint-js.d.ts +4 -0
  27. package/src/adapters/eslint/types/eslint-plugin-jsx-a11y.d.ts +16 -0
  28. package/src/adapters/eslint/types/eslint-plugin-react-hooks.d.ts +9 -0
  29. package/src/adapters/eslint/types/eslint-plugin-react.d.ts +9 -0
  30. package/src/adapters/eslint/types/eslint-plugin-tailwindcss.d.ts +6 -0
  31. package/src/adapters/eslint/types/eslint-shared-config.d.ts +3 -0
  32. package/src/adapters/jscpd/README.md +0 -0
  33. package/src/adapters/jscpd/config/.gitkeep +0 -0
  34. package/src/adapters/jscpd/rules/.gitkeep +0 -0
  35. package/src/adapters/madge/README.md +0 -0
  36. package/src/adapters/madge/config/.gitkeep +0 -0
  37. package/src/adapters/madge/rules/.gitkeep +0 -0
  38. package/src/adapters/ts-config/README.md +153 -0
  39. package/src/adapters/ts-config/config/standard/tsconfig.node.ts +13 -0
  40. package/src/adapters/ts-config/config/standard/tsconfig.react.ts +15 -0
  41. package/src/adapters/ts-config/config/standard/tsconfig.test.ts +13 -0
  42. package/src/adapters/ts-config/config/strict/tsconfig.node.ts +13 -0
  43. package/src/adapters/ts-config/config/strict/tsconfig.react.ts +15 -0
  44. package/src/adapters/ts-config/config/strict/tsconfig.test.ts +13 -0
  45. package/src/adapters/ts-config/rules/tsconfig.base.strict.ts +13 -0
  46. package/src/adapters/ts-config/rules/tsconfig.base.ts +17 -0
  47. package/src/code-analysis.ts +1 -0
  48. package/src/configs/complexity-config.ts +29 -0
  49. package/src/configs/file-globs-config.ts +22 -0
  50. package/src/configs/import-order-config.ts +12 -0
  51. package/src/configs/jscpd-config.ts +8 -0
  52. package/src/configs/madge-config.ts +8 -0
  53. package/src/configs/naming-conventions-config.ts +138 -0
  54. package/src/configs/prettier-config.ts +81 -0
  55. package/src/configs/shared-exclusion-patterns.ts +41 -0
  56. package/tsconfig.json +31 -0
@@ -0,0 +1,317 @@
1
+ # ESLint Static Analysis Kit — Plugin Overview & Rule Index
2
+
3
+ This document provides a full breakdown of all ESLint plugins, rules, and conventions used in the `@ovh-ux/manager-static-analysis-kit`.
4
+
5
+ ---
6
+
7
+ ## 📦 Package Overview
8
+
9
+ ```json
10
+ {
11
+ "name": "@ovh-ux/manager-static-analysis-kit",
12
+ "version": "x.x.x",
13
+ "description": "A modular, extensible, and future-ready toolkit for defining, adapting, and sharing static analysis rules across projects in the `manager` monorepo."
14
+ }
15
+ ```
16
+
17
+ ---
18
+
19
+ ## 🔌 Installed ESLint Plugins
20
+
21
+ ### 🎯 Core ESLint
22
+
23
+ | Package | Purpose |
24
+ |----------------|----------------------------------------|
25
+ | `eslint` | Core linting engine |
26
+ | `@eslint/js` | Base rule set for JS/TS |
27
+ | `@eslint/css` | CSS linting support |
28
+
29
+ ---
30
+
31
+ ### 🧱 Structure & Naming Enforcement
32
+
33
+ | Plugin | Description |
34
+ |----------------------------------|-------------|
35
+ | `eslint-plugin-check-file` | File and folder naming rules |
36
+ | `eslint-import-resolver-typescript` | Type-aware path resolution for imports |
37
+
38
+ ---
39
+
40
+ ### 🧩 Code Style & Formatting
41
+
42
+ | Plugin / Tool | Description |
43
+ |------------------------------------|-------------|
44
+ | `prettier` | Formatter |
45
+ | `eslint-plugin-prettier` | Runs Prettier as a lint rule |
46
+ | `eslint-config-prettier` | Disables ESLint rules conflicting with Prettier |
47
+ | `@trivago/prettier-plugin-sort-imports` | Sorts imports automatically |
48
+ | `prettier-plugin-tailwindcss` | Sorts Tailwind classes |
49
+
50
+ ---
51
+
52
+ ### 🧠 Language & Syntax
53
+
54
+ | Plugin | Description |
55
+ |-----------------------------------|-------------|
56
+ | `@typescript-eslint/eslint-plugin`| TypeScript lint rules |
57
+ | `@typescript-eslint/parser` | TS parser for ESLint |
58
+ | `@typescript-eslint/utils` | TypeScript rule tooling |
59
+ | `@types/eslint`, `@types/node` | Type support |
60
+
61
+ ---
62
+
63
+ ### ⚛️ React & JSX
64
+
65
+ | Plugin | Description |
66
+ |-----------------------------------|-------------|
67
+ | `eslint-plugin-react` | React best practices |
68
+ | `eslint-plugin-react-hooks` | React Hook rules |
69
+ | `eslint-plugin-jsx-a11y` | JSX accessibility |
70
+ | `eslint-plugin-storybook` | Storybook-specific rules |
71
+
72
+ ---
73
+
74
+ ### 💨 Tailwind CSS
75
+
76
+ | Plugin | Description |
77
+ |-----------------------------------|-------------|
78
+ | `eslint-plugin-tailwindcss` | Tailwind usage validation |
79
+ | `@types/eslint-plugin-tailwindcss`| Types for Tailwind plugin |
80
+ | `tailwind-csstree` | Tailwind CSS AST analysis |
81
+
82
+ ---
83
+
84
+ ### 🔍 HTML & Templates
85
+
86
+ | Plugin | Description |
87
+ |-----------------------------------|-------------|
88
+ | `@html-eslint/eslint-plugin` | HTML rules |
89
+ | `@html-eslint/parser` | HTML parsing support |
90
+
91
+ ---
92
+
93
+ ### 🧪 Testing
94
+
95
+ | Plugin | Description |
96
+ |-----------------------------------|-------------|
97
+ | `@vitest/eslint-plugin` | Vitest rules |
98
+
99
+ ---
100
+
101
+ ### 🧶 TanStack Query
102
+
103
+ | Plugin | Description |
104
+ |-----------------------------------|-------------|
105
+ | `@tanstack/eslint-plugin-query` | Best practices for `tanstack-query` |
106
+
107
+ ---
108
+
109
+ ## 📁 Rule Modules
110
+
111
+ Available in `src/adapters/eslint/rules/`:
112
+
113
+ | Module | Purpose |
114
+ |--------------------------------|----------------------------------|
115
+ | `eslint-a11y.ts` | Accessibility rules |
116
+ | `eslint-complexity.ts` | Code complexity constraints |
117
+ | `eslint-css.ts` | Linting for stylesheets |
118
+ | `eslint-html.ts` | HTML linting rules |
119
+ | `eslint-imports.ts` | Import rules and conventions |
120
+ | `eslint-javascript.ts` | Generic JavaScript rules |
121
+ | `eslint-naming-conventions.ts` | Folder/file naming enforcement |
122
+ | `eslint-prettier.ts` | Prettier integration |
123
+ | `eslint-react.ts` | React conventions and structure |
124
+ | `eslint-storybook.ts` | Storybook-specific lint rules |
125
+ | `eslint-tailwind-jsx.ts` | Tailwind inside JSX |
126
+ | `eslint-tanstack.ts` | Linting for TanStack Query usage|
127
+ | `eslint-tests.ts` | Testing rules (e.g., Vitest) |
128
+ | `eslint-typescript.ts` | TypeScript-specific rules |
129
+
130
+ ---
131
+
132
+ ## 📤 Package Export Map
133
+
134
+ ```json
135
+ "exports": {
136
+ ".": "./dist/code-analysis.js",
137
+ "./eslint/config": "./dist/adapters/eslint/config/eslint-shared-config.js",
138
+ "./eslint/storybook": "./dist/adapters/eslint/rules/eslint-storybook.js",
139
+ "./eslint/a11y": "./dist/adapters/eslint/rules/eslint-a11y.js",
140
+ "./eslint/complexity": "./dist/adapters/eslint/rules/eslint-complexity.js",
141
+ "./eslint/css": "./dist/adapters/eslint/rules/eslint-css.js",
142
+ "./eslint/html": "./dist/adapters/eslint/rules/eslint-html.js",
143
+ "./eslint/imports": "./dist/adapters/eslint/rules/eslint-imports.js",
144
+ "./eslint/javascript": "./dist/adapters/eslint/rules/eslint-javascript.js",
145
+ "./eslint/naming-conventions": "./dist/adapters/eslint/rules/eslint-naming-conventions.js",
146
+ "./eslint/prettier": "./dist/adapters/eslint/rules/eslint-prettier.js",
147
+ "./eslint/react": "./dist/adapters/eslint/rules/eslint-react.js",
148
+ "./eslint/tailwind-jsx": "./dist/adapters/eslint/rules/eslint-tailwind-jsx.js",
149
+ "./eslint/tanstack": "./dist/adapters/eslint/rules/eslint-tanstack.js",
150
+ "./eslint/tests": "./dist/adapters/eslint/rules/eslint-tests.js",
151
+ "./eslint/typescript": "./dist/adapters/eslint/rules/eslint-typescript.js"
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 🧪 Custom CLI
158
+
159
+ ```json
160
+ "bin": {
161
+ "manager-lint": "./bin/lint.js"
162
+ }
163
+ ```
164
+
165
+ To lint your codebase:
166
+
167
+ ```bash
168
+ yarn manager-lint path/to/package
169
+ ```
170
+
171
+ ---
172
+
173
+ ## 🔧 Usage Options
174
+
175
+ ### ✅ Option 1: Full Shared Config
176
+
177
+ ```ts
178
+ import { eslintSharedConfig } from '@ovh-ux/manager-static-analysis-kit';
179
+
180
+ export default eslintSharedConfig;
181
+ ```
182
+
183
+ ### 🔀 Option 2: Progressive Adoption
184
+
185
+ ```ts
186
+ import { javascriptEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/javascript';
187
+ import { typescriptEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/typescript';
188
+ import { reactEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/react';
189
+ import { prettierEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/prettier';
190
+ import { a11yEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/a11y';
191
+ import { complexityJsxTsxConfig, complexityTsJsConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/complexity';
192
+ import { htmlEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/html';
193
+ import { cssEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/css';
194
+ import { tailwindJsxConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/tailwind-jsx';
195
+ import { tanStackQueryEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/tanstack';
196
+ import { importEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/imports';
197
+ import { checkFileEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/naming-conventions';
198
+ import { vitestEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/tests';
199
+
200
+ export default [
201
+ javascriptEslintConfig,
202
+ typescriptEslintConfig,
203
+ reactEslintConfig,
204
+ a11yEslintConfig,
205
+ htmlEslintConfig,
206
+ cssEslintConfig,
207
+ tailwindJsxConfig,
208
+ tanStackQueryEslintConfig,
209
+ ...importEslintConfig,
210
+ ...checkFileEslintConfig,
211
+ vitestEslintConfig,
212
+ prettierEslintConfig,
213
+ complexityJsxTsxConfig,
214
+ complexityTsJsConfig,
215
+ ];
216
+ ```
217
+
218
+ ### ❌ Option 3: Override or Disable Rules
219
+
220
+ ```ts
221
+ import { typescriptEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/typescript';
222
+
223
+ export default [
224
+ {
225
+ ...typescriptEslintConfig,
226
+ rules: {
227
+ ...typescriptEslintConfig.rules,
228
+ '@typescript-eslint/no-unsafe-return': 'off',
229
+ '@typescript-eslint/no-unsafe-assignment': 'off',
230
+ '@typescript-eslint/no-explicit-any': 'off',
231
+ '@typescript-eslint/await-thenable': 'off'
232
+ },
233
+ },
234
+ ];
235
+ ```
236
+
237
+ **Disable all rules:**
238
+
239
+ ```ts
240
+ import { typescriptEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/typescript';
241
+
242
+ export default [
243
+ {
244
+ ...typescriptEslintConfig,
245
+ rules: {},
246
+ },
247
+ ];
248
+ ```
249
+
250
+ ---
251
+
252
+ ## 🚀 CLI Support
253
+
254
+ With Flat Config enabled, use the following script definitions:
255
+
256
+ ```json
257
+ {
258
+ "scripts": {
259
+ "lint": "manager-lint --config eslint.config.mjs ./src",
260
+ "lint:fix": "manager-lint --fix --config eslint.config.mjs ./src"
261
+ }
262
+ }
263
+ ```
264
+
265
+ ---
266
+
267
+ ## 📁 File Naming Conventions
268
+
269
+ | Purpose | Pattern | Format |
270
+ |----------------|---------------------------------|----------------------|
271
+ | Component | `*.component.tsx` | `PASCAL_CASE` |
272
+ | Hook | `use*.ts`, `use*.tsx` | `CAMEL_CASE` |
273
+ | Hook Test | `use*.spec.ts`, `use*.test.ts` | `CAMEL_CASE` |
274
+ | Test | `*.spec.tsx`, `*.test.tsx` | `PASCAL_CASE` |
275
+ | Constants | `*.constants.ts` | `PASCAL_CASE` |
276
+ | Types | `*.type.ts`, `*.interface.ts` | `PASCAL_CASE` |
277
+ | Translations | `Messages_en_GB.json` | `SCREAMING_SNAKE_CASE` |
278
+ | Styles | `*.css`, `*.scss` | `KEBAB_CASE` |
279
+ | Configs | `*.config.ts`, `vite.config.ts` | `KEBAB_CASE` |
280
+
281
+ ---
282
+
283
+ ## 🧼 React Best Practices
284
+
285
+ ### 📛 One Component per File
286
+
287
+ We enforce **one React component per file** to encourage modularity and readability:
288
+
289
+ ```json
290
+ "react/no-multi-comp": ["error", { "ignoreStateless": false }]
291
+ ```
292
+
293
+ ---
294
+
295
+ ## 📊 Complexity Rules Summary
296
+
297
+ | Rule | Target | Limit |
298
+ |---------------------------|------------------------|-------------------------|
299
+ | `max-depth` | Any block | 4 levels |
300
+ | `max-params` | Function parameters | 4 parameters |
301
+ | `max-nested-callbacks` | Callbacks | 3 levels |
302
+ | `complexity` | Cyclomatic complexity | 10–15 (context-based) |
303
+ | `max-lines` | Per file | 300 lines |
304
+ | `max-lines-per-function` | Function body | 50–80 lines |
305
+
306
+ ---
307
+
308
+ ## 📎 Related Links
309
+
310
+ - [TypeScript Config Guide](./README_tsconfig_static_analysis_kit.md)
311
+ - [Monorepo Guidelines](https://github.com/ovh/manager/tree/master/packages/manager)
312
+
313
+ ---
314
+
315
+ ## 📜 License
316
+
317
+ BSD-3-Clause — © OVH SAS
@@ -0,0 +1,60 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ import { a11yEslintConfig } from '../rules/eslint-a11y';
4
+ import { complexityJsxTsxConfig, complexityTsJsConfig } from '../rules/eslint-complexity';
5
+ import { cssEslintConfig } from '../rules/eslint-css';
6
+ import { htmlEslintConfig } from '../rules/eslint-html';
7
+ import { importEslintConfig } from '../rules/eslint-imports';
8
+ import { javascriptEslintConfig } from '../rules/eslint-javascript';
9
+ import { checkFileEslintConfig } from '../rules/eslint-naming-conventions';
10
+ import { prettierEslintConfig } from '../rules/eslint-prettier';
11
+ import { reactEslintConfig } from '../rules/eslint-react';
12
+ import { tailwindJsxConfig } from '../rules/eslint-tailwind-jsx';
13
+ import { tanStackQueryEslintConfig } from '../rules/eslint-tanstack';
14
+ import { vitestEslintConfig } from '../rules/eslint-tests';
15
+ import { typescriptEslintConfig } from '../rules/eslint-typescript';
16
+
17
+ /**
18
+ * Shared ESLint Flat Config aggregation for the OVH Manager codebase.
19
+ *
20
+ * This includes linting rules for:
21
+ * - Core web languages (HTML, CSS, JS, TS)
22
+ * - Popular tools and frameworks (React, Tailwind, Vitest, TanStack Query)
23
+ * - Code structure, complexity, and formatting
24
+ * - File naming and import conventions
25
+ *
26
+ * You may use this full config or import specific ones individually.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { eslintSharedConfig } from '@ovh-ux/manager-static-analysis-kit';
31
+ * export default eslintSharedConfig;
32
+ * ```
33
+ */
34
+ export const eslintSharedConfig: Linter.FlatConfig[] = [
35
+ // Core language support
36
+ htmlEslintConfig,
37
+ javascriptEslintConfig,
38
+ typescriptEslintConfig,
39
+ cssEslintConfig,
40
+
41
+ // Static analysis extensions
42
+ ...importEslintConfig, // JS/TS import rules
43
+ tailwindJsxConfig, // Tailwind CSS linting
44
+ a11yEslintConfig, // Accessibility
45
+
46
+ // Frameworks & Libraries
47
+ reactEslintConfig,
48
+ tanStackQueryEslintConfig,
49
+
50
+ // Testing and complexity constraints
51
+ vitestEslintConfig,
52
+ complexityJsxTsxConfig,
53
+ complexityTsJsConfig,
54
+
55
+ // Formatter (should go last to avoid conflict)
56
+ prettierEslintConfig,
57
+
58
+ // Structural constraints (e.g., file/folder naming)
59
+ ...checkFileEslintConfig,
60
+ ];
@@ -0,0 +1,30 @@
1
+ import { Linter } from 'eslint';
2
+ import jsxA11y from 'eslint-plugin-jsx-a11y';
3
+
4
+ import { allModules } from '../../../configs/file-globs-config';
5
+
6
+ /**
7
+ * Accessibility ESLint configuration using `eslint-plugin-jsx-a11y`.
8
+ *
9
+ * This configuration applies recommended accessibility rules for JSX,
10
+ * and is scoped to all JavaScript and TypeScript modules, including
11
+ * React and modern module formats.
12
+ *
13
+ * @see https://www.npmjs.com/package/eslint-plugin-jsx-a11y
14
+ */
15
+ export const a11yEslintConfig: Linter.FlatConfig = {
16
+ files: [allModules],
17
+ plugins: {
18
+ 'jsx-a11y': jsxA11y,
19
+ },
20
+ languageOptions: {
21
+ parserOptions: {
22
+ ecmaFeatures: {
23
+ jsx: true,
24
+ },
25
+ },
26
+ },
27
+ rules: {
28
+ ...jsxA11y.flatConfigs.recommended.rules,
29
+ },
30
+ };
@@ -0,0 +1,87 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ import { complexityRules } from '../../../configs/complexity-config';
4
+ import { jsTsFiles, jsxTsxFiles } from '../../../configs/file-globs-config';
5
+
6
+ /**
7
+ * Shared complexity rules applied across all file types
8
+ */
9
+ const sharedComplexityRules: Linter.RulesRecord = {
10
+ /** Maximum nesting depth of blocks */
11
+ 'max-depth': ['warn', complexityRules.maxDepth],
12
+
13
+ /** Maximum number of function parameters */
14
+ 'max-params': ['warn', complexityRules.maxParams],
15
+
16
+ /** Maximum number of nested callbacks */
17
+ 'max-nested-callbacks': ['warn', complexityRules.maxCallbacks],
18
+ };
19
+
20
+ /**
21
+ * Complexity rules for TSX/JSX files
22
+ */
23
+ export const complexityJsxTsxConfig: Linter.FlatConfig = {
24
+ files: [jsxTsxFiles],
25
+ rules: {
26
+ ...sharedComplexityRules,
27
+
28
+ /** Cyclomatic complexity */
29
+ complexity: ['warn', complexityRules.statements.tsxJsx],
30
+
31
+ /** Max lines per file */
32
+ 'max-lines': [
33
+ 'warn',
34
+ {
35
+ max: complexityRules.maxLines,
36
+ skipBlankLines: true,
37
+ skipComments: true,
38
+ },
39
+ ],
40
+
41
+ /** Max lines per function */
42
+ 'max-lines-per-function': [
43
+ 'warn',
44
+ {
45
+ max: complexityRules.linesPerFunction.tsxJsx,
46
+ skipBlankLines: true,
47
+ skipComments: true,
48
+ IIFEs: true,
49
+ },
50
+ ],
51
+ },
52
+ };
53
+
54
+ /**
55
+ * Complexity rules for TS/JS files
56
+ */
57
+ export const complexityTsJsConfig: Linter.FlatConfig = {
58
+ files: [jsTsFiles],
59
+ ignores: [jsxTsxFiles],
60
+ rules: {
61
+ ...sharedComplexityRules,
62
+
63
+ /** Cyclomatic complexity */
64
+ complexity: ['warn', complexityRules.statements.tsJs],
65
+
66
+ /** Max lines per file */
67
+ 'max-lines': [
68
+ 'warn',
69
+ {
70
+ max: complexityRules.maxLines,
71
+ skipBlankLines: true,
72
+ skipComments: true,
73
+ },
74
+ ],
75
+
76
+ /** Max lines per function */
77
+ 'max-lines-per-function': [
78
+ 'warn',
79
+ {
80
+ max: complexityRules.linesPerFunction.tsJs,
81
+ skipBlankLines: true,
82
+ skipComments: true,
83
+ IIFEs: true,
84
+ },
85
+ ],
86
+ },
87
+ };
@@ -0,0 +1,35 @@
1
+ import css from '@eslint/css';
2
+ import { ESLint, Linter } from 'eslint';
3
+ import { tailwind4 } from 'tailwind-csstree';
4
+
5
+ import { cssFiles } from '../../../configs/file-globs-config';
6
+
7
+ type ExtendedFlatConfig = Linter.FlatConfig & {
8
+ language?: string;
9
+ languageOptions?: Record<string, unknown>;
10
+ };
11
+
12
+ /**
13
+ * ESLint configuration for validating CSS files, including Tailwind CSS syntax.
14
+ *
15
+ * Uses `@eslint/css` plugin with `tailwind-csstree` custom parser to support Tailwind-specific syntax.
16
+ * Ensures clean and valid CSS, while integrating seamlessly into modern component-based workflows.
17
+ *
18
+ * Applies only to `.css` files.
19
+ *
20
+ * @see https://github.com/eslint/css?tab=readme-ov-file#rules
21
+ * @see https://github.com/francoismassart/tailwind-csstree
22
+ */
23
+ export const cssEslintConfig: ExtendedFlatConfig = {
24
+ files: [cssFiles],
25
+ language: 'css/css',
26
+ languageOptions: {
27
+ customSyntax: tailwind4,
28
+ },
29
+ plugins: {
30
+ css: css as unknown as ESLint.Plugin,
31
+ },
32
+ rules: {
33
+ ...css.configs.recommended.rules,
34
+ },
35
+ };
@@ -0,0 +1,32 @@
1
+ import htmlPlugin from '@html-eslint/eslint-plugin';
2
+ import htmlParser from '@html-eslint/parser';
3
+ import { ESLint, Linter } from 'eslint';
4
+
5
+ import { htmlFiles } from '../../../configs/file-globs-config';
6
+
7
+ /**
8
+ * ESLint Flat Config for linting HTML files using `@html-eslint`.
9
+ *
10
+ * This configuration applies HTML-specific best practices and ensures
11
+ * semantic correctness, accessibility, and proper formatting of HTML documents.
12
+ *
13
+ * It uses the custom parser `@html-eslint/parser` to interpret HTML syntax
14
+ * and the recommended rule set from `@html-eslint/eslint-plugin`.
15
+ *
16
+ * Applies only to `.html` files.
17
+ *
18
+ * @see https://html-eslint.org/docs/rules
19
+ */
20
+ export const htmlEslintConfig: Linter.FlatConfig = {
21
+ files: [htmlFiles],
22
+ ignores: [],
23
+ plugins: {
24
+ '@html-eslint': htmlPlugin as unknown as ESLint.Plugin,
25
+ },
26
+ languageOptions: {
27
+ parser: htmlParser,
28
+ },
29
+ rules: {
30
+ ...htmlPlugin.configs['flat/recommended'].rules,
31
+ },
32
+ };
@@ -0,0 +1,84 @@
1
+ import js from '@eslint/js';
2
+ import { Linter } from 'eslint';
3
+ import importPlugin from 'eslint-plugin-import';
4
+ import tsEslint from 'typescript-eslint';
5
+
6
+ import { jsFiles, tsFiles } from '../../../configs/file-globs-config';
7
+
8
+ /**
9
+ * Shared import-related ESLint rules applied across both JavaScript and TypeScript.
10
+ *
11
+ * Includes cycle detection, discourages dynamic `require`, and disallows usage of core Node.js modules directly.
12
+ */
13
+ const sharedImportRules: Record<string, Linter.RuleEntry | undefined> = {
14
+ ...importPlugin.flatConfigs.recommended.rules,
15
+ 'import/no-cycle': [
16
+ 'error',
17
+ {
18
+ maxDepth: Infinity,
19
+ ignoreExternal: false,
20
+ allowUnsafeDynamicCyclicDependency: false,
21
+ disableScc: false,
22
+ },
23
+ ],
24
+ 'import/no-dynamic-require': 'warn',
25
+ 'import/no-nodejs-modules': 'warn',
26
+ };
27
+
28
+ /**
29
+ * JavaScript-specific import rules.
30
+ * Enables base `no-unused-vars` since TypeScript version is not in use.
31
+ */
32
+ const jsImportRules: Record<string, Linter.RuleEntry | undefined> = {
33
+ ...sharedImportRules,
34
+ 'no-unused-vars': 'warn',
35
+ };
36
+
37
+ /**
38
+ * TypeScript-specific import rules.
39
+ * Disables base `no-unused-vars` in favor of the TypeScript-aware variant from `@typescript-eslint`.
40
+ */
41
+ const tsImportRules: Record<string, Linter.RuleEntry | undefined> = {
42
+ ...sharedImportRules,
43
+ 'no-unused-vars': 'off',
44
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
45
+ };
46
+
47
+ /**
48
+ * ESLint Flat Config for managing import conventions, cycles, and unused rules
49
+ * for both JavaScript and TypeScript environments.
50
+ *
51
+ * - Uses `eslint-plugin-import` for best practices
52
+ * - Applies proper rules per language
53
+ * - Configures import resolver for TS files
54
+ *
55
+ * @see https://github.com/import-js/eslint-plugin-import
56
+ */
57
+ export const importEslintConfig: Linter.FlatConfig[] = [
58
+ // JavaScript configuration block
59
+ js.configs.recommended,
60
+ importPlugin.flatConfigs.recommended,
61
+ {
62
+ files: [jsFiles],
63
+ languageOptions: {
64
+ ecmaVersion: 'latest',
65
+ sourceType: 'module',
66
+ },
67
+ rules: jsImportRules,
68
+ },
69
+
70
+ // TypeScript configuration block
71
+ ...tsEslint.config({
72
+ files: [tsFiles],
73
+ extends: [importPlugin.flatConfigs.recommended, importPlugin.flatConfigs.typescript],
74
+ rules: tsImportRules,
75
+ settings: {
76
+ 'import/resolver': {
77
+ typescript: {
78
+ alwaysTryTypes: true,
79
+ },
80
+ node: true,
81
+ },
82
+ },
83
+ }),
84
+ ];
@@ -0,0 +1,27 @@
1
+ import js from '@eslint/js';
2
+ import { Linter } from 'eslint';
3
+
4
+ import { jsFilesLoose } from '../../../configs/file-globs-config';
5
+
6
+ /**
7
+ * ESLint Flat Config for standard JavaScript files.
8
+ *
9
+ * Applies:
10
+ * - ESLint's built-in recommended rules via `@eslint/js`
11
+ * - Supports both `.js` and `.jsx` files (loose JS pattern)
12
+ * - Configured for ECMAScript Modules (`sourceType: 'module'`)
13
+ *
14
+ * @see https://eslint.org/docs/latest/rules/
15
+ */
16
+ export const javascriptEslintConfig: Linter.FlatConfig = {
17
+ files: [jsFilesLoose],
18
+ ignores: [],
19
+ languageOptions: {
20
+ ...js.languageOptions,
21
+ sourceType: 'module',
22
+ },
23
+ plugins: js.plugins,
24
+ rules: {
25
+ ...js.configs.recommended.rules,
26
+ },
27
+ };