Skip to content

Commit 3d07f81

Browse files
committed
perf: avoid duplicate linting when used with eslint-loader
1 parent aec11fc commit 3d07f81

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: lib/loaders/pitcher.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ module.exports = code => code
1010
// and transform it into appropriate requests.
1111
module.exports.pitch = function (remainingRequest) {
1212
const query = qs.parse(this.resourceQuery.slice(1))
13-
const loaders = this.loaders.slice(1) // remove self
13+
14+
// if this is a language block request, remove eslint-loader to avoid
15+
// duplicate linting.
16+
const loaders = query.type
17+
? this.loaders.filter(l => !/(\/|\\|@)eslint-loader/.test(l.path))
18+
: this.loaders
19+
20+
// remove self
21+
loaders.shift()
1422

1523
// do not inject if user uses null-loader to void the type (#1239)
1624
if (loaders.some(l => /(\/|\\|@)null-loader/.test(l.path))) {

0 commit comments

Comments
 (0)