From 991b360c90556167ae76dbc84517180a6cb171a9 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 24 Jul 2017 11:54:06 +0200 Subject: [PATCH] fix useless-escape linting issues --- bin/convert-argv.js | 2 +- lib/MultiCompiler.js | 4 ++-- lib/Parser.js | 2 +- lib/Stats.js | 2 +- lib/Template.js | 2 +- lib/dependencies/HarmonyCompatibilityDependency.js | 2 +- lib/optimize/CommonsChunkPlugin.js | 4 ++-- test/binCases/config-name/not-found/test.js | 2 +- test/configCases/rule-set/custom/webpack.config.js | 4 ++-- test/statsCases/named-chunks-plugin-async/webpack.config.js | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/convert-argv.js b/bin/convert-argv.js index 24be809ebf4..043ea2abb4c 100644 --- a/bin/convert-argv.js +++ b/bin/convert-argv.js @@ -300,7 +300,7 @@ module.exports = function(yargs, argv, convertOptions) { binding += "-loader"; } var rule = { - test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), + test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape loader: binding }; if(arg === "module-bind-pre") { diff --git a/lib/MultiCompiler.js b/lib/MultiCompiler.js index bb387a3d304..ac133181836 100644 --- a/lib/MultiCompiler.js +++ b/lib/MultiCompiler.js @@ -46,8 +46,8 @@ module.exports = class MultiCompiler extends Tapable { get outputPath() { let commonPath = this.compilers[0].outputPath; for(const compiler of this.compilers) { - while(compiler.outputPath.indexOf(commonPath) !== 0 && /[\/\\]/.test(commonPath)) { - commonPath = commonPath.replace(/[\/\\][^\/\\]*$/, ""); + while(compiler.outputPath.indexOf(commonPath) !== 0 && /[/\\]/.test(commonPath)) { + commonPath = commonPath.replace(/[/\\][^/\\]*$/, ""); } } diff --git a/lib/Parser.js b/lib/Parser.js index 96eb6e7d785..6bf07a58fc9 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -1102,7 +1102,7 @@ class Parser extends Tapable { result = this.applyPluginsBailResult1("call " + callee.identifier, expression); if(result === true) return; - let identifier = callee.identifier.replace(/\.[^\.]+$/, ".*"); + let identifier = callee.identifier.replace(/\.[^.]+$/, ".*"); if(identifier !== callee.identifier) { result = this.applyPluginsBailResult1("call " + identifier, expression); if(result === true) diff --git a/lib/Stats.js b/lib/Stats.js index 47548a0adc4..93291c5115e 100644 --- a/lib/Stats.js +++ b/lib/Stats.js @@ -108,7 +108,7 @@ class Stats { const showPublicPath = optionOrLocalFallback(options.publicPath, !forToString); const excludeModules = [].concat(optionOrFallback(options.exclude, [])).map(item => { if(typeof item === "string") { - const regExp = new RegExp(`[\\\\/]${item.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`); + const regExp = new RegExp(`[\\\\/]${item.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`); // eslint-disable-line no-useless-escape return ident => regExp.test(ident); } if(item && typeof item === "object" && typeof item.test === "function") diff --git a/lib/Template.js b/lib/Template.js index d7ee6e85b11..6c7235c5b98 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -28,7 +28,7 @@ module.exports = class Template extends Tapable { static toPath(str) { if(typeof str !== "string") return ""; - return str.replace(/[^a-zA-Z0-9_!§$()=\-\^°]+/g, "-").replace(/^-|-$/, ""); + return str.replace(/[^a-zA-Z0-9_!§$()=\-^°]+/g, "-").replace(/^-|-$/, ""); } // map number to a single character a-z, A-Z or <_ + number> if number is too big diff --git a/lib/dependencies/HarmonyCompatibilityDependency.js b/lib/dependencies/HarmonyCompatibilityDependency.js index 744b979bee4..1370346e059 100644 --- a/lib/dependencies/HarmonyCompatibilityDependency.js +++ b/lib/dependencies/HarmonyCompatibilityDependency.js @@ -21,7 +21,7 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate const usedExports = dep.originModule.usedExports; if(usedExports && !Array.isArray(usedExports)) { const exportName = dep.originModule.exportsArgument || "exports"; - const content = `Object.defineProperty(${exportName}, \"__esModule\", { value: true });\n`; + const content = `Object.defineProperty(${exportName}, "__esModule", { value: true });\n`; source.insert(-10, content); } } diff --git a/lib/optimize/CommonsChunkPlugin.js b/lib/optimize/CommonsChunkPlugin.js index 51ff53807c5..eaa2c323547 100644 --- a/lib/optimize/CommonsChunkPlugin.js +++ b/lib/optimize/CommonsChunkPlugin.js @@ -60,8 +60,8 @@ The available options are: * that webpack will take care of loading this file. */ if(options.async && options.filename) { - throw new Error(`You can not specify a filename if you use the \"async\" option. -You can however specify the name of the async chunk by passing the desired string as the \"async\" option.`); + throw new Error(`You can not specify a filename if you use the "async" option. +You can however specify the name of the async chunk by passing the desired string as the "async" option.`); } /** diff --git a/test/binCases/config-name/not-found/test.js b/test/binCases/config-name/not-found/test.js index d8cb53b704d..b147887589b 100644 --- a/test/binCases/config-name/not-found/test.js +++ b/test/binCases/config-name/not-found/test.js @@ -3,6 +3,6 @@ module.exports = function testAssertions(code, stdout, stderr) { code.should.not.eql(0); stdout.should.be.empty(); - stderr[0].should.containEql("Configuration with name \'foo\' was not found."); + stderr[0].should.containEql("Configuration with name 'foo' was not found."); }; diff --git a/test/configCases/rule-set/custom/webpack.config.js b/test/configCases/rule-set/custom/webpack.config.js index 9b7514c9e2f..c69c1dff1f5 100644 --- a/test/configCases/rule-set/custom/webpack.config.js +++ b/test/configCases/rule-set/custom/webpack.config.js @@ -7,9 +7,9 @@ module.exports = { return { loader: "./loader", options: { - resource: data.resource.replace(/^.*[\\\/]/g, ""), + resource: data.resource.replace(/^.*[\\/]/g, ""), resourceQuery: data.resourceQuery, - issuer: data.issuer.replace(/^.*[\\\/]/g, ""), + issuer: data.issuer.replace(/^.*[\\/]/g, ""), } }; } diff --git a/test/statsCases/named-chunks-plugin-async/webpack.config.js b/test/statsCases/named-chunks-plugin-async/webpack.config.js index 1b81d94fa69..ac033880cca 100644 --- a/test/statsCases/named-chunks-plugin-async/webpack.config.js +++ b/test/statsCases/named-chunks-plugin-async/webpack.config.js @@ -14,7 +14,7 @@ module.exports = { } const chunkModulesToName = (chunk) => chunk.mapModules((mod) => { const rs = new RequestShortener(mod.context); - return rs.shorten(mod.request).replace(/[.\/\\]/g, "_"); + return rs.shorten(mod.request).replace(/[./\\]/g, "_"); }).join("-"); if(chunk.getNumberOfModules() > 0) {