From 963e693b8936d4f462ca48e11850ef1a9e84864f Mon Sep 17 00:00:00 2001 From: Nuno Sousa Date: Thu, 2 Mar 2017 15:42:34 +0000 Subject: [PATCH] Fix missing rules in tests --- test/fixtures/environment.js | 16 +----------- test/fixtures/incorrect.js | 49 +++++++++++++++++------------------- test/index.js | 12 ++++++--- 3 files changed, 32 insertions(+), 45 deletions(-) diff --git a/test/fixtures/environment.js b/test/fixtures/environment.js index b771ae2..82c8ce4 100644 --- a/test/fixtures/environment.js +++ b/test/fixtures/environment.js @@ -1,19 +1,5 @@ // Incorrect environment-specific (os or editor) setings. -// Avoid extra `no-unused-vars` violations. -function noop() { - // do nothing -} - // `linebreak-style` - Windows line endings (CRLF). -// `no-mixed-spaces-and-tabs`. -function noMixedSpacesAndTabs() { - const foo = 'bar'; - - noop(foo); -} - -noop(noMixedSpacesAndTabs); - -// `eol-last` - no newline at the end of the file. \ No newline at end of file +// `eol-last` - no newline at the end of the file. \ No newline at end of file diff --git a/test/fixtures/incorrect.js b/test/fixtures/incorrect.js index f3dbd7d..c939f6a 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); @@ -124,16 +132,9 @@ try { } catch (e) {} // `no-labels`. -noLabels: - while (noLabels) { - break noLabels; - } - -// `no-mixed-spaces-and-tabs`. -const noMixedSpacesAndTabs = { - bar: 'foo', - foo: 'bar' -}; +noLabels: { + break noLabels; +} // `no-multi-spaces`. noop(['foo', 'bar']); @@ -168,18 +169,14 @@ noop(Child); // `no-underscore-dangle`. class NoUnderscoreDangle { constructor() { - this._foo = 'bar'; + this._foo(); } } -const noUnderscoreDangle1 = { _foo: 'bar' }; -const noUnderscoreDangle2 = {}; +noop(new NoUnderscoreDangle()); -noUnderscoreDangle2._foo = 'bar'; - -noop(NoUnderscoreDangle); -noop(noUnderscoreDangle1); -noop(noUnderscoreDangle2); +// `no-unused-vars` +const foobar = ''; // `object-curly-spacing`. const objectCurlySpacing = {foo: 'bar'}; @@ -193,10 +190,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 +257,7 @@ let spaceBeforeBlocks = true; if (spaceBeforeBlocks){ spaceBeforeBlocks = false; -}else{ +} else { spaceBeforeBlocks = true; } diff --git a/test/index.js b/test/index.js index f0021b5..5ead7f2 100644 --- a/test/index.js +++ b/test/index.js @@ -23,18 +23,18 @@ 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' + '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 +42,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', @@ -61,6 +64,7 @@ describe('eslint-config-seegno', () => { 'no-spaced-func', 'no-this-before-super', 'no-underscore-dangle', + 'no-unused-vars', 'object-curly-spacing', 'one-var', 'one-var-declaration-per-line',