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

Update linting configuration, support Node.js 12 in CI #168

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 35 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
/* eslint-disable import/no-extraneous-dependencies */
const {
rules: airbnbBaseStyle,
} = require('eslint-config-airbnb-base/rules/style');
const {
rules: airbnbBaseBestPractices,
} = require('eslint-config-airbnb-base/rules/best-practices');

module.exports = {
extends: [
'eslint-config-airbnb-base',
'eslint-config-prettier',
'plugin:prettier/recommended',
'prettier/babel',
'plugin:ava/recommended',
],
plugins: ['eslint-plugin-prettier', 'eslint-plugin-ava'],
plugins: ['eslint-plugin-babel', 'eslint-plugin-ava'],
parser: 'babel-eslint',
env: {
es6: true,
commonjs: true,
node: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
// Disable rules for which there are eslint-plugin-babel replacements:
// https://github.com/babel/eslint-plugin-babel#rules
'new-cap': 'off',
'no-invalid-this': 'off',
'object-curly-spacing': 'off',
semi: 'off',
'no-unused-expressions': 'off',
// Ensure the replacement rules use the options set by airbnb rather than ESLint defaults.
'babel/new-cap': airbnbBaseStyle['new-cap'],
'babel/no-invalid-this': airbnbBaseBestPractices['no-invalid-this'],
'babel/object-curly-spacing': airbnbBaseStyle['object-curly-spacing'],
'babel/semi': airbnbBaseStyle.semi,
'babel/no-unused-expressions':
airbnbBaseBestPractices['no-unused-expressions'],
'class-methods-use-this': 'off',
'no-shadow': 'off',
'no-underscore-dangle': 'off',
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'es5',
bracketSpacing: true,
jsxBracketSameLine: true,
trailingComma: 'all',
proseWrap: 'always',
endOfLine: 'lf',
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_js:
- '6'
- '8'
- '10'
- '11'
- '12'
before_install:
# Required due to: https://github.com/travis-ci/travis-ci/issues/7951
- curl -sSfL https://yarnpkg.com/install.sh | bash
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@
"javascript-stringify": "^2.0.0"
},
"devDependencies": {
"@types/node": "^10.12.17",
"@types/node": "^11.13.7",
"@types/webpack": "^4.4.21",
"auto-changelog": "^1.8.0",
"auto-changelog": "^1.13.0",
"ava": "^1.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.6.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-ava": "^6.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.0.0",
"prettier": "^1.14.3",
"typescript": "^3.2.2",
"webpack": "^4.20.2"
"prettier": "^1.17.0",
"typescript": "^3.4.5",
"webpack": "^4.30.0"
}
}
2 changes: 1 addition & 1 deletion src/ChainedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ module.exports = class extends Chainable {
when(
condition,
whenTruthy = Function.prototype,
whenFalsy = Function.prototype
whenFalsy = Function.prototype,
) {
if (condition) {
whenTruthy(this);
Expand Down
2 changes: 1 addition & 1 deletion src/ChainedSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = class extends Chainable {
when(
condition,
whenTruthy = Function.prototype,
whenFalsy = Function.prototype
whenFalsy = Function.prototype,
) {
if (condition) {
whenTruthy(this);
Expand Down
12 changes: 6 additions & 6 deletions src/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = class extends ChainedMap {
stringify(
value.__pluginArgs && value.__pluginArgs.length
? { args: value.__pluginArgs }
: {}
: {},
)
);
}
Expand Down Expand Up @@ -104,7 +104,7 @@ module.exports = class extends ChainedMap {

return stringify(value);
},
2
2,
);
}

Expand Down Expand Up @@ -133,9 +133,9 @@ module.exports = class extends ChainedMap {
entry: Object.keys(entryPoints).reduce(
(acc, key) =>
Object.assign(acc, { [key]: entryPoints[key].values() }),
{}
{},
),
})
}),
);
}

Expand All @@ -157,13 +157,13 @@ module.exports = class extends ChainedMap {

if (!omit.includes('entry') && 'entry' in obj) {
Object.keys(obj.entry).forEach(name =>
this.entry(name).merge([].concat(obj.entry[name]))
this.entry(name).merge([].concat(obj.entry[name])),
);
}

if (!omit.includes('plugin') && 'plugin' in obj) {
Object.keys(obj.plugin).forEach(name =>
this.plugin(name).merge(obj.plugin[name])
this.plugin(name).merge(obj.plugin[name]),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/DevServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ module.exports = class extends ChainedMap {
{
allowedHosts: this.allowedHosts.values(),
},
this.entries() || {}
)
this.entries() || {},
),
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ module.exports = class extends ChainedMap {
Object.assign(this.entries() || {}, {
defaultRules: this.defaultRules.values().map(r => r.toConfig()),
rules: this.rules.values().map(r => r.toConfig()),
})
}),
);
}

