Skip to content

@nx/eslint workspace-rule generator generates broken rule test #29252

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

Closed
1 of 4 tasks
GeorgeKnap opened this issue Dec 8, 2024 · 6 comments · Fixed by #29253
Closed
1 of 4 tasks

@nx/eslint workspace-rule generator generates broken rule test #29252

GeorgeKnap opened this issue Dec 8, 2024 · 6 comments · Fixed by #29253
Assignees
Labels
scope: linter Issues related to Eslint support in Nx type: bug

Comments

@GeorgeKnap
Copy link

Current Behavior

In NX 20.2 (also in previous versions) scaffolded eslint rule doesn't scaffold runnable rule test. This is the error that it produces:

FAIL   eslint-rules  tools/eslint-rules/rules/foo.spec.ts
  foo
    valid
      × const example = true; (18 ms)
  ● foo › valid › const example = true;
    ConfigError: ESLint configuration in rule-tester is invalid: Config (unnamed): Key "parser": This appears to be in eslintrc format rather than flat config format.

      at rethrowConfigError (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:328:8)
      at ../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1174:5
          at Array.reduce (<anonymous>)
      at FlatConfigArray.getConfigWithStatus (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1167:43)
      at FlatConfigArray.getConfig (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1196:15)
      at runRuleForItem (../../node_modules/eslint/lib/rule-tester/rule-tester.js:807:25)
      at testValidTemplate (../../node_modules/eslint/lib/rule-tester/rule-tester.js:922:28)
      at Object.<anonymous> (../../node_modules/eslint/lib/rule-tester/rule-tester.js:1274:37)
    Cause:
    Key "parser": This appears to be in eslintrc format rather than flat config format.

      at ObjectSchema.validate (../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:440:11)
      at ../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:383:9
          at Array.reduce (<anonymous>)
      at ObjectSchema.merge (../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:382:18)
      at ../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1169:43
          at Array.reduce (<anonymous>)
      at FlatConfigArray.getConfigWithStatus (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1167:43)
      at FlatConfigArray.getConfig (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1196:15)
      at runRuleForItem (../../node_modules/eslint/lib/rule-tester/rule-tester.js:807:25)
      at testValidTemplate (../../node_modules/eslint/lib/rule-tester/rule-tester.js:922:28)
      at Object.<anonymous> (../../node_modules/eslint/lib/rule-tester/rule-tester.js:1274:37)
    Cause:
    This appears to be in eslintrc format rather than flat config format.

      at Object.validate (../../node_modules/eslint/lib/config/flat-config-schema.js:526:19)
      at ObjectSchema.validate (../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:438:14)
      at ../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:383:9
          at Array.reduce (<anonymous>)
      at ObjectSchema.merge (../../node_modules/@eslint/object-schema/dist/cjs/index.cjs:382:18)
      at ../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1169:43
          at Array.reduce (<anonymous>)
      at FlatConfigArray.getConfigWithStatus (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1167:43)
      at FlatConfigArray.getConfig (../../node_modules/@eslint/config-array/dist/cjs/index.cjs:1196:15)
      at runRuleForItem (../../node_modules/eslint/lib/rule-tester/rule-tester.js:807:25)
      at testValidTemplate (../../node_modules/eslint/lib/rule-tester/rule-tester.js:922:28)
      at Object.<anonymous> (../../node_modules/eslint/lib/rule-tester/rule-tester.js:1274:37)
Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        2.809 s
Ran all test suites.

Expected Behavior

Working rule tests

GitHub Repo

No response

Steps to Reproduce

1.scaffold new NX repo
2. generate workspace eslint rule
3. run eslint-rule tests

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.10.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 10.9.0

nx (global)        : 20.0.0
nx                 : 20.2.1
@nx/js             : 20.2.1
@nx/jest           : 20.2.1
@nx/eslint         : 20.2.1
@nx/workspace      : 20.2.1
@nx/angular        : 20.2.1
@nx/devkit         : 20.2.1
@nx/eslint-plugin  : 20.2.1
@nx/web            : 20.2.1
@nx/webpack        : 20.2.1
typescript         : 5.6.3
---------------------------------------
Community plugins:
angular-eslint : 19.0.1

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@lppedd
Copy link

lppedd commented Jan 13, 2025

@pawel-twardziak any reason to close the PR? Can't see any other commit fixing it.

@pawel-twardziak
Copy link
Contributor

@lppedd I closed my PR because nobody from the team responded it.

@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label Jan 28, 2025
@meeroslav
Copy link
Contributor

Sorry @pawel-twardziak for the long delay. I have re-opened your PR and reviewed it. If you have time, please make the small change requested so that we can merge it in.

Thanks

@pawel-twardziak
Copy link
Contributor

Hi @meeroslav I will look at it 👍

@pawel-twardziak
Copy link
Contributor

@meeroslav fixed

@meeroslav
Copy link
Contributor

Thank you @pawel-twardziak for your contribution!

FrozenPandaz pushed a commit that referenced this issue May 16, 2025
)

Closes #29252

## Current Behavior
See #29252

## Expected Behavior
See #29252

## Related Issue(s)
See #29252

Fixes #
See #29252

---------

Co-authored-by: Miroslav Jonaš <[email protected]>
(cherry picked from commit c4cb96c)
FrozenPandaz pushed a commit that referenced this issue May 16, 2025
)

Closes #29252

## Current Behavior
See #29252

## Expected Behavior
See #29252

## Related Issue(s)
See #29252

Fixes #
See #29252

---------

Co-authored-by: Miroslav Jonaš <[email protected]>
(cherry picked from commit c4cb96c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants