Skip to content

Commit

Permalink
Improve linting rules
Browse files Browse the repository at this point in the history
- Disallow undeclared variables

- Disallow unused variables

- Suggest using const

- Enforce a convention in module import order

- Enable Node env for linting

- Require a space before function parenthesis in non-named functions
  • Loading branch information
timkurvers committed Jan 14, 2018
1 parent 3ed8e15 commit 5da0c9d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "./index.js",
"env": {
"node": true
}
}
8 changes: 8 additions & 0 deletions rules/es2015/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module.exports = {
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
'import/no-webpack-loader-syntax': 'error',

// Enforce a convention in module import order
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
'import/order': 'error',

// Require modules with a single export to use a default export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
'import/prefer-default-export': 'error',
Expand All @@ -42,6 +46,10 @@ module.exports = {
// http://eslint.org/docs/rules/no-var
'no-var': 'error',

// Suggest using const
// https://eslint.org/docs/rules/prefer-const
'prefer-const': 'error',

// Require template literals instead of string concat
// http://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
Expand Down
10 changes: 9 additions & 1 deletion rules/general/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ module.exports = {

// Ensure RegExp strings are valid
// http://eslint.org/docs/rules/no-invalid-regexp
'no-invalid-regexp': 'error'
'no-invalid-regexp': 'error',

// Disallow undeclared variables
// https://eslint.org/docs/rules/no-undef
'no-undef': 'error',

// Disallow unused variables
// https://eslint.org/docs/rules/no-unused-vars
'no-unused-vars': 'error',

}

Expand Down
8 changes: 8 additions & 0 deletions rules/general/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ module.exports = {
// http://eslint.org/docs/rules/space-before-blocks
'space-before-blocks': ['error', 'always'],

// Require a space before function parenthesis in non-named functions
// https://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}],

// Prohibit spaces inside parens (immediately adjacent to paren)
// http://eslint.org/docs/rules/space-in-parens
'space-in-parens': ['error', 'never'],
Expand Down

0 comments on commit 5da0c9d

Please sign in to comment.