forked from ever-co/ever-gauzy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
100 lines (93 loc) · 4.39 KB
/
Copy patheslint.config.js
File metadata and controls
100 lines (93 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Root ESLint flat config for the Ever Gauzy workspace.
*
* ESLint 9 reads `eslint.config.js` and never reads `.eslintrc.json`. The previous version of
* this file did:
*
* const { FlatESLint } = require('@nx/eslint-plugin-nx');
* module.exports = new FlatESLint({ overrides: [] });
*
* which could never have worked: a flat config must export an ARRAY, no Nx package has ever
* exported a `FlatESLint` class, and `@nx/[email protected]` is the beta-only
* predecessor name of `@nx/eslint-plugin`. Requiring it pulled a nested `@nx/devkit@16` that
* expects an `nx` internal path nx@22 no longer ships, so every `eslint` invocation in the
* workspace died with `Cannot find module 'nx/src/utils/typescript'`.
*
* Shape below follows what Nx 22 generates itself — see
* `@nx/eslint/src/generators/init/global-eslint-config.js` (`getGlobalFlatEslintConfiguration`).
*
* Project configs inherit this file directly (`require('../../eslint.config.js')`). They used to
* spread the legacy `.eslintrc.json`, which is a JSON *object*, so `[...baseConfig]` threw
* `TypeError: baseConfig is not iterable` and every `nx lint <project>` failed.
*/
const nx = require('@nx/eslint-plugin');
// Files ESLint should never look at. Replaces the legacy root `.eslintrc.json`'s
// `"ignorePatterns": ["**/*"]`, which disabled linting for the entire workspace.
//
// Declared as a named binding rather than inline in the array below: Codacy's PMD parses a
// bare object literal in that position as a block statement and reports "Unnecessary block".
// After `=` there is no such ambiguity. `name` is a real ESLint 9 flat-config field, which
// surfaces in config inspection; typescript-eslint's own bundled configs set it too.
const globalIgnores = {
name: 'gauzy/global-ignores',
ignores: [
'**/node_modules',
'**/dist',
'**/build',
'**/out-tsc',
'**/coverage',
'**/.angular',
'**/.nx',
'**/*.d.ts',
// Generated TypeORM migrations: several hundred machine-written files that dominate
// both the lint wall clock and the finding count, and that nobody hand-edits.
'packages/core/src/lib/database/migrations/**',
// Codegen output.
'**/*.generated.ts',
'packages/plugins/integration-ai/src/lib/sdk/gauzy-ai-sdk.ts',
'**/src/assets/**'
]
};
module.exports = [
// Registers the `@nx` plugin namespace (enforce-module-boundaries, dependency-checks,
// nx-plugin-checks) that the project configs rely on.
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
globalIgnores,
{
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts', '**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
rules: {
// Carried over from the legacy root config, with the plugin renamed `@nrwl/nx` -> `@nx`.
// The `allow` entry is Nx 22's default and is what lets a project's eslint.config.js
// require this file without tripping the boundary rule on itself.
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?[jt]s$'],
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }]
}
],
// `@nx/eslint-plugin`'s presets still enable this rule, but typescript-eslint
// deprecated it in v8.0.0 and replaced it with `no-empty-object-type`, which the
// same presets also enable. Leaving both on double-reports every occurrence
// (90 + 90 in packages/contracts alone). Off, so the count means something.
'@typescript-eslint/no-empty-interface': 'off',
// Preserved from the legacy root config: formatting is Prettier's job.
// The legacy config also disabled `@typescript-eslint/comma-dangle`; that rule no
// longer exists in typescript-eslint v8 (it moved to @stylistic), so it is dropped
// rather than carried forward as a name that can never resolve.
'comma-dangle': 'off',
// Re-enabled deliberately. `typescript-eslint`'s `eslint-recommended` overlay — pulled
// in by `nx.configs['flat/typescript']` — turns these OFF on the grounds that `tsc`
// already reports them. That reasoning does not hold here: no CI job in this
// workspace runs `tsc --noEmit`, and a duplicate object key in `packages/core/jest.config.ts`
// has already silently changed behaviour once. These are the guardrail.
'no-dupe-keys': 'error',
'no-dupe-class-members': 'error',
'no-dupe-args': 'error',
'no-unreachable': 'error'
}
}
];