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 22 commits into
base: main
Choose a base branch
from
Open

Conversation

jdegand
Copy link
Contributor

@jdegand jdegand commented Jul 16, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

Change to ESLint flat config.

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Outdated ESLint configuration. Failing lint command in package.json.

Closes #4883

What is the new behavior?

ESLint works with lint command.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

There are quite a few lint tests failing.

Copy link

netlify bot commented Jul 16, 2025

Deploy Preview for ngrx-site-v19 ready!

Name Link
🔨 Latest commit 825948e
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-site-v19/deploys/6897f5504a5f0000081db740
😎 Deploy Preview https://deploy-preview-4887--ngrx-site-v19.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jul 16, 2025

Deploy Preview for ngrx-io canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 825948e
🔍 Latest deploy log https://app.netlify.com/projects/ngrx-io/deploys/6897f5501a3a3e000860e350

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

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

The migration looks good.
Can you look at the lint errors please to make the build pass?

@timdeschryver
Copy link
Member

@jdegand there seem to be some linting issues.
Are you planning to take a look at them?

@timdeschryver timdeschryver added the Needs Cleanup Review changes needed label Aug 4, 2025
@jdegand
Copy link
Contributor Author

jdegand commented Aug 4, 2025

@timdeschryver I think some issues stem from this in the config files:

parserOptions: {
          project: ['modules/effects/testing/tsconfig.*?.json'],
},

There are issues resolving file paths. I going to try tweaking this first.

Changing the wildcard helped 3 more lints pass.

@jdegand
Copy link
Contributor Author

jdegand commented Aug 5, 2025

Using

import baseConfig from '../../eslint.config.mjs';
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
import cypressPlugin from 'eslint-plugin-cypress';

export default [
  {
    ignores: ['**/dist'],
  },
  ...baseConfig,

  {
    plugins: {
      '@typescript-eslint': typescriptEslintEslintPlugin,
      cypress: cypressPlugin,
    },
  },
  {
    rules: {},
  },
  {
    files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
    rules: {},
    languageOptions: {
      parserOptions: {
        project: 'projects/example-app-e2e/tsconfig.*.json',
      },
    },
  },
  {
    files: ['src/plugins/index.js'],
    rules: {
      '@typescript-eslint/no-var-requires': 'off',
      'no-undef': 'off',
    },
  },
  {
    ignores: ['schematics-core'],
  },

  // ✅ Cypress E2E overrides
  {
    files: ['src/**/*.cy.{ts,tsx}'],
    plugins: {
      cypress: cypressPlugin,
    },
    languageOptions: {
      parserOptions: {
        project: null,
      },
    },
    rules: {},
  },
];

for the standalone and example app and not using FlatCompat at all works. FlatCompat has potential incompatibilities. I have tried extending the recommended config and ignoring name to no avail. Also, there is a potential issue with a missing @types/cypress dependency in the tsconfig.json. This causes a warning, but no real difference. The types can be included or deleted.

@jdegand
Copy link
Contributor Author

jdegand commented Aug 5, 2025

There seem to be inconsistencies between the results of CI tests and what I get in a GitHub codespace. I am getting more lint successes in a GitHub codespace. If high CPU usage happens in the codespace, results seem to become unreliable.

@timdeschryver
Copy link
Member

@jdegand the cypress plugin will be removed in #4891.
It's ok to just remove it here as well if that makes it easier.

@jdegand
Copy link
Contributor Author

jdegand commented Aug 5, 2025

Now, I think the question mark after the wildcard didn't make a difference (modules/effects/testing/tsconfig.*?.json).
ngrx.io config has the *? syntax and still works. Let me know a preference and this can be changed.

Running pnpm lint causes high CPU usage in the codespace and then things become unreliable. It is better to lint a few projects separately (npx nx run store:lint, etc) so a few cached values help performance of the codespace.

I changed the two e2e configs so the cypress-plugin can be removed.

@jdegand jdegand requested a review from timdeschryver August 7, 2025 01:46
@jdegand
Copy link
Contributor Author

jdegand commented Aug 7, 2025

projects/www/src/app/pages/guide/data/entity-metadata.md got added to the PR after merging main? It is incorrectly formatted, but it still made it pass the husky lint?

@markostanimirovic markostanimirovic removed the Needs Cleanup Review changes needed label Aug 9, 2025
Comment on lines 11 to 13
"paths": {
"@ngrx/store": ["src"]
},
Copy link
Member

Choose a reason for hiding this comment

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

is this change required?

Copy link
Contributor Author

@jdegand jdegand Aug 10, 2025

Choose a reason for hiding this comment

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

This was part of my debugging (this is just helping to point to the correct files to lint) and it's not necessary. Looks like the only file I did this in.

@@ -92,7 +92,8 @@
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json",
Copy link
Member

Choose a reason for hiding this comment

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

it seems this line can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there is a leftover eslintrc.json file in the projects/www folder. Because it uses analog, I guess the nx script skipped converting it automatically. I guess this can be converted as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've had some issues getting this working perfectly, but it looks there will be extra lint errors that need to be fixed inside the www folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new style guide generated quite a few errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if you want this included into this PR or a separate PR. I created another branch to work on and implemented fixes there. I can easily do whatever you prefer. Although it does clutter the PR, I did remove standalone:true from a lot of components in the www folder (might as well do it now).

Comment on lines 158 to 161
return PropsFilterFnFactory<Villain>[('name', 'saying')](
entities,
pattern
return (
PropsFilterFnFactory <
Villain >
[('name', 'saying')](entities, pattern)
Copy link
Member

Choose a reason for hiding this comment

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

can you revert this change?

Copy link
Contributor Author

@jdegand jdegand Aug 10, 2025

Choose a reason for hiding this comment

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

I used no-verify to revert the file.

@markostanimirovic markostanimirovic changed the title chore(eslint): migrate config to flat format chore: migrate eslint config to flat format Aug 10, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.eslintrc.json files are deprecated
3 participants