mizdra / eslint-interactive Goto Github PK
View Code? Open in Web Editor NEWThe CLI tool to fix huge number of ESLint errors
License: MIT License
The CLI tool to fix huge number of ESLint errors
License: MIT License
Stop the cache location from changing on every boot.
ref:
eslint-interactive/src/cli/log.ts
Lines 7 to 11 in 08ce5fe
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.devcontainer/Dockerfile
.github/workflows/benchmark.yml
actions/checkout v3
actions/setup-node v3
actions/cache v3
.github/workflows/ci-node.yml
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
actions/checkout v3
actions/setup-node v3
e2e-test/flat-config/package.json
e2e-test/global-installation/package.json
npm 8.14.0
e2e-test/import-as-esm-from-esm/package.json
package.json
boxen ^7.1.1
chalk ^5.3.0
comlink ^4.4.1
enquirer ^2.4.1
eslint-formatter-codeframe ^7.32.1
estraverse ^5.3.0
find-cache-dir ^5.0.0
is-installed-globally ^1.0.0
ora ^7.0.1
strip-ansi ^7.1.0
table ^6.8.1
terminal-link ^3.0.0
yargs ^17.7.2
@mizdra/eslint-config-mizdra 2.1.0-alpha.0
@mizdra/inline-fixture-files ^1.1.0
@mizdra/prettier-config-mizdra ^1.0.0
@tsconfig/node18 ^18.2.2
@tsconfig/strictest ^2.0.2
@types/eslint ^8.44.6
@types/estraverse ^5.1.6
@types/estree ^1.0.5
@types/fs-extra ^11.0.4
@types/node ^20.8.10
@types/yargs ^17.0.29
dedent ^1.5.1
eslint ^8.57.0
fs-extra ^11.1.1
import-meta-resolve ^4.0.0
npm-run-all ^4.1.5
prettier 3.0.3
stream-match ^4.1.0
typescript ^5.2.2
vitest ^1.1.0
vitest-github-actions-reporter ^0.10.0
node >=18.0.0
pnpm 8.9.0
log:
$ yarn run eslint-interactive .
/usr/bin/env: ‘node -r source-map-support/register’: No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
I want to add more tests because there are some modules that have insufficient amount of tests or don't exist at all.
✔ Found errors.
- 9 files (2 files passed, 7 files failed) checked.
- 32 problems (31 errors, 1 warning) found.
┌─────────────────────────────┬────────────────────────────────────┬──────────────────────────────────────┐
│ Rule │ Error (fixable/suggest-applicable) │ Warning (fixable/suggest-applicable) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ semi │ 15 (15/0) │ 1 (1/0) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ import/order │ 3 (3/0) │ 0 (0/0) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ prefer-const │ 4 (4/0) │ 0 (0/0) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ no-unused-vars │ 5 (0/0) │ 0 (0/0) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ ban-exponentiation-operator │ 3 (0/0) │ 0 (0/0) │
├─────────────────────────────┼────────────────────────────────────┼──────────────────────────────────────┤
│ null │ 1 (0/0) │ 0 (0/0) │
└─────────────────────────────┴────────────────────────────────────┴──────────────────────────────────────┘
✔ Which rules would you like to apply action? · semi
✔ Which action do you want to do? · applySuggestion
[Error: ENOENT: no such file or directory, open '/var/folders/dg/hj_fw8n16tv1mttdsnvxzk6r0000gn/T/eslint-interactive/filter-script/semi.js'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/var/folders/dg/hj_fw8n16tv1mttdsnvxzk6r0000gn/T/eslint-interactive/filter-script/semi.js'
}
I would like to be able to leave the intent of disable as a code comment.
master
=> main
Core
is the heart of eslint-interactive. By exporting it, the user can programmatically fix problems or apply suggestions.
Add // eslint-disable-next-line <rule-name>
automatically.
There are a few packages that are directly dependent on it that are not included in package.json.
Change the design of the spinner so that it doesn't bore the user and also makes them smile :)
And obsolete --formatter
option
RuleFixer
is ESLint's API.Rule.Fix
.function fixableMaker(fixer, message, node) {
if (!node) return null;
if (!node.range) return null;
if (message.ruleId === 'no-unused-vars' || message.ruleId === '@typescript-eslint/no-unused-vars') {
if (node.type !== 'Identifier') return null;
- return {
- range: [node.range[0], node.range[0]],
- text: '_',
- };
+ return fixer.insertTextBefore(node, '_');
} else {
return null;
}
}
Thank you for great tool.
https://github.com/aladdin-add/eslint-plugin/tree/master/packages/autofix can increase the number of fixable rules.
More fixable rules are useful because they reduce the need to add disable comments.
log:
✔ What format do you want to display the problem message in? · withPager
Error: The codeframe formatter is no longer part of core ESLint. Install it manually with `npm install -D eslint-formatter-codeframe`
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
...
I want eslint-interactive to print a link to the rule's document when displaying tabular errors.
eslint may report a problem without a location (e.g. https://stackoverflow.com/questions/58510287/parseroptions-project-has-been-set-for-typescript-eslint-parser).
Currently eslint-interactive shows those problems as null
in the table. If they are simply displayed as null
, the user will probably be confused. Therefore, I would like to display a more detailed error message.
If you write the following, it will not work as expected.
eslint-interactive --ext .ts,.tsx,.vue src
This is equivalent to the behavior as if .ts,.tsx,.vue
and src
were passed to the ext option, according to the yargs
specification (yargs/yargs#1848).
eslint-interactive --ext .ts,.tsx,.vue --ext src
This confuses for the user because it is interpreted differently than eslint
.
You can avoid this problem by always writing the directory patterns first.
eslint-interactive src --ext .ts,.tsx,.vue
The duplication rate of the code under src/rules/
is high. It needs to be refactored.
Use https://www.npmjs.com/package/boxen to make the warning message more visible.
Actual:
✔ Found errors.
8 file(s) checked. 2 passed. 6 failed. 30 file(s) 1 file(s).
┌─────────────────────────────┬─────────────────┬───────────────────┐
│ Rule │ Error (fixable) │ Warning (fixable) │
├─────────────────────────────┼─────────────────┼───────────────────┤
│ semi │ 15 (15) │ 1 (1) │
├─────────────────────────────┼─────────────────┼───────────────────┤
│ import/order │ 3 (3) │ 0 (0) │
├─────────────────────────────┼─────────────────┼───────────────────┤
│ prefer-const │ 4 (4) │ 0 (0) │
├─────────────────────────────┼─────────────────┼───────────────────┤
│ no-unused-vars │ 5 (0) │ 0 (0) │
├─────────────────────────────┼─────────────────┼───────────────────┤
│ ban-exponentiation-operator │ 3 (0) │ 0 (0) │
└─────────────────────────────┴─────────────────┴───────────────────┘
Expected:
✔ Found errors.
8 file(s) checked. 2 passed. 6 failed. 30 file(s) 1 file(s).
...
Welcome to contribute :)
src/formatter
src/rules
Make it more compact.
Since we are currently running the Core API on the main thread, the spinner will freeze while running. I want to run the Core API on a worker so that the spinner doesn't freeze.
Sometimes users want to re-run an action multiple times while changing options.
It would be useful to have a way to restore the file modified by the action and resume from entering the action's options.
$ npm un source-map-support
$ npm un -g source-map-support
$ npm i -g @mizdra/eslint-interactive
$ eslint-interactive --version
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'source-map-support/register'
Require stack:
- internal/preload
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1272:12)
at loadPreloadModules (node:internal/bootstrap/pre_execution:474:5)
at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:77:3)
at node:internal/main/run_main_module:7:1 {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]
}
Node.js v17.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.