Skip to content

Instantly share code, notes, and snippets.

@dlabey
Created January 12, 2017 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlabey/847ef9f22f246da910f25e93fe33ca44 to your computer and use it in GitHub Desktop.
Save dlabey/847ef9f22f246da910f25e93fe33ca44 to your computer and use it in GitHub Desktop.
React ESLint
{
"browser": true,
"es6": true,
"jest": true,
"node": true,
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"eslint-plugin-react"
],
"rules": {
"array-bracket-spacing": ["warn", "never"], // e.g. ['foo', 'bar'] <- make sure there are no weird spaces
"array-callback-return": "warn", // e.g. [...].map((el) => { return el; <- make sure we have a return }
"block-scoped-var": "warn", // e.g. { { const foo = 'bar'; } console.log(foo); <- make sure this has to be in scope
"block-spacing": "warn", // e.g. { console.log('foo bar'); } <- make sure there are spaces around statement in block
"brace-style": "warn", // e.g. if () { <- make sure the brace is on the same line
"comma-spacing": "warn", // e.g. 1, 2 not 1,2
"comma-style": ["warn", "last"], // e.g. item,\nitem2 not item\n,item2
"curly": ["warn", "multi"], // e.g. make sure that a curly bracket exists if a conditional spans more than 1 line
"dot-location": ["warn", "property"], // e.g. object\n.property instead of object.\nproperty
"dot-notation": "warn", // e.g. make sure to use foo.bar instead of foo['bar] when possible
"eqeqeq": "warn", // e.g. make sure to use === for type inference when comparing
"func-call-spacing": "warn", // make sure when calling a function there is no space by the parenthesis
"guard-for-in": "warn", // make sure when doing a for in we use Object.prototype.hasOwnProperty for safety
"max-len": ["warn", 80], // it is ideal if a line is not more than 80 characters long for when using a single screen
"new-parens": "warn", // make sure to use parenthesis on a constructor invokation even when no arguments are there
"newline-after-var": "warn", // make sure to use a newline after variable definitions
"newline-before-return": "warn", // make sure to use
"no-const-assign": "warn", // make sure to not reassign a constant variable
"no-duplicate-imports": "warn", // make sure not to import the same module twice
"no-else-return": "warn", // make sure to use the function block for the default return statement instead of an else
"no-empty-pattern": "warn", // e.g. const { foo } = bar; <- make sure the destructuring is not empty
"no-irregular-whitespace": "warn", // make sure there is no weird whitespace
"no-lonely-if": "warn", // make sure to use an else if if the else only has an if in it
"no-mixed-spaces-and-tabs": "warn", // make sure we use consistent spacing strategy
"no-multiple-empty-lines": ["warn", { "max": 2, "maxEOF": 1 }], // make sure there are no more than post 2 lines
"no-nested-ternary": "warn", // make sure a ternary is a variable for when using in a call
"no-trailing-spaces": "warn", // make sure there is no trailing whitepsace
"no-unneeded-ternary": "warn", // e.g. true instead of true ? true : false <- make sure a ternary is not redundant
"no-unreachable": "warn", // make sure that the code is reachable for avoiding unnecessary side effects
"no-undef": "warn", // make sure we declare variables
"no-undef-init": "warn", // e.g. const t; instead of const t = undefined; make sure we are not redundant in declaring undefined variables
"no-unused-vars": "warn", // make sure we do not keep unused variables
"no-use-before-define": "warn", // make sure we define varibales before we use them
"no-useless-concat": "warn", // e.g. `Hi this is ${name}` <- use es6 template literalys when possible
"no-useless-escape": "warn", // e.g. '\"' <- no need to escape something that doesn't need to be
"no-useless-return": "warn", // e.g. return;
"no-var": "warn", // e.g. use const and let instead of var as we are using es2015
"no-whitespace-before-property": "warn", // e.g. foo [bar] foo .bar <- avoid weird stuff
"one-var-declaration-per-line": "warn", // use one variable assignment in a declaration per line
"prefer-const": "warn", // use const when a variable does not need to be mutated
"prefer-template": "warn", // use template literals instead of string concatenation
"radix": ["warn", "as-needed"], // e.g. parseInt('071', 10) should be parseInt('071') as 10 is default
"sort-imports": "warn", // sort the imports when you can so there is some assumption of module use
"spaced-comment": "warn", // e.g. // comment not //comment <- add a space between the slashes in a comment
"space-in-parens": ["error", "never"], // e.g. (foo) instead of ( foo )
"strict": ["warn", "never"], // es2015 is inherently strict so no need to be redundant
"symbol-description": "warn", // e.g. Symbol("descriptor") not Symbol <- for human context
"template-curly-spacing": "warn", // e.g. ${foo} instead of ${ foo } in template literals
"vars-on-top": "warn", // declare at least the variables at the top of the block for assumed context
"yoda": ["warn", "never", { "exceptRange": true }] // e.g. foo === 'bar' instead of 'bar' === foo <- no yoda logic
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment