Skip to content

Commit

Permalink
Update tests to consider prettier rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Micael Rodrigues committed Oct 8, 2020
1 parent 7576928 commit 6dc0967
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 91 deletions.
44 changes: 13 additions & 31 deletions test/fixtures/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ try {
noop();
}

noop(function *() { return yield noop(); });
noop(function* () {
return yield noop();
});

// `capitalized-comments`.

Expand Down Expand Up @@ -109,8 +111,8 @@ noop(DelimiterDangleType);
noop(DelimiterDangleInterface);

// `generator-star-spacing`
noop(function *() {});
noop(function *foo() {});
noop(function* () {});
noop(function* foo() {});
noop({ *foo() {} });

// `id-match`.
Expand Down Expand Up @@ -159,7 +161,7 @@ function funcThatReturns(bar) {
funcThatReturns('foo');

// `no-class-assign`.
class NoClassAssign { }
class NoClassAssign {}

noop(NoClassAssign);

Expand All @@ -179,15 +181,13 @@ if (noConstantCondition) {

// `no-dupe-class-members`.
class NoDupeClassMembers {

bar() {
return 'bar';
}

foo() {
return 'foo';
}

}

noop(NoDupeClassMembers);
Expand Down Expand Up @@ -217,12 +217,10 @@ noop();
const NoThisBeforeSuper = require('no-this-before-super');

class Child extends NoThisBeforeSuper {

constructor() {
super();
this.foo = 'bar';
}

}

noop(Child);
Expand Down Expand Up @@ -260,13 +258,12 @@ noop(operatorLineBreak);

// `padded-blocks`.
class PaddedBlocks {

constructor() {
switch (true) {
default: noop();
default:
noop();
}
}

}

noop(new PaddedBlocks());
Expand Down Expand Up @@ -332,7 +329,7 @@ const sortObjectProps = {
noop(sortObjectProps);

// `space-before-function-paren`.
(function() {
(function () {
noop();
})();

Expand Down Expand Up @@ -378,11 +375,6 @@ const templateCurlySpacing = 'foo';

noop(`${templateCurlySpacing}`);

// `wrap-iife`.
(function() {
noop();
})();

// `sort-destructure-keys/sort-destructure-keys`.
const props = { KeyA: 1, keyA: 2, keyB: 3, keyZ: 4 };
const { KeyA, keyA, keyB, keyZ, ...rest } = props;
Expand Down Expand Up @@ -430,39 +422,29 @@ function useHook() {
noop(RulesOfHooks, useHook);

// `react/jsx-curly-brace-presence`.
const CurlyBracePresence = () => (
<div foo={'bar'} />
);
const CurlyBracePresence = () => <div foo={'bar'} />;

noop(CurlyBracePresence);

// `react/jsx-no-literals`.
const NoLiterals = () => (
<div>
{'qux'}
</div>
);
const NoLiterals = () => <div>{'qux'}</div>;

noop(NoLiterals);

// `react/jsx-tag-spacing`.
const TagSpacing = () => (
<div />
);
const TagSpacing = () => <div />;

noop(TagSpacing);

// `react/prefer-stateless-function`.
class PreferStatelessFunction extends React.Component {

getFoo = () => {
return 'foo';
}
};

render() {
return this.getFoo();
}

}

noop(PreferStatelessFunction);
133 changes: 73 additions & 60 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const path = require('path');
*/

describe('eslint-config-seegno', () => {
const linter = new CLIEngine({ configFile: path.join(__dirname, '..', 'src', 'index.js') });
const linter = new CLIEngine({
configFile: path.join(__dirname, '..', 'src', 'index.js')
});

it('should not generate any violation for correct code', () => {
const source = path.join(__dirname, 'fixtures', 'correct.js');
Expand All @@ -23,38 +25,44 @@ describe('eslint-config-seegno', () => {
it('should generate violations for environment-specific rules', () => {
const source = path.join(__dirname, 'fixtures', 'environment.js');

Array.from(linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId)).should.eql([
'linebreak-style',
'linebreak-style',
'linebreak-style',
'linebreak-style',
'eol-last'
Array.from(
linter
.executeOnFiles([source])
.results[0].messages.map(violation => violation.ruleId)
).should.eql([
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier'
]);
});

it('should generate violations for incorrect code', () => {
const source = path.join(__dirname, 'fixtures', 'incorrect.js');

Array.from(linter.executeOnFiles([source]).results[0].messages.map(violation => violation.ruleId)).should.eql([
'array-bracket-spacing',
'arrow-parens',
'brace-style',
Array.from(
linter
.executeOnFiles([source])
.results[0].messages.map(violation => violation.ruleId)
).should.eql([
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'capitalized-comments',
'comma-dangle',
'comma-spacing',
'comma-style',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'consistent-this',
'curly',
'prettier/prettier',
'dot-notation',
'flowtype/delimiter-dangle',
'flowtype/delimiter-dangle',
'generator-star-spacing',
'generator-star-spacing',
'generator-star-spacing',
'generator-star-spacing',
'generator-star-spacing',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'id-match',
'indent',
'prettier/prettier',
'jest/no-disabled-tests',
'jest/no-disabled-tests',
'jest/no-disabled-tests',
Expand All @@ -66,71 +74,73 @@ describe('eslint-config-seegno', () => {
'jest/no-disabled-tests',
'jest/no-focused-tests',
'mocha/no-exclusive-tests',
'mocha/no-exclusive-tests',
'jest/no-focused-tests',
'mocha/no-exclusive-tests',
'jest/no-focused-tests',
'mocha/no-exclusive-tests',
'jest/no-focused-tests',
'jest/no-focused-tests',
'jest/no-identical-title',
'key-spacing',
'keyword-spacing',
'prettier/prettier',
'prettier/prettier',
'no-new',
'new-cap',
'new-with-error/new-with-error',
'newline-before-return',
'prettier/prettier',
'no-class-assign',
'no-console',
'no-const-assign',
'no-constant-condition',
'prettier/prettier',
'no-dupe-class-members',
'prettier/prettier',
'no-empty',
'no-labels',
'no-labels',
'no-multi-spaces',
'prettier/prettier',
'no-multi-str',
'no-multiple-empty-lines',
'no-spaced-func',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'no-this-before-super',
'prettier/prettier',
'no-undef',
'prettier/prettier',
'no-underscore-dangle',
'prettier/prettier',
'no-unused-vars',
'object-curly-spacing',
'object-curly-spacing',
'prettier/prettier',
'one-var',
'one-var-declaration-per-line',
'operator-linebreak',
'padded-blocks',
'padded-blocks',
'padded-blocks',
'padded-blocks',
'padded-blocks',
'padded-blocks',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'padding-line-between-statements',
'quote-props',
'quote-props',
'quote-props',
'quote-props',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'quotes',
'semi',
'semi-spacing',
'semi-spacing',
'prettier/prettier',
'prettier/prettier',
'sort-imports-es6/sort-imports-es6',
'sort-keys',
'space-before-blocks',
'space-before-function-paren',
'space-in-parens',
'space-in-parens',
'space-infix-ops',
'space-unary-ops',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'spaced-comment',
'sql-template/no-unsafe-query',
'switch-case/newline-between-switch-case',
'no-fallthrough',
'switch-case/newline-between-switch-case',
'template-curly-spacing',
'template-curly-spacing',
'wrap-iife',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'sort-destructure-keys/sort-destructure-keys',
'yoda',
'react-hooks/exhaustive-deps',
Expand All @@ -142,14 +152,17 @@ describe('eslint-config-seegno', () => {
'react-hooks/rules-of-hooks',
'react-hooks/rules-of-hooks',
'react-hooks/rules-of-hooks',
'prettier/prettier',
'react/jsx-curly-brace-presence',
'prettier/prettier',
'react/jsx-no-literals',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/jsx-tag-spacing',
'react/prefer-stateless-function'
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'prettier/prettier',
'react/prefer-stateless-function',
'prettier/prettier',
'prettier/prettier'
]);
});
});

0 comments on commit 6dc0967

Please sign in to comment.