This repository was archived by the owner on Aug 31, 2023. It is now read-only.
Implement the 100+ rules from eslint-plugin-unicorn #4756
flexiworld
started this conversation in
Suggestions
Replies: 2 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Frankly, I find that most of these rules add value to the linting process. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Implement the 100+ rules from eslint-plugin-unicorn: https://github.com/sindresorhus/eslint-plugin-unicorn/tree/main
✅ Set in the
recommendedconfiguration.🔧 Automatically fixable by the
--fixCLI option.💡 Manually fixable by editor suggestions.
Errorsubclassing.messagevalue when creating a built-in error.lengthorsizeproperty of a value.newfor all builtins, exceptString,Number,Boolean,SymbolandBigInt.eslint-disablecomments.for…ofover theforEachmethod.thisargument in array methods.Array#push()into one call.Array#reduce()andArray#reduceRight().console.logparameters.document.cookiedirectly.forloop that can be replaced with afor-ofloop.Array.isArray()instead ofinstanceof Array.EventTarget#removeEventListener()with the result of an expression.neworclass.ifstatements as the only statement inifblocks withoutelse.new Array().Buffer.from()andBuffer.alloc()instead of the deprecatednew Buffer().nullliteral.process.exit().thenproperty.thisto a variable.undefinedusingtypeof.Promise.resolve/reject()in async functions or promise callbacksundefined..addEventListener()and.removeEventListener()overon-functions..find(…)and.findLast(…)over the first or last element from.filter(…).Array#flat()over legacy techniques to flatten arrays..flatMap(…)over.map(…).flat().Array#{indexOf,lastIndexOf}()overArray#{findIndex,findLastIndex}()when looking for the index of an item..some(…)over.filter(…).lengthcheck and.{find,findLast}(…)..at()method for index access andString#charAt().Blob#arrayBuffer()overFileReader#readAsArrayBuffer(…)andBlob#text()overFileReader#readAsText(…).String#codePointAt(…)overString#charCodeAt(…)andString.fromCodePoint(…)overString.fromCharCode(…).Date.now()to get the number of milliseconds since the Unix Epoch.Node#append()overNode#appendChild()..dataseton DOM elements over calling attribute methods.childNode.remove()overparentNode.removeChild(childNode)..textContentover.innerText.EventTargetoverEventEmitter.export…fromwhen re-exporting..includes()over.indexOf()andArray#some()when checking for existence or non-existence.KeyboardEvent#keyoverKeyboardEvent#keyCode.Math.truncinstead of bitwise operators..before()over.insertBefore(),.replaceWith()over.replaceChild(), prefer one of.before(),.after(),.append()or.prepend()overinsertAdjacentText()andinsertAdjacentElement().MathAPIs over legacy patterns.String,Number,BigInt,Boolean, andSymboldirectly..length - indexwhen possible.node:protocol when importing Node.js builtin modules.Numberstatic properties over global ones.Object.fromEntries(…)to transform a list of key-value pairs into an object.catchbinding parameter..querySelector()over.getElementById(),.querySelectorAll()over.getElementsByClassName()and.getElementsByTagName().Reflect.apply()overFunction#apply().RegExp#test()overString#match()andRegExp#exec().Set#has()overArray#includes()when checking for existence or non-existence.Set#sizeinstead ofArray#length.Array.from(…),Array#concat(…),Array#{slice,toSpliced}()andString#split('').String#replaceAll()over regex searches with the global flag.String#slice()overString#substr()andString#substring().String#startsWith()&String#endsWith()overRegExp#test().String#trimStart()/String#trimEnd()overString#trimLeft()/String#trimRight().switchover multipleelse-if.if-elsestatements.TypeErrorin type checking conditions.Array#join().Number#toFixed().targetOriginargument withwindow.postMessage().caseclauses.newwhen throwing an error.Beta Was this translation helpful? Give feedback.
All reactions