-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix]
no-unused-modules
: provide more meaningful error message when…
… no eslintrc is present This change adjusts what we're doing if an error is thrown while attempting to enumerate lintable files in the no-used-modules rule, when users are running with flat config. Now, if FileEnumerator throws due to a lack of eslintrc and the user is running with flat config, we catch the error and rethrow with a more informative message. I also cleaned up the original aspects of the implementation that was using the proposed eslint context functions, since that proposal was walked back and the API was never introduced. Note: This isn't an ideal state, since this rule still relies on the legacy api to understand what needs to be ignored. Remaining tethered to the legacy config system is going to need to be solved at some point. Fixes #3079
- Loading branch information
1 parent
aee018f
commit e5edf49
Showing
12 changed files
with
157 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import importPlugin from 'eslint-plugin-import'; | ||
import js from '@eslint/js'; | ||
|
||
export default [ | ||
js.configs.recommended, | ||
importPlugin.flatConfigs.recommended, | ||
{ | ||
files: ['**/*.{js,mjs,cjs}'], | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
}, | ||
ignores: ['eslint.config.mjs', 'node_modules/*'], | ||
rules: { | ||
'no-unused-vars': 'off', | ||
'import/no-dynamic-require': 'warn', | ||
'import/no-nodejs-modules': 'warn', | ||
'import/no-unused-modules': ['warn', { unusedExports: true }], | ||
'import/no-cycle': 'warn', | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "v9", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"lint": "eslint src --report-unused-disable-directives" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.17.0", | ||
"eslint": "^9.17.0", | ||
"eslint-plugin-import": "file:../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { foo } from "./es6/depth-one-dynamic"; | ||
|
||
foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function foo() {} | ||
|
||
export const bar = () => import("../depth-zero").then(({foo}) => foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const a = 13; | ||
export const b = 18; | ||
|
||
const defaultExport = { a, b }; | ||
|
||
export default defaultExport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const a = 13; | ||
export const b = 18; | ||
|
||
const defaultExport = { a, b }; | ||
|
||
export default defaultExport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//import c from './exports'; | ||
import { a, b } from './exports'; | ||
|
||
import path from 'path'; | ||
import fs from 'node:fs'; | ||
import console from 'console'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters