eslint-plugin-unicorn
eslint-plugin-unicorn copied to clipboard
More than 100 powerful ESLint rules
Occasionally it's easier to deal with IDs: ```jsx const field = labelElement.htmlFor; ``` ```jsx return ; ``` ```jsx const element = document.getElementById(field) ``` It's kind of an exception, but this...
### Description Prevent returning or assigning mutating array methods, to improve readability and also protect against accidentally mutating an array in-place when you shouldn't. `Array#sort()`, `Array#fill()`, `Array#reverse()`. ### Fail ```js...
### Description if the new string starts with the previous string, prefer operator assignment as less code is written ### Fail ```js foo = foo + 'baz qux' ``` ```js...
Currently, [`new-for-builtins`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/new-for-builtins.md) enforce builtins used either `call` or `new`. My idea is to extend this rule to check all builtins. - Objects like `JSON`/`Math`/`Reflect`/`Temporal` should be neither `call` nor `new`...
### Description Sometimes, we incorrectly try to add a class that begins with a dot, but linters and indeed browsers do not indicate that this is an error. The error...
I want to allow this abbr `elementRef: ElementRef` as it a well known term in Angular ``` replacements:[ // those don't work elementRef: false, ElementRef: false, Ref: false, // only...
For `eslint-plugin-jsdoc`, we have added a convenient testing feature that allows us to run tests like `npm run test-index --rule=xyz --invalid=3-5` or `npm run test-index --rule=xyz --valid=-1` (with slice-like ranges/indexes/negative...
## Fail ```js // Should use `Object.values` for (const key of Object.keys(foo)) { bar(foo[key]); } ``` ```js // Should use `Object.entries` for (const key of Object.keys(foo)) { bar(foo[key], key); }...
We are going to add `prefer-object-from-entries` rule in #1308. As proposed in [the original proposal](https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1260), the following case should be reported too ```js const foo = {}; for (const [key,...
#1812 makes me realize that the following edge cases will cause runtime error by autofix. ```js // The second parameter default value can be a reference from first parameter array.forEach((element,...