merge(obj, omit = []) {
if (!omit.includes('rule') && 'rule' in obj) {
Object.keys(obj.rule).forEach(name =>
this.rule(name).merge(obj.rule[name])
this.rule(name).merge(obj.rule[name]),
);
}

if (!omit.includes('defaultRule') && 'defaultRule' in obj) {
Object.keys(obj.defaultRule).forEach(name =>
this.defaultRule(name).merge(obj.defaultRule[name])
this.defaultRule(name).merge(obj.defaultRule[name]),
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Optimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ module.exports = class extends ChainedMap {
minimizer(name) {
return this.minimizers.getOrCompute(
name,
() => new Plugin(this, name, 'optimization.minimizer')
() => new Plugin(this, name, 'optimization.minimizer'),
);
}

toConfig() {
return this.clean(
Object.assign(this.entries() || {}, {
minimizer: this.minimizers.values().map(plugin => plugin.toConfig()),
})
}),
);
}

merge(obj, omit = []) {
if (!omit.includes('minimizer') && 'minimizer' in obj) {
Object.keys(obj.minimizer).forEach(name =>
this.minimizer(name).merge(obj.minimizer[name])
this.minimizer(name).merge(obj.minimizer[name]),
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Orderable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = Class =>
if (this.__after) {
throw new Error(
`Unable to set .before(${JSON.stringify(
name
)}) with existing value for .after()`
name,
)}) with existing value for .after()`,
);
}

Expand All @@ -17,8 +17,8 @@ module.exports = Class =>
if (this.__before) {
throw new Error(
`Unable to set .after(${JSON.stringify(
name
)}) with existing value for .before()`
name,
)}) with existing value for .before()`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ module.exports = Orderable(

return config;
}
}
},
);
6 changes: 3 additions & 3 deletions src/Resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = class extends ChainedMap {
plugin(name) {
return this.plugins.getOrCompute(
name,
() => new Plugin(this, name, 'resolve.plugin')
() => new Plugin(this, name, 'resolve.plugin'),
);
}

Expand All @@ -42,7 +42,7 @@ module.exports = class extends ChainedMap {
mainFiles: this.mainFiles.values(),
modules: this.modules.values(),
plugins: this.plugins.values().map(plugin => plugin.toConfig()),
})
}),
);
}

Expand All @@ -59,7 +59,7 @@ module.exports = class extends ChainedMap {

if (!omit.includes('plugin') && 'plugin' in obj) {
Object.keys(obj.plugin).forEach(name =>
this.plugin(name).merge(obj.plugin[name])
this.plugin(name).merge(obj.plugin[name]),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ResolveLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = class extends Resolve {
moduleExtensions: this.moduleExtensions.values(),
packageMains: this.packageMains.values(),
},
super.toConfig()
)
super.toConfig(),
),
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Rule = Orderable(
exclude: this.exclude.values(),
oneOf: this.oneOfs.values().map(oneOf => oneOf.toConfig()),
use: this.uses.values().map(use => use.toConfig()),
})
}),
);

Object.defineProperties(config, {
Expand All @@ -76,13 +76,13 @@ const Rule = Orderable(

if (!omit.includes('use') && 'use' in obj) {
Object.keys(obj.use).forEach(name =>
this.use(name).merge(obj.use[name])
this.use(name).merge(obj.use[name]),
);
}

if (!omit.includes('oneOf') && 'oneOf' in obj) {
Object.keys(obj.oneOf).forEach(name =>
this.oneOf(name).merge(obj.oneOf[name])
this.oneOf(name).merge(obj.oneOf[name]),
);
}

Expand All @@ -99,7 +99,7 @@ const Rule = Orderable(
'test',
]);
}
}
},
);

module.exports = Rule;
2 changes: 1 addition & 1 deletion src/Use.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ module.exports = Orderable(

return config;
}
}
},
);
10 changes: 5 additions & 5 deletions test/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ test('toString', t => {
)
]
}
`.trim()
`.trim(),
);
});

Expand All @@ -500,7 +500,7 @@ test('toString for functions with custom expression', t => {
]
}
}
`.trim()
`.trim(),
);
});

Expand All @@ -518,7 +518,7 @@ test('toString with custom prefix', t => {
new TestPlugin()
]
}
`.trim()
`.trim(),
);
});

Expand Down Expand Up @@ -549,7 +549,7 @@ test('static Config.toString', t => {
},
],
},
})
}),
).trim(),
`
{
Expand All @@ -573,6 +573,6 @@ test('static Config.toString', t => {
]
}
}
`.trim()
`.trim(),
);
});
2 changes: 1 addition & 1 deletion test/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test('init', t => {
});
const initialized = plugin.get('init')(
plugin.get('plugin'),
plugin.get('args')
plugin.get('args'),
);

t.is(instance, plugin);
Expand Down
2 changes: 1 addition & 1 deletion test/Resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ test('merge with omit', t => {
extensions: ['.jsx'],
alias: { ReactDOM: 'src/react-dom' },
},
['alias']
['alias'],
);

t.deepEqual(resolve.toConfig(), {
Expand Down
Loading