Skip to content
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

Bug: flat configs are processing ignored directories and applying rules that were scoped to other directories #18372

Open
1 task
runspired opened this issue Apr 21, 2024 · 1 comment
Labels
bug ESLint is working incorrectly needs info Not enough information has been provided to triage this issue repro:needed

Comments

@runspired
Copy link

runspired commented Apr 21, 2024

Environment

  • Note: npx eslint --env-info does not function properly with flat config

Node version: v18.20.2 (N/A)
npm version: v10.5.0 (N/A)
Local ESLint version: v8.57.0
Global ESLint version: Not found
Operating System: darwin 22.6.0

Bun: 1.1.2
Pnpm: 8.15.6

What parser are you using?

What did you do?

Note: I'm using flat config which can't be copy pasted due to their size

Configuration
import * as node from '@warp-drive/internal-config/eslint/node.js';
import * as typescript from '@warp-drive/internal-config/eslint/typescript.js';
import * as qunit from '@warp-drive/internal-config/eslint/qunit.js';

/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
  // all ================
  globalIgnores(),

  typescript.browser({
    srcDirs: ['src'],
    allowedImports: [
      '@embroider/macros',
      '@ember/application/namespace',
      'ember',
      'ember-inflector',
      '@ember/debug',
      '@ember/array/proxy',
      '@ember/object/promise-proxy-mixin',
      '@ember/object/proxy',
      '@ember/application',
    ],
  }),

  // node (module) ================
  node.esm(),

  // node (script) ================
  node.cjs(),

  // Test Support
  qunit.ember({
    files: ['src/test-support/**/*.{js,ts}'],
    allowedImports: ['@ember/debug', '@ember/owner'],
  }),
];
bun run eslint . --report-unused-disable-directives

What did you expect to happen?

all lint rules pass as expected

What actually happened?

lint rules failed for files within ignore in a manner that suggests rules but not plugins were applied globally

/Users/cthoburn/github/data/packages/-ember-data/dist/test-support/index.js
  8:3  error  Definition for rule '@typescript-eslint/no-unsafe-member-access' was not found  @typescript-eslint/no-unsafe-member-access

Note: all files parsed by the typescript rules passed successfully. Those rules specify exactly which files to match in the config object under files which in this case is scoped to the directory ./src. So this suggests that rules were hoisted out of a config object and applied both to files that they were not intended to apply to and without the plugin they depend upon.

globalIgnores(), is a list of files and directories to always ignore using the global overrides pattern:

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

Note: the actual list is much longer, but I've shortend it to just what we care about here. Also note how just in case I've tried every variant of directory glob just in case eslint shifted away from dist working as expected. No variation worked.

Debugging with bun run eslint --print-config ./dist/test-support/index.js leads to an interesting observation:

{
  "languageOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module",
    "parser": "[email protected]",
    "parserOptions": {},
    "globals": {}
  },
  "plugins": [
    "@"
  ],
  "rules": {}
}

Based on the ignores this file shouldn't be in the system, but what we see is that default language options have been applied. Note though, no rules ;)

Link to Minimal Reproducible Example

N/A

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Note using the new rules debugger is not possible. eslint --inspect-config errors as --inspect-config is not valid. npx @eslint/config-inspector fails because it cannot find eslint since this is a project that enforces strict node_modules vs dangerously hoisting them like the tool depends upon.

@runspired runspired added bug ESLint is working incorrectly repro:needed labels Apr 21, 2024
@runspired runspired changed the title Bug: (temp) Bug: flat configs are processing ignored directories and applying rules that were scoped to other directories Apr 21, 2024
@mdjermanovic
Copy link
Member

Local ESLint version: v8.57.0

Can you try with the latest ESLint v9.1.0?

If it still doesn't work as expected, please provide a minimal reproducible example as there is not enough information for us to figure out what could be causing the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESLint is working incorrectly needs info Not enough information has been provided to triage this issue repro:needed
Projects
Status: Triaging
Development

No branches or pull requests

2 participants