Skip to content

chore: migrate eslint config to flat format #4887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1254db9
feat: replace eslintrc.json files
jdegand Jul 15, 2025
5661c1e
fix: remove reference to eslintrc.json in nx.json
jdegand Jul 15, 2025
727cb96
feat(package.json): change lint command
jdegand Jul 16, 2025
6764780
chore(eslint): add ts-check to config files
jdegand Jul 17, 2025
e8d26e3
Revert "chore(eslint): add ts-check to config files"
jdegand Jul 17, 2025
15a5c96
fix: change wildcard in parserOptions
jdegand Aug 4, 2025
441378f
fix: cypress config in example-app
jdegand Aug 5, 2025
30f9b8f
refactor: cypress configs
jdegand Aug 5, 2025
8671a5a
fix: effects config project file path
jdegand Aug 5, 2025
4fa1936
fix: exclude files for data config
jdegand Aug 5, 2025
f20590c
fix: exclude jest in configs
jdegand Aug 5, 2025
3e5cb40
fix(entity): exclude standalone
jdegand Aug 5, 2025
3595758
fix: component-store, component, and potentially router-store
jdegand Aug 5, 2025
89b5d53
fix: exclude test-setup in router-store
jdegand Aug 5, 2025
0427dd6
fix: exclude jest in store config
jdegand Aug 5, 2025
9baba88
fix: exclude module boundaries
jdegand Aug 5, 2025
59d187f
fix: remove references to store in effects config
jdegand Aug 5, 2025
70c6a30
fix: remove cypress plugin from configs
jdegand Aug 5, 2025
a0ecfb4
chore: merge main
jdegand Aug 7, 2025
4b12129
fix: pnpm-lock
jdegand Aug 7, 2025
49757c0
revert: md file
jdegand Aug 10, 2025
825948e
fix: tsconfig in store
jdegand Aug 10, 2025
d0cc0bb
chore: convert to eslint config in www
jdegand Aug 12, 2025
abdadfa
fix: lint errors and most warnings
jdegand Aug 12, 2025
dda0e34
Merge branch 'main' into eslint
jdegand Aug 12, 2025
3dd0f0f
fix: index.html
jdegand Aug 12, 2025
530c2d8
fix: update tags
jdegand Aug 12, 2025
f6ed7de
fix: my-counter tags
jdegand Aug 12, 2025
e6e1cda
fix: import AppComponent
jdegand Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

84 changes: 0 additions & 84 deletions .eslintrc.json

This file was deleted.

110 changes: 110 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { FlatCompat } from '@eslint/eslintrc';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import js from '@eslint/js';
import nxEslintPlugin from '@nx/eslint-plugin';

const compat = new FlatCompat({
baseDirectory: dirname(fileURLToPath(import.meta.url)),
recommendedConfig: js.configs.recommended,
});

export default [
{
ignores: ['**/dist'],
},
{ plugins: { '@nx': nxEslintPlugin } },
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
allow: [],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
'@typescript-eslint/member-ordering': 'off',
'@typescript-eslint/no-inferrable-types': 'warn',
},
},
...compat
.config({
extends: ['plugin:@nx/typescript'],
})
.map((config) => ({
...config,
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
rules: {
...config.rules,
'no-extra-semi': 'off',
},
})),
...compat
.config({
extends: ['plugin:@nx/javascript'],
})
.map((config) => ({
...config,
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
rules: {
...config.rules,
'no-extra-semi': 'off',
},
})),
...compat
.config({
plugins: ['eslint-plugin-import', '@typescript-eslint'],
})
.map((config) => ({
...config,
files: ['**/*.ts'],
rules: {
...config.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
eqeqeq: ['off', 'smart'],
'id-blacklist': [
'error',
'any',
'Number',
'number',
'String',
'string',
'Boolean',
'boolean',
'Undefined',
'undefined',
],
'id-match': 'error',
'no-eval': 'off',
'no-redeclare': 'off',
'no-underscore-dangle': 'off',
'no-var': 'error',
'no-prototype-builtins': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
},
})),
{
files: ['**/*.html'],
// Override or add rules here
rules: {},
},
];
27 changes: 0 additions & 27 deletions modules/component-store/.eslintrc.json

This file was deleted.

54 changes: 54 additions & 0 deletions modules/component-store/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { FlatCompat } from '@eslint/eslintrc';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import js from '@eslint/js';
import baseConfig from '../../eslint.config.mjs';

const compat = new FlatCompat({
baseDirectory: dirname(fileURLToPath(import.meta.url)),
recommendedConfig: js.configs.recommended,
});

export default [
{
ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core/test-setup.ts', '**/schematics-core/utility/standalone.ts'],
Copy link
Member

@timdeschryver timdeschryver Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add this to the base config and remove it in the module specific configs?

In the base config:

    ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core'],

I don't remember why we excluded these, this can be looked into later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the exclusions were added to match previous files. The lints fail without them.

Copy link
Contributor Author

@jdegand jdegand Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential option is to add .eslintignore files and add the files there.

In base config, could add an overrides array like this:

  overrides: [
    {
      files: ['**/jest.config.ts'],
      env: { node: true },
      rules: {
        // customize rules for config files
      },
    },
    {
      files: ['**/schematics-core/**/*.ts'],
      env: { node: true },
      rules: {
        // loosen rules or add globals as needed
      },
    },
  ],

Typically, files are ignored if they use "globals" or unusual patterns that could break if linted. Code that uses TypeScript AST, Node.js (node vs web environments), and schematics is also typically ignored. That standalone utility looks a stop-gap or bridge file and may be something that could potentially be removed as bootstrapApplication can make standalone components.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, we don't need to add a eslintignore - AFAIK this isn't supported anymore.

},
...baseConfig,
...compat
.config({
extends: [
'plugin:@nx/angular',
'plugin:@angular-eslint/template/process-inline-templates',
],
plugins: ['@typescript-eslint'],
})
.map((config) => ({
...config,
files: ['**/*.ts'],
rules: {
...config.rules,
'@angular-eslint/directive-selector': 'off',
'@angular-eslint/component-selector': 'off',
'@angular-eslint/prefer-standalone': 'off',
},
languageOptions: {
parserOptions: {
project: ['modules/component-store/tsconfig.*.json'],
},
},
})),
...compat
.config({
extends: ['plugin:@nx/angular-template'],
})
.map((config) => ({
...config,
files: ['**/*.html'],
rules: {
...config.rules,
},
})),
{
ignores: ['schematics-core'],
},
];
6 changes: 3 additions & 3 deletions modules/component-store/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"projectType": "library",
"sourceRoot": "modules/component-store/src",
"prefix": "ngrx",
"tags": [],
"generators": {},
"targets": {
"build-package": {
"executor": "@angular-devkit/build-angular:ng-packagr",
Expand Down Expand Up @@ -49,7 +51,5 @@
},
"outputs": ["{workspaceRoot}/coverage/modules/component-store"]
}
},
"generators": {},
"tags": []
}
}
28 changes: 0 additions & 28 deletions modules/component/.eslintrc.json

This file was deleted.

55 changes: 55 additions & 0 deletions modules/component/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { FlatCompat } from '@eslint/eslintrc';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import js from '@eslint/js';
import baseConfig from '../../eslint.config.mjs';

const compat = new FlatCompat({
baseDirectory: dirname(fileURLToPath(import.meta.url)),
recommendedConfig: js.configs.recommended,
});

export default [
{
ignores: ['**/dist', '**/jest.config.ts', '**/schematics-core/test-setup.ts', '**/schematics-core/utility/standalone.ts'],
},
...baseConfig,
...compat
.config({
extends: [
'plugin:@nx/angular',
'plugin:@angular-eslint/template/process-inline-templates',
],
plugins: ['@typescript-eslint'],
})
.map((config) => ({
...config,
files: ['**/*.ts'],
rules: {
...config.rules,
'@angular-eslint/directive-selector': 'off',
'@angular-eslint/component-selector': 'off',
'@angular-eslint/no-input-rename': 'off',
'@angular-eslint/prefer-standalone': 'off',
},
languageOptions: {
parserOptions: {
project: ['modules/component/tsconfig.*.json'],
},
},
})),
...compat
.config({
extends: ['plugin:@nx/angular-template'],
})
.map((config) => ({
...config,
files: ['**/*.html'],
rules: {
...config.rules,
},
})),
{
ignores: ['schematics-core'],
},
];
Loading