Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

jest: Configure ESLint to use 'plugin:jest/recommended' #1218

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions packages/jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@ module.exports = (neutrino, options = {}) => {
? lintOptions
: merge(lintOptions, {
baseConfig: {
env: {
'jest/globals': true
},
plugins: ['jest'],
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error'
}
extends: ['plugin:jest/recommended']
}
})
);
Expand Down
22 changes: 8 additions & 14 deletions packages/jest/test/jest_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'ava';
import lint from '../../eslint';
import airbnbPreset from '../../airbnb';
import eslintPreset from '../../eslint';
import Neutrino from '../../neutrino/Neutrino';
import neutrino from '../../neutrino';

Expand Down Expand Up @@ -77,25 +78,18 @@ test('uses middleware with options', t => {

test('updates lint config by default', t => {
const api = new Neutrino();
api.use(lint);
api.use(airbnbPreset);
api.use(mw());
const options = api.config.module.rule('lint').use('eslint').get('options');
t.deepEqual(options.baseConfig.env, {
es6: true,
'jest/globals': true
});
t.deepEqual(options.baseConfig.plugins, ['babel', 'jest']);
t.deepEqual(options.baseConfig.rules, {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/valid-expect': 'error'
});
t.deepEqual(options.baseConfig.extends, [
require.resolve('eslint-config-airbnb'),
'plugin:jest/recommended'
]);
});

test('does not update lint config if useEslintrc true', t => {
const api = new Neutrino();
api.use(lint, { eslint: { useEslintrc: true } });
api.use(eslintPreset, { eslint: { useEslintrc: true } });
api.use(mw());
const options = api.config.module.rule('lint').use('eslint').get('options');
t.deepEqual(options.baseConfig, {});
Expand Down