Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vue-loader
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pi-plusplus
fork-from-github
vue-loader
Commits
6f1d404c
Commit
6f1d404c
authored
Jul 17, 2018
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: should not remove eslint-loader on src import blocks (close #1359)
parent
be2384c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
pitcher.js
lib/loaders/pitcher.js
+33
-6
No files found.
lib/loaders/pitcher.js
View file @
6f1d404c
...
...
@@ -5,6 +5,25 @@ const selfPath = require.resolve('../index')
const
templateLoaderPath
=
require
.
resolve
(
'./templateLoader'
)
const
stylePostLoaderPath
=
require
.
resolve
(
'./stylePostLoader'
)
const
isESLintLoader
=
l
=>
/
(\/
|
\\
|@
)
eslint-loader/
.
test
(
l
.
path
)
const
isNullLoader
=
l
=>
/
(\/
|
\\
|@
)
null-loader/
.
test
(
l
.
path
)
const
isCSSLoader
=
l
=>
/
(\/
|
\\
|@
)
css-loader/
.
test
(
l
.
path
)
const
isPitcher
=
l
=>
l
.
path
!==
__filename
const
dedupeESLintLoader
=
loaders
=>
{
const
res
=
[]
let
seen
=
false
loaders
.
forEach
(
l
=>
{
if
(
!
isESLintLoader
(
l
))
{
res
.
push
(
l
)
}
else
if
(
!
seen
)
{
seen
=
true
res
.
push
(
l
)
}
})
return
res
}
module
.
exports
=
code
=>
code
// This pitching loader is responsible for intercepting all vue block requests
...
...
@@ -16,17 +35,25 @@ module.exports.pitch = function (remainingRequest) {
let
loaders
=
this
.
loaders
// if this is a language block request,
remove eslint-loader to avoi
d
//
duplicate linting.
// if this is a language block request,
eslint-loader may get matche
d
//
multiple times
if
(
query
.
type
)
{
loaders
=
loaders
.
filter
(
l
=>
!
/
(\/
|
\\
|@
)
eslint-loader/
.
test
(
l
.
path
))
// if this is an inline block, since the whole file itself is being linted,
// remove eslint-loader to avoid duplicate linting.
if
(
/
\.
vue$/
.
test
(
this
.
resourcePath
))
{
loaders
=
loaders
.
filter
(
l
=>
!
isESLintLoader
(
l
))
}
else
{
// This is a src import. Just make sure there's not more than 1 instance
// of eslint present.
loaders
=
dedupeESLintLoader
(
loaders
)
}
}
// remove self
loaders
=
loaders
.
filter
(
l
=>
l
.
path
!==
__filename
)
loaders
=
loaders
.
filter
(
isPitcher
)
// do not inject if user uses null-loader to void the type (#1239)
if
(
loaders
.
some
(
l
=>
/
(\/
|
\\
|@
)
null-loader/
.
test
(
l
.
path
)
))
{
if
(
loaders
.
some
(
isNullLoader
))
{
return
}
...
...
@@ -58,7 +85,7 @@ module.exports.pitch = function (remainingRequest) {
// Inject style-post-loader before css-loader for scoped CSS and trimming
if
(
query
.
type
===
`style`
)
{
const
cssLoaderIndex
=
loaders
.
findIndex
(
l
=>
/
(\/
|
\\
|@
)
css-loader/
.
test
(
l
.
path
)
)
const
cssLoaderIndex
=
loaders
.
findIndex
(
isCSSLoader
)
if
(
cssLoaderIndex
>
-
1
)
{
const
afterLoaders
=
loaders
.
slice
(
0
,
cssLoaderIndex
+
1
)
const
beforeLoaders
=
loaders
.
slice
(
cssLoaderIndex
+
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment