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

eslint: Lint the tests directory by default too #951

Merged
merged 1 commit into from
Jun 14, 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
8 changes: 4 additions & 4 deletions packages/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const eslint = require('@neutrinojs/eslint');

// Usage shows default values
neutrino.use(eslint, {
test: /\.(js|jsx)$/,
include: [], /* Should specify either include or exclude */
exclude: [], /* Should specify either include or exclude */
test: neutrino.regexFromExtensions(), // Uses extensions from neutrino.options.extensions
include: [neutrino.options.source, neutrino.options.tests],
exclude: [],
eslint: {
failOnError: neutrino.config.get('mode') === 'production',
cwd: neutrino.options.root,
useEslintrc: false,
root: true,
extensions: neutrino.options.extensions,
plugins: ['babel'],
baseConfig: {},
envs: ['es6'],
Expand Down
14 changes: 3 additions & 11 deletions packages/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,15 @@ const eslintrc = (neutrino, override) => {
.use('eslint')
.get('options')
),
// We remove these keys since they are needed when running the lint command
// but not the eslintrc command. The lint command uses ESLint's CLIEngine,
// but the ESLint RC format does not match the CLIEngine format exactly. We
// must remove anything we add that does not comply with ESLint's schemas.
// https://github.com/eslint/eslint/blob/9d1df92628dd4dd1e70fbb19454008e146387435/conf/config-schema.js
// https://github.com/eslint/eslint/blob/9d1df92628dd4dd1e70fbb19454008e146387435/lib/config/config-validator.js#L167
// Remove keys that are eslint-loader specific, since they'll be rejected by the .eslintrc schema:
// https://github.com/eslint/eslint/blob/v4.19.1/conf/config-schema.js
[
'failOnError',
'emitWarning',
'emitError',
'cwd',
'useEslintrc',
'fix',
'extensions',
'formatter'
]
);
Expand Down Expand Up @@ -85,16 +80,13 @@ module.exports = (neutrino, opts = {}) => {
}

const defaults = {
include: !opts.include ? [neutrino.options.source] : undefined,
include: !opts.include ? [neutrino.options.source, neutrino.options.tests] : undefined,
eslint: {
failOnError: neutrino.config.get('mode') === 'production',
cwd: neutrino.options.root,
useEslintrc: false,
root: true,
formatter: 'codeframe',
// eslint-loader uses executeOnText(), which ignores the `extensions` setting.
// However it's still needed for the lint command, as it uses executeOnFiles().
extensions: neutrino.options.extensions,
// Unfortunately we can't `require.resolve('eslint-plugin-babel')` due to:
// https://github.com/eslint/eslint/issues/6237
// ...so we have no choice but to rely on it being hoisted.
Expand Down