@ovh-ux/manager-static-analysis-kit 0.2.0 → 0.3.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/CHANGELOG.md +11 -0
- package/bin/lint-cli.js +1 -1
- package/package.json +8 -5
- package/eslint.config.mjs +0 -53
- package/scripts/build.ts +0 -44
- package/src/adapters/code-health-meter/README.md +0 -1
- package/src/adapters/code-health-meter/config/.gitkeep +0 -0
- package/src/adapters/code-health-meter/rules/.gitkeep +0 -0
- package/src/adapters/eslint/README.md +0 -317
- package/src/adapters/eslint/config/eslint-shared-config.ts +0 -60
- package/src/adapters/eslint/rules/eslint-a11y.ts +0 -30
- package/src/adapters/eslint/rules/eslint-complexity.ts +0 -87
- package/src/adapters/eslint/rules/eslint-css.ts +0 -35
- package/src/adapters/eslint/rules/eslint-html.ts +0 -32
- package/src/adapters/eslint/rules/eslint-imports.ts +0 -84
- package/src/adapters/eslint/rules/eslint-javascript.ts +0 -27
- package/src/adapters/eslint/rules/eslint-naming-conventions.ts +0 -49
- package/src/adapters/eslint/rules/eslint-prettier.ts +0 -29
- package/src/adapters/eslint/rules/eslint-react.ts +0 -50
- package/src/adapters/eslint/rules/eslint-storybook.ts +0 -29
- package/src/adapters/eslint/rules/eslint-tailwind-jsx.ts +0 -21
- package/src/adapters/eslint/rules/eslint-tanstack.ts +0 -25
- package/src/adapters/eslint/rules/eslint-tests.ts +0 -35
- package/src/adapters/eslint/rules/eslint-typescript.ts +0 -33
- package/src/adapters/eslint/types/eslint-js.d.ts +0 -4
- package/src/adapters/eslint/types/eslint-plugin-jsx-a11y.d.ts +0 -16
- package/src/adapters/eslint/types/eslint-plugin-react-hooks.d.ts +0 -9
- package/src/adapters/eslint/types/eslint-plugin-react.d.ts +0 -9
- package/src/adapters/eslint/types/eslint-plugin-tailwindcss.d.ts +0 -6
- package/src/adapters/eslint/types/eslint-shared-config.d.ts +0 -3
- package/src/adapters/jscpd/README.md +0 -0
- package/src/adapters/jscpd/config/.gitkeep +0 -0
- package/src/adapters/jscpd/rules/.gitkeep +0 -0
- package/src/adapters/madge/README.md +0 -0
- package/src/adapters/madge/config/.gitkeep +0 -0
- package/src/adapters/madge/rules/.gitkeep +0 -0
- package/src/adapters/ts-config/README.md +0 -153
- package/src/adapters/ts-config/config/standard/tsconfig.node.ts +0 -13
- package/src/adapters/ts-config/config/standard/tsconfig.react.ts +0 -15
- package/src/adapters/ts-config/config/standard/tsconfig.test.ts +0 -13
- package/src/adapters/ts-config/config/strict/tsconfig.node.ts +0 -13
- package/src/adapters/ts-config/config/strict/tsconfig.react.ts +0 -15
- package/src/adapters/ts-config/config/strict/tsconfig.test.ts +0 -13
- package/src/adapters/ts-config/rules/tsconfig.base.strict.ts +0 -13
- package/src/adapters/ts-config/rules/tsconfig.base.ts +0 -17
- package/src/code-analysis.ts +0 -1
- package/src/configs/complexity-config.ts +0 -29
- package/src/configs/file-globs-config.ts +0 -22
- package/src/configs/import-order-config.ts +0 -12
- package/src/configs/jscpd-config.ts +0 -8
- package/src/configs/madge-config.ts +0 -8
- package/src/configs/naming-conventions-config.ts +0 -138
- package/src/configs/prettier-config.ts +0 -81
- package/src/configs/shared-exclusion-patterns.ts +0 -41
- package/tsconfig.json +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.3.0](https://github.com/ovh/manager/compare/@ovh-ux/manager-static-analysis-kit@0.2.0...@ovh-ux/manager-static-analysis-kit@0.3.0) (2025-07-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add required configuration for public package ([391502d](https://github.com/ovh/manager/commit/391502dd08a9a4b198ec13bac74150ed01836038)), closes [#MANAGER-17954](https://github.com/ovh/manager/issues/MANAGER-17954)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.2.0](https://github.com/ovh/manager/compare/@ovh-ux/manager-static-analysis-kit@0.1.0...@ovh-ux/manager-static-analysis-kit@0.2.0) (2025-07-17)
|
|
7
18
|
|
|
8
19
|
|
package/bin/lint-cli.js
CHANGED
|
@@ -13,7 +13,7 @@ const eslintBin = resolve(__dirname, '../node_modules/.bin/eslint');
|
|
|
13
13
|
const args = process.argv.slice(2);
|
|
14
14
|
const hasExplicitConfigArg = args.includes('--config');
|
|
15
15
|
const localConfigPath = join(userCwd, 'eslint.config.ts');
|
|
16
|
-
const sharedDefaultPath = resolve(__dirname, '../dist/adapters/eslint/config/eslint
|
|
16
|
+
const sharedDefaultPath = resolve(__dirname, '../dist/adapters/eslint/config/eslint-shared-config.js');
|
|
17
17
|
const hasLocalConfig = existsSync(localConfigPath);
|
|
18
18
|
|
|
19
19
|
// Determine effective config path
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ovh-ux/manager-static-analysis-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A modular, extensible, and future-ready toolkit for defining, adapting, and sharing static analysis rules across projects in the `manager` monorepo.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -83,13 +83,18 @@
|
|
|
83
83
|
"bin": {
|
|
84
84
|
"manager-lint": "./bin/lint-cli.js"
|
|
85
85
|
},
|
|
86
|
+
"files": [
|
|
87
|
+
"dist",
|
|
88
|
+
"bin",
|
|
89
|
+
"README.md"
|
|
90
|
+
],
|
|
86
91
|
"scripts": {
|
|
87
92
|
"build": "tsx scripts/build.ts",
|
|
88
93
|
"lint:modern": "manager-lint --config eslint.config.mjs ./src",
|
|
89
94
|
"lint:modern:fix": "manager-lint --fix --config eslint.config.mjs ./src",
|
|
90
95
|
"test": "echo \"No tests yet.\" && exit 0"
|
|
91
96
|
},
|
|
92
|
-
"
|
|
97
|
+
"dependencies": {
|
|
93
98
|
"@eslint/css": "^0.9.0",
|
|
94
99
|
"@eslint/js": "^9.29.0",
|
|
95
100
|
"@html-eslint/eslint-plugin": "^0.42.0",
|
|
@@ -117,11 +122,9 @@
|
|
|
117
122
|
"prettier": "^3.6.2",
|
|
118
123
|
"prettier-plugin-tailwindcss": "^0.6.13",
|
|
119
124
|
"tailwind-csstree": "^0.1.1",
|
|
125
|
+
"tailwindcss": "^3.4.4",
|
|
120
126
|
"tsx": "^4.20.3",
|
|
121
127
|
"typescript": "^5.8.3",
|
|
122
128
|
"typescript-eslint": "^8.35.0"
|
|
123
|
-
},
|
|
124
|
-
"peerDependencies": {
|
|
125
|
-
"eslint": "^9.29.0"
|
|
126
129
|
}
|
|
127
130
|
}
|
package/eslint.config.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { javascriptEslintConfig } from './src/adapters/eslint/rules/eslint-javascript'
|
|
2
|
-
import { typescriptEslintConfig } from './src/adapters/eslint/rules/eslint-typescript';
|
|
3
|
-
import { reactEslintConfig } from './src/adapters/eslint/rules/eslint-react';
|
|
4
|
-
import { tanStackQueryEslintConfig } from './src/adapters/eslint/rules/eslint-tanstack';
|
|
5
|
-
import { importEslintConfig } from './src/adapters/eslint/rules/eslint-imports';
|
|
6
|
-
import { checkFileEslintConfig } from './src/adapters/eslint/rules/eslint-naming-conventions';
|
|
7
|
-
import { vitestEslintConfig } from './src/adapters/eslint/rules/eslint-tests';
|
|
8
|
-
import { prettierEslintConfig } from './src/adapters/eslint/rules/eslint-prettier';
|
|
9
|
-
import { complexityJsxTsxConfig, complexityTsJsConfig } from './src/adapters/eslint/rules/eslint-complexity';
|
|
10
|
-
|
|
11
|
-
export default [
|
|
12
|
-
javascriptEslintConfig,
|
|
13
|
-
typescriptEslintConfig,
|
|
14
|
-
reactEslintConfig,
|
|
15
|
-
tanStackQueryEslintConfig,
|
|
16
|
-
...importEslintConfig,
|
|
17
|
-
...checkFileEslintConfig,
|
|
18
|
-
vitestEslintConfig,
|
|
19
|
-
prettierEslintConfig,
|
|
20
|
-
complexityJsxTsxConfig,
|
|
21
|
-
complexityTsJsConfig,
|
|
22
|
-
{
|
|
23
|
-
ignores: [
|
|
24
|
-
'**/*.md',
|
|
25
|
-
'**/coverage/**',
|
|
26
|
-
'**/dist/**',
|
|
27
|
-
'**/*.d.ts',
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
rules: {
|
|
32
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
33
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
34
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
files: ['**/prettier-config.ts', '**/*.config.{ts,js,mjs}'],
|
|
39
|
-
rules: {
|
|
40
|
-
'import/no-nodejs-modules': 'off',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
files: [
|
|
45
|
-
'**/ts-config/config/standard/tsconfig.test.ts',
|
|
46
|
-
'**/ts-config/config/strict/tsconfig.test.ts',
|
|
47
|
-
],
|
|
48
|
-
rules: {
|
|
49
|
-
'check-file/folder-match-with-fex': 'off',
|
|
50
|
-
'check-file/filename-naming-convention': 'off',
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
];
|
package/scripts/build.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { writeFileSync, rmSync, mkdirSync, existsSync } from 'node:fs';
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
import { pathToFileURL } from 'node:url';
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const root = resolve(import.meta.dirname, '..');
|
|
9
|
-
const dist = resolve(root, 'dist');
|
|
10
|
-
|
|
11
|
-
console.log('🧹 Cleaning dist...');
|
|
12
|
-
rmSync(dist, { recursive: true, force: true });
|
|
13
|
-
|
|
14
|
-
console.log('🛠️ Building TypeScript...');
|
|
15
|
-
execSync('tsc --project tsconfig.json', { stdio: 'inherit' });
|
|
16
|
-
|
|
17
|
-
console.log('📦 Flattening TypeScript config files...');
|
|
18
|
-
|
|
19
|
-
const configs: [string, string][] = [
|
|
20
|
-
['src/adapters/ts-config/config/standard/tsconfig.react.ts', 'tsconfig/react.json'],
|
|
21
|
-
['src/adapters/ts-config/config/standard/tsconfig.node.ts', 'tsconfig/node.json'],
|
|
22
|
-
['src/adapters/ts-config/config/standard/tsconfig.test.ts', 'tsconfig/test.json'],
|
|
23
|
-
['src/adapters/ts-config/config/strict/tsconfig.react.ts', 'tsconfig/react-strict.json'],
|
|
24
|
-
['src/adapters/ts-config/config/strict/tsconfig.node.ts', 'tsconfig/node-strict.json'],
|
|
25
|
-
['src/adapters/ts-config/config/strict/tsconfig.test.ts', 'tsconfig/test-strict.json'],
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
for (const [sourcePath, destPath] of configs) {
|
|
29
|
-
const srcFullPath = resolve(root, sourcePath);
|
|
30
|
-
const destFullPath = resolve(dist, destPath);
|
|
31
|
-
const destDir = resolve(dist, destPath.split('/').slice(0, -1).join('/'));
|
|
32
|
-
|
|
33
|
-
if (!existsSync(destDir)) {
|
|
34
|
-
mkdirSync(destDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const configModule = await import(pathToFileURL(srcFullPath).href);
|
|
38
|
-
const config = configModule.default;
|
|
39
|
-
|
|
40
|
-
writeFileSync(destFullPath, JSON.stringify(config, null, 2), 'utf8');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log('✅ Build completed with flattened tsconfigs.');
|
|
44
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# code-health-meter
|
|
File without changes
|
|
File without changes
|
|
@@ -1,317 +0,0 @@
|
|
|
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
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
];
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
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
|
-
};
|