Skip to content

Commit

Permalink
Move test file overrides to a separate file (#185)
Browse files Browse the repository at this point in the history
* Move test file overrides to a separate file

* Update index.js
  • Loading branch information
tclindner authored Jun 14, 2020
1 parent d601b24 commit 7850e4d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 74 deletions.
76 changes: 2 additions & 74 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const node = require.resolve('./rules/node');
const style = require.resolve('./rules/style');
const variables = require.resolve('./rules/variables');
const prettier = require.resolve('./rules/prettier');
const testFileOverrides = require('./overrides/testFiles');

module.exports = {
extends: [
Expand All @@ -31,78 +32,5 @@ module.exports = {
rules: {
strict: 'error',
},
overrides: [
{
files: ['**/*.spec.js', '**/*.test.js', '**/tests-*.js'],
env: {
jest: true,
mocha: true,
},
rules: {
'array-bracket-newline': 'off',
'array-element-newline': 'off',
'eslint-comments/no-unused-disable': 'error',
'id-length': 'off',
'jest/consistent-test-it': [
'error',
{
fn: 'test',
withinDescribe: 'test',
},
],
'jest/expect-expect': 'error',
'jest/no-alias-methods': 'error',
'jest/no-commented-out-tests': 'error',
'jest/no-disabled-tests': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-if': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-large-snapshots': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-callback': 'error',
'jest/no-test-return-statement': 'error',
'jest/no-truthy-falsy': 'error',
'jest/no-try-expect': 'error',
'jest/prefer-called-with': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-to-be-null': 'error',
'jest/prefer-to-be-undefined': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-todo': 'error',
'jest/require-to-throw-message': 'error',
'jest/require-top-level-describe': 'error',
'jest/valid-describe': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/valid-expect': 'error',
'jest/valid-title': 'error',
'max-lines': 'off',
'object-curly-newline': 'off',
'padding-line-between-statements': [
'error',
{blankLine: 'always', prev: '*', next: 'return'},
{blankLine: 'any', prev: ['const', 'let', 'var'], next: '*'},
{blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var']},
{blankLine: 'always', prev: 'directive', next: '*'},
{blankLine: 'any', prev: ['for', 'do', 'while'], next: '*'},
{blankLine: 'any', prev: '*', next: 'for'},
{blankLine: 'any', prev: 'import', next: '*'},
{blankLine: 'any', prev: 'import', next: 'import'},
{blankLine: 'any', prev: 'if', next: '*'},
{blankLine: 'any', prev: 'function', next: '*'},
{blankLine: 'any', prev: '*', next: 'function'},
{blankLine: 'any', prev: '*', next: 'export'},
{blankLine: 'any', prev: '*', next: 'cjs-export'},
{blankLine: 'any', prev: 'cjs-import', next: '*'},
{blankLine: 'any', prev: 'cjs-import', next: 'cjs-import'},
],
},
},
],
overrides: [testFileOverrides],
};
80 changes: 80 additions & 0 deletions overrides/testFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const testFileOverrides = {
files: ['**/*.spec.js', '**/*.test.js', '**/tests-*.js'],
env: {
jest: true,
mocha: true,
},
rules: {
'array-bracket-newline': 'off',
'array-element-newline': 'off',
'eslint-comments/no-unused-disable': 'error',
'id-length': 'off',
'jest/consistent-test-it': [
'error',
{
fn: 'test',
withinDescribe: 'test',
},
],
'jest/expect-expect': 'error',
'jest/no-alias-methods': 'error',
'jest/no-commented-out-tests': 'error',
'jest/no-disabled-tests': 'error',
'jest/no-duplicate-hooks': 'error',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-if': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-large-snapshots': 'error',
'jest/no-standalone-expect': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-callback': 'error',
'jest/no-test-return-statement': 'error',
'jest/no-truthy-falsy': 'error',
'jest/no-try-expect': 'error',
'jest/prefer-called-with': 'error',
'jest/prefer-hooks-on-top': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-to-be-null': 'error',
'jest/prefer-to-be-undefined': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-todo': 'error',
'jest/require-to-throw-message': 'error',
'jest/require-top-level-describe': 'error',
'jest/valid-describe': 'error',
'jest/valid-expect-in-promise': 'error',
'jest/valid-expect': 'error',
'jest/valid-title': 'error',
'max-lines': 'off',
'max-lines-per-function': 'off',
'max-nested-callbacks': 'off',
'max-statements': 'off',
'newline-after-var': 'off',
'no-process-env': 'off',
'no-undefined': 'off',
'object-curly-newline': 'off',
'padding-line-between-statements': [
'error',
{blankLine: 'always', prev: '*', next: 'return'},
{blankLine: 'any', prev: ['const', 'let', 'var'], next: '*'},
{blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var']},
{blankLine: 'always', prev: 'directive', next: '*'},
{blankLine: 'any', prev: ['for', 'do', 'while'], next: '*'},
{blankLine: 'any', prev: '*', next: 'for'},
{blankLine: 'any', prev: 'import', next: '*'},
{blankLine: 'any', prev: 'import', next: 'import'},
{blankLine: 'any', prev: 'if', next: '*'},
{blankLine: 'any', prev: 'function', next: '*'},
{blankLine: 'any', prev: '*', next: 'function'},
{blankLine: 'any', prev: '*', next: 'export'},
{blankLine: 'any', prev: '*', next: 'cjs-export'},
{blankLine: 'any', prev: 'cjs-import', next: '*'},
{blankLine: 'any', prev: 'cjs-import', next: 'cjs-import'},
],
},
};

module.exports = testFileOverrides;

0 comments on commit 7850e4d

Please sign in to comment.