-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlycoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Description
Environment
Node version: 19.7.0
npm version: 9.5.0
Local ESLint version: 8.37.0
Global ESLint version: N/A
Operating System: windows 10 x64
What parser are you using?
Default (Espree)
What did you do?
When passing cwd option to eslint with a path with forward slash on windows (C:/path/to/project
), eslintignore breaks and errors were reported from ignored files.
folder structure:
src/1.js
src/dist/2.js
.eslintignore
.eslintrc.js
lint.js
src/1.js
console.log(1)
src/dist/2.js
console.log(2)
.eslintignore
src/dist
lint.js
const eslint = require('eslint');
const run = async (cwd) => {
// 1. Create an instance.
const instance = new eslint.ESLint({ cwd, extensions: ['.js'] });
// 2. Lint files.
const results = await instance.lintFiles(["./src"]);
// 3. Format the results.
const formatter = await instance.loadFormatter("stylish");
const resultText = formatter.format(results);
// 4. Output it.
console.log(resultText);
};
const main = async () => {
await run(__dirname);
console.log('-----------');
await run(__dirname.replaceAll("\\", "/"));
};
main();
.eslintrc.js
module.exports = {
parserOptions: {
ecmaVersion: 2020,
},
'root': true,
'rules': {
'semi': 'error',
},
};
result
C:\src\eslinttest\src\1.js
1:15 error Missing semicolon semi
✖ 1 problem (1 error, 0 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
-----------
C:\src\eslinttest\src\1.js
1:15 error Missing semicolon semi
C:\src\eslinttest\src\dist\2.js
1:15 error Missing semicolon semi
✖ 2 problems (2 errors, 0 warnings)
2 errors and 0 warnings potentially fixable with the `--fix` option.
What did you expect to happen?
eslintignore working as expected
What actually happened?
linting ignored files
Participation
- I am willing to submit a pull request for this issue.
Additional comments
Where I get this problem? Here.
I'm using vite-plugin-checker on my project. It pass a root
param recieved from vite
to eslint cwd
option which happens to be a path with forward slash on windows.
Metadata
Metadata
Assignees
Labels
acceptedThere is consensus among the team that this change meets the criteria for inclusionThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlycoreRelates to ESLint's core APIs and featuresRelates to ESLint's core APIs and featuresrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Type
Projects
Status
Complete