diff --git a/src/index.js b/src/index.js index 3955b16..b94ea26 100644 --- a/src/index.js +++ b/src/index.js @@ -91,6 +91,7 @@ module.exports = { 'no-lonely-if': 'error', 'no-loop-func': 'error', 'no-mixed-requires': 'error', + 'no-mixed-spaces-and-tabs': 'error', 'no-multi-spaces': 'error', 'no-multi-str': 'error', 'no-multiple-empty-lines': ['error', { diff --git a/test/fixtures/environment.js b/test/fixtures/environment.js index b771ae2..3f4cc19 100644 --- a/test/fixtures/environment.js +++ b/test/fixtures/environment.js @@ -9,9 +9,9 @@ function noop() { // `no-mixed-spaces-and-tabs`. function noMixedSpacesAndTabs() { - const foo = 'bar'; + const foo = 'bar'; - noop(foo); + noop(foo); } noop(noMixedSpacesAndTabs); diff --git a/test/fixtures/incorrect.js b/test/fixtures/incorrect.js index f3dbd7d..4ac3855 100644 --- a/test/fixtures/incorrect.js +++ b/test/fixtures/incorrect.js @@ -7,7 +7,7 @@ function noop() { noop([ 'bar', 'foo']); // `arrow-parens` -noop((foo) => {}); +noop((foo) => noop(foo)); // `brace-style`. try { @@ -25,7 +25,7 @@ noop(['bar','foo']); // `comma-style`. noop({ - bar: 'foo' + bar: 'foo' , foo: 'bar' }); @@ -38,7 +38,7 @@ noop(consistentThis); let curly = true; if (curly) - curly = false + curly = false; // `dot-notation`. const dotNotation = {}; @@ -55,6 +55,11 @@ let id_match; noop(id_match); +// `indent`. +noop({ + bar: 'foo' +}); + // `key-spacing`. noop({ foo:'bar' }); @@ -72,7 +77,8 @@ describe.only('noExclusiveTests', () => { // `new-cap`. const cap = require('cap'); -const newCap = new cap(); + +new cap(); // `newline-after-var`. const newLineAfterVar = 'foo'; @@ -100,6 +106,8 @@ const noConstAssign = true; noConstAssign = false; +noop(noConstAssign); + // `no-constant-condition`. if (true) { noop(true); @@ -123,17 +131,18 @@ try { noop(); } catch (e) {} -// `no-labels`. -noLabels: - while (noLabels) { - break noLabels; - } +// `no-labels` and `no-unused-labels`. +noLabels: { + break noLabels; +} // `no-mixed-spaces-and-tabs`. -const noMixedSpacesAndTabs = { - bar: 'foo', - foo: 'bar' -}; +noop({ + foo: { + bar: 'foo', + foo: 'bar' + } +}); // `no-multi-spaces`. noop(['foo', 'bar']); @@ -168,18 +177,14 @@ noop(Child); // `no-underscore-dangle`. class NoUnderscoreDangle { constructor() { - this._foo = 'bar'; + this._foo(); } } -const noUnderscoreDangle1 = { _foo: 'bar' }; -const noUnderscoreDangle2 = {}; - -noUnderscoreDangle2._foo = 'bar'; +noop(new NoUnderscoreDangle()); -noop(NoUnderscoreDangle); -noop(noUnderscoreDangle1); -noop(noUnderscoreDangle2); +// `no-unused-vars` +const foobar = ''; // `object-curly-spacing`. const objectCurlySpacing = {foo: 'bar'}; @@ -193,10 +198,10 @@ noop(oneVar1); noop(oneVar2); // `one-var-declaration-per-line`. -const oneVar1 = 'foo'; const oneVar2 = 'bar'; +const oneVarDeclarationPerLine1 = 'foo'; const oneVarDeclarationPerLine2 = 'bar'; -noop(oneVar1); -noop(oneVar2); +noop(oneVarDeclarationPerLine1); +noop(oneVarDeclarationPerLine2); // `operator-linebreak`. const operatorLineBreak = 1 + @@ -260,7 +265,7 @@ let spaceBeforeBlocks = true; if (spaceBeforeBlocks){ spaceBeforeBlocks = false; -}else{ +} else { spaceBeforeBlocks = true; } diff --git a/test/index.js b/test/index.js index f0021b5..1411c89 100644 --- a/test/index.js +++ b/test/index.js @@ -23,18 +23,19 @@ describe('eslint-config-seegno', () => { it('should generate violations for environment-specific rules', () => { const source = path.join(__dirname, 'fixtures', 'environment.js'); - linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId).should.containDeep([ - 'eol-last', + Array.from(new Set(linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId))).should.eql([ 'linebreak-style', - 'no-mixed-spaces-and-tabs' + 'no-mixed-spaces-and-tabs', + 'eol-last' ]); }); it('should generate violations for incorrect code', () => { const source = path.join(__dirname, 'fixtures', 'incorrect.js'); - linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId).should.containDeep([ + Array.from(new Set(linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId))).should.eql([ 'array-bracket-spacing', + 'arrow-parens', 'brace-style', 'comma-dangle', 'comma-spacing', @@ -42,10 +43,13 @@ describe('eslint-config-seegno', () => { 'consistent-this', 'curly', 'dot-notation', + 'generator-star-spacing', 'id-match', + 'indent', 'key-spacing', 'keyword-spacing', 'mocha/no-exclusive-tests', + 'no-new', 'new-cap', 'newline-after-var', 'newline-before-return', @@ -55,12 +59,14 @@ describe('eslint-config-seegno', () => { 'no-dupe-class-members', 'no-empty', 'no-labels', + 'no-mixed-spaces-and-tabs', 'no-multi-spaces', 'no-multi-str', 'no-multiple-empty-lines', 'no-spaced-func', 'no-this-before-super', 'no-underscore-dangle', + 'no-unused-vars', 'object-curly-spacing', 'one-var', 'one-var-declaration-per-line',