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: Eslint not working with eslint src/**/*.ts --fix #18347

Open
1 task
macartur opened this issue Apr 15, 2024 · 4 comments
Open
1 task

Bug: Eslint not working with eslint src/**/*.ts --fix #18347

macartur opened this issue Apr 15, 2024 · 4 comments
Labels
bug ESLint is working incorrectly needs info Not enough information has been provided to triage this issue repro:needed

Comments

@macartur
Copy link

Environment

Node version: v20.12.1
npm version: 10.5.0
Local ESLint version: v8.57.0
Operating System: Debian

What parser are you using?

@typescript-eslint/parser

What did you do?

Way to reproduce

Create a file into src/data/get_user/index.ts with a linter error.
Try run the command bellow

npx eslint src/**/*ts

What did you expect to happen?

A expect the file will be read and found typescript errors.

What actually happened?

After run no error will be found because the file was not found.

Link to Minimal Reproducible Example

https://eslint.org/play/#eyJ0ZXh0IjoiLyogZXNsaW50IHF1b3RlczogW1wiZXJyb3JcIiwgXCJkb3VibGVcIl0gKi9cbmNvbnN0IGEgPSBcImJcIjsiLCJvcHRpb25zIjp7InJ1bGVzIjp7ImNvbnN0cnVjdG9yLXN1cGVyIjpbImVycm9yIl0sImZvci1kaXJlY3Rpb24iOlsiZXJyb3IiXSwiZ2V0dGVyLXJldHVybiI6WyJlcnJvciJdLCJuby1hc3luYy1wcm9taXNlLWV4ZWN1dG9yIjpbImVycm9yIl0sIm5vLWNhc2UtZGVjbGFyYXRpb25zIjpbImVycm9yIl0sIm5vLWNsYXNzLWFzc2lnbiI6WyJlcnJvciJdLCJuby1jb21wYXJlLW5lZy16ZXJvIjpbImVycm9yIl0sIm5vLWNvbmQtYXNzaWduIjpbImVycm9yIl0sIm5vLWNvbnN0LWFzc2lnbiI6WyJlcnJvciJdLCJuby1jb25zdGFudC1iaW5hcnktZXhwcmVzc2lvbiI6WyJlcnJvciJdLCJuby1jb25zdGFudC1jb25kaXRpb24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jpbImVycm9yIl0sIm5vLXJlZGVjbGFyZSI6WyJlcnJvciJdLCJuby1yZWdleC1zcGFjZXMiOlsiZXJyb3IiXSwibm8tc2VsZi1hc3NpZ24iOlsiZXJyb3IiXSwibm8tc2V0dGVyLXJldHVybiI6WyJlcnJvciJdLCJuby1zaGFkb3ctcmVzdHJpY3RlZC1uYW1lcyI6WyJlcnJvciJdLCJuby1zcGFyc2UtYXJyYXlzIjpbImVycm9yIl0sIm5vLXRoaXMtYmVmb3JlLXN1cGVyIjpbImVycm9yIl0sIm5vLXVuZGVmIjpbImVycm9yIl0sIm5vLXVuZXhwZWN0ZWQtbXVsdGlsaW5lIjpbImVycm9yIl0sIm5vLXVucmVhY2hhYmxlIjpbImVycm9yIl0sIm5vLXVuc2FmZS1maW5hbGx5IjpbImVycm9yIl0sIm5vLXVuc2FmZS1uZWdhdGlvbiI6WyJlcnJvciJdLCJuby11bnNhZmUtb3B0aW9uYWwtY2hhaW5pbmciOlsiZXJyb3IiXSwibm8tdW51c2VkLWxhYmVscyI6WyJlcnJvciJdLCJuby11bnVzZWQtcHJpdmF0ZS1jbGFzcy1tZW1iZXJzIjpbImVycm9yIl0sIm5vLXVudXNlZC12YXJzIjpbImVycm9yIl0sIm5vLXVzZWxlc3MtYmFja3JlZmVyZW5jZSI6WyJlcnJvciJdLCJuby11c2VsZXNzLWNhdGNoIjpbImVycm9yIl0sIm5vLXVzZWxlc3MtZXNjYXBlIjpbImVycm9yIl0sIm5vLXdpdGgiOlsiZXJyb3IiXSwicmVxdWlyZS15aWVsZCI6WyJlcnJvciJdLCJ1c2UtaXNuYW4iOlsiZXJyb3IiXSwidmFsaWQtdHlwZW9mIjpbImVycm9yIl19LCJsYW5ndWFnZU9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hRmVhdHVyZXMiOnt9fX19fQ==

Participation

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

Additional comments

No response

@macartur macartur added bug ESLint is working incorrectly repro:needed labels Apr 15, 2024
@aladdin-add
Copy link
Member

What does your eslint configuration look like? the "Link to Minimal Reproducible Example" seems not able to repro it.

@aladdin-add aladdin-add added the needs info Not enough information has been provided to triage this issue label Apr 16, 2024
@ValeraKaktotak
Copy link

