Skip to content

Commit

Permalink
chore: organize rules in a single directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed May 30, 2020
1 parent 19cbe5b commit 3243dbb
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 50 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
module.exports = {
extends: [
'./rules/general/format',
'./rules/general/style',
'./rules/general/error',
'./rules/es2015/style',
'./rules/es2015/error',
'./rules/error',
'./rules/format',
'./rules/import',
'./rules/style',
].map(require.resolve),

parserOptions: {
Expand Down
19 changes: 12 additions & 7 deletions rules/es2015/error.js → rules/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ module.exports = {
// https://eslint.org/docs/rules/constructor-super
'constructor-super': 'error',

// Ensure imports point to resolveable modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
'import/no-unresolved': ['error', {
commonjs: true,
caseSensitive: true,
}],

// Ensure const variables are not reassigned or modified
// https://eslint.org/docs/rules/no-const-assign
'no-const-assign': 'error',

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

// Ensure super() is called first in constructors (for derived classes)
// https://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': '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',
},
};
File renamed without changes.
15 changes: 0 additions & 15 deletions rules/general/error.js

This file was deleted.

33 changes: 10 additions & 23 deletions rules/es2015/style.js → rules/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ module.exports = {
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
'import/no-absolute-path': 'error',

// Prohibit duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',

// Prohibit use of expressions in require statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
'import/no-dynamic-require': 'error',

// Prohibit duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',
// Ensure imports point to resolveable modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
'import/no-unresolved': ['error', {
commonjs: true,
caseSensitive: true,
}],

// Prohibit Webpack-specific loader syntax in import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
Expand All @@ -31,25 +38,5 @@ module.exports = {
// 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',

// Prohibit silently overriding class members
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',

// Prohibit constructors when default is sufficient
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',

// Require variables to be declared with let or const instead of var
// https://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
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
},
};
20 changes: 20 additions & 0 deletions rules/general/style.js → rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.exports = {
// https://eslint.org/docs/rules/no-console
'no-console': 'warn',

// Prohibit silently overriding class members
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',

// Prohibit overwriting / reassigning exception objects
// https://eslint.org/docs/rules/no-ex-assign
'no-ex-assign': 'error',
Expand All @@ -34,10 +38,26 @@ module.exports = {
// https://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 'error',

// Prohibit constructors when default is sufficient
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',

// Require variables to be declared with let or const instead of var
// https://eslint.org/docs/rules/no-var
'no-var': 'error',

// Prohibit padding at beginning/end of blocks, classes and switch statements
// https://eslint.org/docs/rules/padded-blocks
'padded-blocks': ['error', 'never'],

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

// Require template literals instead of string concat
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',

// Prohibit invalid JSDoc annotations (when present)
// https://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': 'error',
Expand Down

0 comments on commit 3243dbb

Please sign in to comment.