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: v9.0.0 has prevented ancestor glob patterns #18370

Open
1 task
elliottmangham opened this issue Apr 19, 2024 · 4 comments
Open
1 task

Bug: v9.0.0 has prevented ancestor glob patterns #18370

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

Comments

@elliottmangham
Copy link

elliottmangham commented Apr 19, 2024

Environment

Node version: v21.7.2
npm version: v10.5.0
Local ESLint version: 9.1.0
Global ESLint version: 9.1.0
Operating System: darwin 23.4.0

What parser are you using?

@babel/eslint-parser

What did you do?

I used to simply run eslint '../assets/source/scripts/**/*.js' and it worked perfectly. Since updating to ES Lint v9.0.0, however, it no longer works.

Below is my eslint.config.js file (formerly .eslintrc.js), which hasn't changed besides the file name.

const path = require('path');

module.exports = {
	env: {
		browser: true,
		es2021: true,
		node: true,
	},
	extends: 'eslint:recommended',
	parserOptions: {
		ecmaVersion: 'latest',
		sourceType: 'module',
	},
	settings: {
		'import/resolver': {
			node: {
				paths: [path.resolve(__dirname, 'packages')],
			},
		},
	},
	overrides: [
		{
			env: {
				node: true,
			},
			files: ['.eslintrc.{js,cjs}'],
			parserOptions: {
				sourceType: 'script',
			},
		},
	],
	rules: {
		'no-unused-vars': 'warn',
	},
};

What did you expect to happen?

It should run ES Lint on all JS files in my ../assets/source/scripts/ directory as per my glob pattern ../assets/source/scripts/**/*.js.

What actually happened?

I get the following error:

> eslint '../assets/source/scripts/**/*.js'

Oops! Something went wrong! :(

ESLint: 9.1.0

You are linting "../assets/source/scripts/**/*.js", but all of the files matching the glob pattern "../assets/source/scripts/**/*.js" are ignored.

If you don't want to lint these files, remove the pattern "../assets/source/scripts/**/*.js" 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.

Link to Minimal Reproducible Example

https://github.com/coderesolution/boilerplate

Participation

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

Additional comments

Please observe the ../ at the beginning, as the JS files are in the parent folder where I run my scripts and where my package.json file is. I have noticed that if I removed the ../ and reference JS files in the same directory or below, it works. Interesting, if I reference a single file above, like ../assets/source/scripts/app.js, this works.

This suggests that something in v9.0.0 has prevented ancestor directories/files from linting if combined with a glob pattern like **/*.js.

@elliottmangham elliottmangham added bug ESLint is working incorrectly repro:needed labels Apr 19, 2024
@elliottmangham elliottmangham changed the title Bug: glob patterns change affecting ancestor files ("../") Bug: v9.0.0 has prevented ancestor glob patterns Apr 19, 2024
@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,
      },
    },
  },
};

@mdjermanovic
Copy link
Member

Link to Minimal Reproducible Example

https://github.com/coderesolution/boilerplate

I'm getting 404 on this link, perhaps the repo is private. Can you provide another repo where we could reproduce this?

@mdjermanovic mdjermanovic added the needs info Not enough information has been provided to triage this issue label Apr 22, 2024
@elliottmangham
Copy link
Author

Link to Minimal Reproducible Example

https://github.com/coderesolution/boilerplate

I'm getting 404 on this link, perhaps the repo is private. Can you provide another repo where we could reproduce this?

Hey so sorry I posted this just before I left for vacation. I can create a reproduction mid May when I am back at the studio.

Glad to see another user has had the same issue though.

@nzakas
Copy link
Member

nzakas commented Apr 22, 2024

@elliottmangham @paulocoghi neither of your examples are valid eslint.config.js files. Please see the migration guide for help in converting your config file.

@paulocoghi please create a StackBlitz or GitHub repo with a minimal reproduction so we can take a look.

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

4 participants