Skip to content

Commit

Permalink
Merge pull request #69 from seegno/bugfix/fix-missing-rules-in-tests
Browse files Browse the repository at this point in the history
Add missing rules and improve tests
  • Loading branch information
rplopes authored Mar 3, 2017
2 parents a1e60ae + 963e693 commit 37a776b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 45 deletions.
16 changes: 1 addition & 15 deletions test/fixtures/environment.js
Original file line number Diff line number Diff line change
@@ -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.
// `eol-last` - no newline at the end of the file.
49 changes: 23 additions & 26 deletions test/fixtures/incorrect.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function noop() {
noop([ 'bar', 'foo']);

// `arrow-parens`
noop((foo) => {});
noop((foo) => noop(foo));

// `brace-style`.
try {
Expand All @@ -25,7 +25,7 @@ noop(['bar','foo']);

// `comma-style`.
noop({
bar: 'foo'
bar: 'foo'
, foo: 'bar'
});

Expand All @@ -38,7 +38,7 @@ noop(consistentThis);
let curly = true;

if (curly)
curly = false
curly = false;

// `dot-notation`.
const dotNotation = {};
Expand All @@ -55,6 +55,11 @@ let id_match;

noop(id_match);

// `indent`.
noop({
bar: 'foo'
});

// `key-spacing`.
noop({ foo:'bar' });

Expand All @@ -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';
Expand Down Expand Up @@ -100,6 +106,8 @@ const noConstAssign = true;

noConstAssign = false;

noop(noConstAssign);

// `no-constant-condition`.
if (true) {
noop(true);
Expand All @@ -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']);
Expand Down Expand Up @@ -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'};
Expand All @@ -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 +
Expand Down Expand Up @@ -260,7 +257,7 @@ let spaceBeforeBlocks = true;

if (spaceBeforeBlocks){
spaceBeforeBlocks = false;
}else{
} else {
spaceBeforeBlocks = true;
}

Expand Down
12 changes: 8 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,32 @@ 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',
'comma-style',
'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',
Expand All @@ -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',
Expand Down

0 comments on commit 37a776b

Please sign in to comment.