ianvs / eslint-nibble Goto Github PK
View Code? Open in Web Editor NEWEase into ESLint, by fixing one rule at a time
License: MIT License
Ease into ESLint, by fixing one rule at a time
License: MIT License
It is not an issue. Just wondering. Is it OK that package.lock.json has a size of 13k lines?
Hi Ian,
I am pleased to endorse this package. ESLint is a necessary package. On available packages, the errors are not easy to treat one by one. At this moment, I fix all my lint-ycal issues.
I would like to ask/suggest a feature: given the .eslintrc config file, how is it possible to avoid some specific rule by using eslint-nibble
? Typically, as seen below, eslint extends some specific indentation style in my case 'airbnb-base'. Sometimes there is a rule one wants to avoid because it is too strict, for example, the camelcase
rule on the image below.
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb-base',
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
},
};
Since fixable eslint issues may be hand by hand fixed, a natural feature is to allow users to have the option to autofix all fixable ones.
From this documentation is not clear how to avoid node.js interactive and autofix errors & warnings for command: eslint-nibble ./src/**/*.ts --rule comma-dangle
How to preset answers "Enter, y, y"?
Can you integrate some progress like https://github.com/zero-t4/eslint-plugin-progress#readme
When using this plugin it count ok, but when select rule it will continue increase counter, and not starting from zero
I have a large app with various lint errors, I want to apply the auto fix only to a select set of rules. This project does a beautiful job, I’d like to use it in CI to lint a select set of rules- if there’s errors it fails the build. This would let me enforce linting across things we already fixed. I cannot run lint in CI due to number of errors.
Get TypeError: Cannot read property 'ecmaFeatures' of undefined
It would be great to be able to use this package and filter by those rules that are auto-fixable by eslint.
You could also implement this as some kind of indication on the initial report of rule violations as to which ones are fixable.
Linting is a common task run in tests. It would be nice if this project could detect the NODE_ENV
and disable the prompt.
ESLint supports a --cache
flag that can dramatically speed up linting. Adding this to nibble would also speed it up (presumably).
For our project we have two .eslintrc
files, .eslintrc
which is what we're currently enforcing and .eslintrc.next
which is where we'd like to be.
It would be nice if you could pass in a custom .eslintrc
file to nibble like you can with ESLint—eslint -c .eslintrc.next
.
The test framework Jest is very useful for programmers. However, eslint dislikes its statements: it
, expect
, describe
and beforeEach
, among others. Maybe I am asking in the wrong place, I ask you to say if so:
Is the a manner to either walk around or fix this "issue"?
CLIEngine has been removed in version 8.0.0.
Hey, the project is awesome!
I would like to use it with import/no-unused-modules
rule from eslint-plugin-import
plugin but not sure how to pass additional config for that rule.
Is there an option do use something like this --rule="{ import/no-unused-modules: [2, { unusedExports: true }] }"
?
Thanks!
If I run eslint-nibble on 10,000 files (which takes, say, 5 minutes to process), and the rule I select only has an error in 200 files, I would expect eslint to take, say, 1 minute to run on only those 200 files, instead of the full 5 minutes to run on all 10K files.
This could be achieved by minimizing what file paths are passed to the eslint --fix
run - via a custom ignore file that ignores the non-errored files; or via a glob path that minimizes which un-errored files are processed the second time around.
I'd love to be able to pre-select the rule(s) with --rule
or similar, so I can skip the laborious list navigation :-)
On Windows, the only way I can get plugins to resolve with my global installation of ESLint is by passing the option --resolve-plugins-relative-to
, set to the output of npm root -g
. Unfortunately eslint-nibble
does not recognize this option, so I can't use it on Windows.
When installed globally, eslint-nibble does not have access to plugins, custom parsers, or shared configs which are installed in the project.
If eslint-nibble needs to be installed globally, those other packages can also be installed globally, but a better way is probably to install eslint-nibble locally to the project. The usage instructions should be updated to reflect this.
The latest (upcoming) version of ESLint supports more control over fixes, so eslint-nibble should be able to fix individual rules automatically.
Throws an error when trying to install:
/usr/app # npm install --no-save eslint-nibble
npm WARN deprecated [email protected]: This module has moved and is now available at @hapi/joi. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://[email protected]/ianvs/eslint-stats.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-01-28T11_52_03_443Z-debug.log
Here is my env:
node: v10.16.3
os: linux alpine
npm: v6.9.0
eslint: v6.1.0
Version: v6.0.0-beta.0
Node: 12
System: OSX Catalina
For instance:
yarn eslint-nibble --no-interactive --rule semi file.js
shows just everything with
error Command failed with exit code 1.
Currently, it is necessary to type in the name of the rule to dig deeper into. It would be great if inquirer could assign numbers to each of the failing rules and let the user select a number.
Hi @IanVS, thanks for this package.
Any ETA on the next npm release which should include the new CLI flags such as --no-interactive
?
Select one of the rules by arrowing up/down and pressing enter
What can I do at this stage if I don't want to fix anything. I just wanted to see a report.
Likely Circle CI.
When running eslint-nibble
interactively and attempting to auto-fix errors, the errors are auto-fixed but eslint-nibble
exits after throwing the following exception:
? Which rule would you like to view? no-multi-spaces
? Would you like to attempt to auto-fix? Yes
(node:11384) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at filterResults (/home/chris/project/git-workflow/csr512-test-openidm-config/config/node_modules/eslint-nibble/src/nibbler.js:63:39)
at Object.getRuleResults (/home/chris/project/git-workflow/csr512-test-openidm-config/config/node_modules/eslint-nibble/src/nibbler.js:149:9)
at gotInput (/home/chris/project/git-workflow/csr512-test-openidm-config/config/node_modules/eslint-nibble/src/cli.js:183:43)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This error should be easy to replicate by running eslint-nibble
interactively against a file with auto-fixable errors and answering y
when asked about attempting to auto-fix them.
$ npx eslint-nibble -v
v8.0.0
Unfortunately there's no way to configure which extensions to look at in .eslintrc
so you have to pass it on the command line: http://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint
It would be great if nibble supported this so I could use it on .jsx
files, etc.
Relevant ESLint issue: eslint/eslint#2419
I'm on a Mac on latest node.
Really, this is pathetic.
I'd love a way to select multiple rules at a time, in particular so I can apply multiple whitespace rules all at once (generating the initial report takes a lot of time)
When I install from npm, it seems es6 module importing does not work.
Can you integrate https://github.com/pinterest/esprint
It running eslint with multiple threads and show results more quickly
This tool is intended to be used as a CLI, but as an npm module maybe it should also have an API? Currently the main
of package.json
is broken, so this module cannot be require
d. I need to think about use cases which may warrant a possible API.
Thanks. Great tool.
yarn eslint-nibble --rule quotes --no-interactive --fix .
Invalid option '--fix' - perhaps you meant '-f'?
Instead of using bare require
, eslint-nibble should use require(resolve(path, { cwd: process.cwd() }))
and https://npmjs.com/resolve, so it doesn't have to be installed locally.
Hi
--non-interactive
flag correctly. Does this mode allow me to specify a rule in the cli which nibble would auto-fix?I have a monorepo with 28 apps in it and navigating into every app one-at-a-time is a bit of pain. I've tried using the rule in combilation with the --rule
flag but the desired outcome isn't quite there yet.
Hello,
Babel is actually required to run eslint-nibble, so it fails if Babel is not installed with this error :
module.js:338
throw err;
^
Error: Cannot find module 'babel/polyfill'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/.../my-project/node_modules/eslint-nibble/index.js:4:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
First off -- awesome project! We've been using this at Condé Nast to help with summaries of lint rule impact, as well as helping us roll out the changes / fixes.
That said, we've found that in general, lint, especially at company scale, is a challenging thing to work with. Providing best practice rules, while being realistic about the downstream impact to your consumers is tricky. Tools like this certainly help us find our way forward, however sometimes it takes multiple strategies.
Right now our flow looks like:
When point 3 occurs, then we lose the entire benefit of that rule, people likely to continue to write the non-desired code.
Rather than disabling a rule, it would be better to ignore the specific infractions of the current codebase, and only apply moving forward. This would ensure that new code at least follows the new standard.
In my mind, this could be accomplished by adding a feature to this tool. After choosing the rule to work on, a user could be presented with an "ignore lines" option in addition to the "fix" option. This would go insert line-level eslint ignore statements. I understand this is a little afield of what the tool currently does, but I don't see any other tools in the space able to help.
I would be interested in helping out, if this is a desired feature.
Hey awesome package, really useful for going through a big codebase rule by rule and fixing things.
However, I noticed that that after installing it, regular eslint
linting via the CLI is not observing the .eslintrc
properly.
Here's an example; prior to installing eslint-nibble
the following code, correctly as per my config, does not throw an eslint error
static propTypes = {
actions: PropTypes.object,
children: PropTypes.any,
}
However, after installing eslint-nibble
and then simply running eslint
on this file I see
18:10 error 'propTypes' is not defined no-undef
Which is incorrect as per my rules. Running eslint-nibble
however, correctly does not deem this to be an error. What's going on here?
Uninstalling eslint-nibble
restores the ability for the regular eslint
CLI command to lint correctly.
If a file has no errors, a report is still returned, with zero warnings and zero errors. This causes a failure with the way that fatal errors are being checked for.
Some files needed to be ignored by eslint-nibble (which already ignored eslint via .eslintignore), but now there are no ways to do it
I have a .eslintrc file in my project with all the required rules. However, when running this it seems to ignore that file and display some standard errors based on what it thinks are the rules. How can i force it to use my set of rules?
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.