ValeraKaktotak commented Apr 21, 2024

I have the same problem, When i use "eslint": "^7.32.0" in package.json everything is good. But when i use eslint": "^8.0.1 i have the same problem. Any Ignore rules i don't use. It happens when i use script - "lint": "eslint src/**/*.{tsx,ts}"

yarn run v1.22.19
$ eslint src/**/*.{tsx,ts}

Oops! Something went wrong! :(

ESLint: 8.57.0

You are linting "src//*.{tsx,ts}", but all of the files matching the glob pattern "src//*.{tsx,ts}" are ignored.

If you don't want to lint these files, remove the pattern "src/**/*.{tsx,ts}" from the list of arguments passed to ESLint.

If you do want to lint these files, try the following solutions:

  • Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
  • Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@paulocoghi
Copy link

paulocoghi commented Apr 22, 2024

I'm having the same bug, or at least a similar one.

After updating from ESLint 8.57.0 to 9.0.0 and moving .eslintrc.js to eslint.config.js (without changing anything inside it), I received the error:

Oops! Something went wrong! :(

ESLint: 9.0.0

You are linting "{src,apps,libs,test}/**/*.ts", but all of the files matching the glob pattern "{src,apps,libs,test}/**/*.ts" are ignored.

If you don't want to lint these files, remove the pattern "{src,apps,libs,test}/**/*.ts" from the list of arguments passed to ESLint.

If you do want to lint these files, try the following solutions:

* Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
* Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.

Here is my eslint.config.js:

const isFixMode = process.argv.includes("--fix");

module.exports = {
  parser: "@typescript-eslint/parser",
  extends: [
    "xo",
    "xo-space",
    "xo-typescript",
    "prettier",
    "plugin:import/typescript",
    "plugin:unicorn/recommended",
    "plugin:prettier/recommended",
  ],
  ignorePatterns: ["**/dist/*", "**/node_modules/*"],
  overrides: [
    {
      plugins: ["jest"],
      files: [
        "test/**/*.ts",
        "tests/**/*.ts",
        "**/*.spec.ts",
      ],
      rules: {
        "@typescript-eslint/no-unsafe-assignment": "off",
        "max-nested-callbacks": "off",
        "jest/no-focused-tests": "error",
        ...(isFixMode && {
          "jest/no-focused-tests": "warn",
        }),
      },
    },
  ],
  parserOptions: {
    ecmaVersion: 2021,
    sourceType: "module",
  },
  env: {
    commonjs: true,
    es6: true,
    node: true,
    jest: true,
  },
  plugins: [
    "@typescript-eslint",
    "import",
    "unused-imports",
    "unicorn",
    "prettier",
  ],
  rules: {
    "prettier/prettier": ["error"],
    "@typescript-eslint/member-ordering": "off",
    "@typescript-eslint/no-unsafe-assignment": "off",
    "@typescript-eslint/no-unsafe-argument": "off",
    "@typescript-eslint/no-unsafe-call": "off",
    "@typescript-eslint/no-unsafe-return": "off",
    "no-console": "off",
    "@typescript-eslint/ban-types": "off",
    "comma-dangle": ["error", "always-multiline"],
    "unicorn/no-new-array": "off",
    "unicorn/no-reduce": "off",
    "unicorn/no-array-reduce": "off",
    "unicorn/prevent-abbreviations": [
      "error",
      {
        replacements: {
          props: false,
          args: false,
          params: false,
          env: false,
        },
      },
    ],
    "import/prefer-default-export": "off",
    "import/first": "error",
    "import/newline-after-import": "error",
    "import/no-duplicates": "error",
    "import/no-unresolved": "error",
    "import/order": [
      "error",
      {
        "newlines-between": "always",
        alphabetize: { order: "asc" },
        groups: ["builtin", "external", "internal", "parent", "sibling"],
      },
    ],
    "unused-imports/no-unused-imports-ts": "error",
    "unused-imports/no-unused-vars-ts": [
      "warn",
      {
        vars: "all",
        varsIgnorePattern: "^_",
        args: "after-used",
        argsIgnorePattern: "^_",
      },
    ],
    "@typescript-eslint/naming-convention": [
      "error",
      {
        selector: ["variable"],
        modifiers: ["const"],
        format: ["strictCamelCase", "StrictPascalCase", "UPPER_CASE"],
        leadingUnderscore: "allow",
      },
    ],
    "new-cap": "off",
  },
  settings: {
    "import/ignore": ["node_modules"],
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"],
    },
    "import/resolver": {
      typescript: {
        alwaysTryTypes: true,
      },
    },
  },
};

@nzakas nzakas changed the title Bug: Eslint now working with eslint src/**/*.ts --fix Bug: Eslint not working with eslint src/**/*.ts --fix Apr 22, 2024
@quellen-sol
Copy link

quellen-sol commented Apr 26, 2024

Just hit this as well. Here's a minimal reproduction: https://github.com/quellen-sol/eslint-bug-repro

Using this in WSL2 Ubuntu with node version 20.11.0

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

5 participants