Skip to content

Commit

Permalink
feat: Cover more variable conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Aug 25, 2017
1 parent 7951d90 commit 7041f12
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 30 deletions.
4 changes: 4 additions & 0 deletions es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ module.exports = Object.assign({
// Additional opinions

// Additional conventions
// See: https://eslint.org/docs/rules/no-var
'no-var': 'off',
// See: https://eslint.org/docs/rules/prefer-const
'prefer-const': 'off',

// Additional mistakes
'node/no-unsupported-features': [2, { version: 4 }],
Expand Down
2 changes: 2 additions & 0 deletions examples/eslint/es5/strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

function f() {
// No use-strict here.
var x = 42;
return x;
}
f();
6 changes: 3 additions & 3 deletions examples/eslint/node6/ugly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
'use strict';
function f (){

const x = 42;
return 2 * x;;
var x = 42;
return 'The number is ' + x;;



}

f () ;
f (/a b/) ;
4 changes: 2 additions & 2 deletions examples/eslint/node6/ugly.out.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function f() {
const x = 42;
return 2 * x;
return `The number is ${x}`;
}

f();
f(/a {3}b/);
1 change: 1 addition & 0 deletions examples/eslint/node6/undef-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

let x = undefined;
x = 42;
x = 13;
(() => {})(x); // "use"
1 change: 1 addition & 0 deletions examples/eslint/node6/undef-init.out.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

let x;
x = 42;
x = 13;
(() => {})(x); // "use"
36 changes: 24 additions & 12 deletions lib/rules/conventions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,35 @@
* might be a moving target.
*/
module.exports = {
/*
* See: http://eslint.org/docs/rules/no-underscore-dangle
*/
// See: http://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': ['warn', { allowAfterThis: true }],

/*
* See: http://eslint.org/docs/rules/no-undef-init
*/
// See: http://eslint.org/docs/rules/no-undef-init
'no-undef-init': 'error',

/*
* See: http://eslint.org/docs/rules/strict
*/
// See: http://eslint.org/docs/rules/strict
strict: ['warn', 'global'], // pending: Can't be auto-fixed

/*
* See: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
*/
// See: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
'import/no-dynamic-require': 'warn', // pending: Can't be auto-fixed

// See: https://eslint.org/docs/rules/no-regex-spaces
'no-regex-spaces': 'error',

// See: https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',

// See: https://eslint.org/docs/rules/no-var
'no-var': 'error',
// See: https://eslint.org/docs/rules/prefer-const
'prefer-const': [
'error',
{
destructuring: 'any',
ignoreReadBeforeAssign: true,
},
],

// See: https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
};
37 changes: 24 additions & 13 deletions lib/rules/mistakes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,20 @@ module.exports = {
// See: https://eslint.org/docs/rules/getter-return
'getter-return': ['error', { allowImplicit: true }],

// See: https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'off',

// See: https://eslint.org/docs/rules/no-compare-neg-zero
'no-constant-condition': 'error',

// See: https://eslint.org/docs/rules/no-dupe-args
'no-dupe-args': 'error',
// See: https://eslint.org/docs/rules/no-dupe-keys
'no-dupe-keys': 'error',
// See: https://eslint.org/docs/rules/no-duplicate-case
'no-duplicate-case': 'error',
// See: https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',

// # RegExp
// See: https://eslint.org/docs/rules/no-empty-character-class
'no-empty-character-class': 'error',
// See: https://eslint.org/docs/rules/no-invalid-regexp
'no-invalid-regexp': 'error',
// See: https://eslint.org/docs/rules/no-regex-spaces
// TODO: Can't be auto-fixed
'no-regex-spaces': 'off',

// # Debug & Refactor Leftovers

Expand All @@ -45,20 +38,38 @@ module.exports = {
'no-unreachable': 'error',
// See: https://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 'error',
// See: https://eslint.org/docs/rules/constructor-super
'constructor-super': 'error',
// See: https://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 'error',
// See: http://eslint.org/docs/rules/require-yield
'require-yield': 'error',
// See: https://eslint.org/docs/rules/no-compare-neg-zero
'no-constant-condition': 'error',

// See: https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',
// # Types & Misleading Syntax

// See: https://eslint.org/docs/rules/use-isnan
'use-isnan': 'error',
// See: https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'off',
// See: https://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 'error',

// See: https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',
// See: https://eslint.org/docs/rules/no-new-require
'no-new-require': 'error',
// See: https://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 'error',

// See: https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',

// # Variables & Assignment

// See: https://eslint.org/docs/rules/no-func-assign
'no-func-assign': 'error',
'no-class-assign': 'error',
'no-const-assign': 'error',

// See: https://eslint.org/docs/rules/no-unused-vars
'no-unused-vars': [
Expand Down

0 comments on commit 7041f12

Please sign in to comment.