Skip to content

Commit

Permalink
chore(lint): fix linter settings (#467)
Browse files Browse the repository at this point in the history
This narrows down to a single eslint
configuration and fixes existing
linter issues. This also updates
to the latest webpack-contrib eslint
recommendations.

Fixes N/A
  • Loading branch information
codymikol committed Jan 29, 2021
1 parent 6369729 commit 52ac365
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 33 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
lib/*
/node_modules
/dist
19 changes: 0 additions & 19 deletions .eslintrc

This file was deleted.

9 changes: 8 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ module.exports = {
plugins: ['prettier'],
extends: ['@webpack-contrib/eslint-config-webpack'],
rules: {
"consistent-return": "off",
"no-console": "off",
"no-param-reassign": "off",
"no-underscore-dangle": "off",
"prefer-destructuring": ["error", {"object": false, "array": false}],
"prefer-rest-params": "off",
"strict": ["error", "safe"],
'prettier/prettier': [
'error',
{ singleQuote: true, trailingComma: 'es5', arrowParens: 'always' },
],
},
};
};
14 changes: 5 additions & 9 deletions lib/KarmaWebpackController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-console */

const path = require('path');
const fs = require('fs');
const os = require('os');
Expand All @@ -21,12 +19,10 @@ class KarmaSyncPlugin {
// read generated file content and store for karma preprocessor
this.controller.bundlesContent = {};
stats.toJson().assets.forEach((webpackFileObj) => {
const filePath = `${compiler.options.output.path}/${
webpackFileObj.name
}`;
const filePath = `${compiler.options.output.path}/${webpackFileObj.name}`;
this.controller.bundlesContent[webpackFileObj.name] = fs.readFileSync(
filePath,
'utf-8',
'utf-8'
);
});

Expand Down Expand Up @@ -88,7 +84,7 @@ class KarmaWebpackController {
new KarmaSyncPlugin({
karmaEmitter: emitter,
controller: this,
}),
})
);
}

Expand Down Expand Up @@ -135,13 +131,13 @@ class KarmaWebpackController {
if (this.webpackOptions.watch === true) {
console.log('Webpack starts watching...');
this.compiler = webpack(this.webpackOptions, (err, stats) =>
this.handleBuildResult(err, stats, resolve),
this.handleBuildResult(err, stats, resolve)
);

this.setupExitHandler(this.compiler);
} else {
this.compiler = webpack(this.webpackOptions).run((err, stats) =>
this.handleBuildResult(err, stats, resolve),
this.handleBuildResult(err, stats, resolve)
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@commitlint/cli": "^7.1.1",
"@commitlint/config-conventional": "^7.1.1",
"@webpack-contrib/defaults": "^2.5.0",
"@webpack-contrib/eslint-config-webpack": "^2.0.4",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-cli": "^6.26.0",
"babel-jest": "^23.4.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/scenarios/basic-setup/basic-setup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('A basic karma-webpack setup', () => {
plugins: [karmaWebpack, karmaChromeLauncher, karmaMocha, karmaChai],
port: 2389,
logLevel: 'ERROR',
singleRun: true,
singleRun: true
};

beforeAll((done) => {
Expand Down
1 change: 0 additions & 1 deletion test/integration/utils/ScenarioUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
const karma = require('karma');

const ScenarioUtils = { run };
Expand Down

0 comments on commit 52ac365

Please sign in to comment.