forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-NoSource-import-bug
- Loading branch information
Showing
2 changed files
with
45 additions
and
16 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,44 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const baseDir = process.cwd(); | ||
const eslintignorePath = path.join(baseDir, '.eslintignore'); | ||
|
||
fs.readFile(eslintignorePath, 'utf8', (err, data) => { | ||
if (err) { | ||
console.error('Error reading .eslintignore file:', err); | ||
return; | ||
} | ||
|
||
const lines = data.split('\n'); | ||
const files = lines.map((line) => line.trim()).filter((line) => line && !line.startsWith('#')); | ||
const nonExistentFiles = []; | ||
|
||
files.forEach((file) => { | ||
const filePath = path.join(baseDir, file); | ||
if (!fs.existsSync(filePath) && file !== 'pythonExtensionApi/out/') { | ||
nonExistentFiles.push(file); | ||
} | ||
}); | ||
|
||
if (nonExistentFiles.length > 0) { | ||
console.log('The following files listed in .eslintignore do not exist:'); | ||
nonExistentFiles.forEach((file) => console.log(file)); | ||
|
||
const updatedLines = lines.filter((line) => { | ||
const trimmedLine = line.trim(); | ||
return !nonExistentFiles.includes(trimmedLine) || trimmedLine === 'pythonExtensionApi/out/'; | ||
}); | ||
const updatedData = `${updatedLines.join('\n')}\n`; | ||
|
||
fs.writeFile(eslintignorePath, updatedData, 'utf8', (err) => { | ||
if (err) { | ||
console.error('Error writing to .eslintignore file:', err); | ||
return; | ||
} | ||
console.log('Non-existent files have been removed from .eslintignore.'); | ||
}); | ||
} else { | ||
console.log('All files listed in .eslintignore exist.'); | ||
} | ||
}); |