27
loading...
This website collects cookies to deliver better user experience
array.includes
instead of some
or find
if you're working on a list of strings for example. There are too many awesome rules to list each here so check out their docs.node:
scheme for being more explicit about importing Node.js libraries from unicorn.import fs from 'fs'
// Vs
import fs from 'node:fs'
"unicorn/no-fn-reference-in-iterator": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-null": "off",
"unicorn/consistent-destructuring": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-spread": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/prevent-abbreviations": [
"error",
{
allowList: { Param: true, Req: true, Res: true },
},
],
extends: [
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript", // make sure you add this one for ts projects
],
settings: {
["import/parsers"]: { "@typescript-eslint/parser": [".ts", ".tsx"] },
["import/resolver"]: {
node: {
extensions: [".ts"],
},
},
},
{
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
sourceType: "module",
ecmaVersion: "es2019",
},
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variable",
format: ["PascalCase", "UPPER_CASE"],
types: ["boolean"],
prefix: ["is", "should", "has", "can", "did", "will"],
},
{
selector: "variableLike",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
},
{
selector: "parameter",
format: ["camelCase"],
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "forbid",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "property",
modifiers: ["readonly"],
format: ["PascalCase"],
},
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
],
/*eslint-disable no-undef */
"eslint-comments/disable-enable-pair": [
"error",
{ allowWholeFile: true },
],
expect(myResult).resolves.toEqual(expected) // this is wrong
return expect(myResult).resolves.toEqual(expected) // this is correct
expect(myResult === expected)
then()
.async/await
or then()/catch()
. This could be useful at the start of a project to force one or the other.