Open aladdin-add opened 1 week ago
I think this part described in https://github.com/eslint/create-config/issues/148 isn't implemented:
The JavaScript option should be checked by default and if unchecked, we should add this to the config:
{ ignores: ["**/*.js", "**/*.cjs", "**/*.mjs"] }
A problem is that most plugin configs (including @eslint/js
configs) don't have files
, so they would apply to non-JS files.
For example:
$ npx @eslint/create-config
@eslint/create-config: v1.3.1
√ What do you want to lint? · javascript, json
√ How would you like to use ESLint? · problems
√ What type of modules does your project use? · esm
√ Which framework does your project use? · none
√ Does your project use TypeScript? · no / yes
√ Where does your code run? · No items were selected
The config that you've selected requires the following dependencies:
eslint, @eslint/js, @eslint/json
√ Would you like to install them now? · No / Yes
√ Which package manager do you want to use? · npm
☕️Installing...
up to date, audited 363 packages in 1s
183 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Successfully created C:\projects\tmp\tmp\eslint.config.mjs file.
Generated config file:
import pluginJs from "@eslint/js";
import json from "@eslint/json";
/** @type {import('eslint').Linter.Config[]} */
export default [
pluginJs.configs.recommended,
{files: ["**/*.json"], language: "json/json", ...json.configs.recommended},
];
$ npx eslint package.json
Oops! Something went wrong! :(
ESLint: 9.14.0
TypeError: Error while loading rule 'no-irregular-whitespace': sourceCode.getAllComments is not a function
Occurred while linting C:\projects\tmp\tmp\package.json
at Object.create (C:\projects\tmp\tmp\node_modules\eslint\lib\rules\no-irregular-whitespace.js:87:41)
at createRuleListeners (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:943:21)
at C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:1068:84
at Array.forEach (<anonymous>)
at runRules (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:999:34)
at #flatVerifyWithoutProcessors (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:1911:31)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:1992:49)
at Linter._verifyWithFlatConfigArray (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:2081:21)
at Linter.verify (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:1528:61)
at Linter.verifyAndFix (C:\projects\tmp\tmp\node_modules\eslint\lib\linter\linter.js:2319:29)
Yes, I was able to repro!
Is it the expected behavior? My understanding is that it should only be applied to js/mjs/cjs
files if no files are specified.
and I'm getting the same error even if I added files
:
import pluginJs from "@eslint/js";
import json from "@eslint/json";
/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ["**/*.{js,mjs,cjs}"]},
pluginJs.configs.recommended,
{files: ["**/*.json"], language: "json/json", ...json.configs.recommended},
];
fixes #148