Skip to content

Commit 9a47a3f

Browse files
committed
fix eslint switch case indent rule
1 parent d1c4224 commit 9a47a3f

File tree

3 files changed

+20
-43
lines changed

3 files changed

+20
-43
lines changed

.eslintrc

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"node": true
55
},
66

7-
"rules": {
7+
"rules": {
88
"accessor-pairs": 2,
99
"array-bracket-spacing": 0,
1010
"block-scoped-var": 0,
@@ -26,29 +26,21 @@
2626
"eqeqeq": [2, "allow-null"],
2727
"func-names": 0,
2828
"func-style": 0,
29-
"generator-star": 0,
3029
"generator-star-spacing": [2, { "before": true, "after": true }],
31-
"global-strict": 0,
3230
"guard-for-in": 0,
3331
"handle-callback-err": [2, "^(err|error)$" ],
34-
"indent": [2, 2],
32+
"indent": [2, 2, { "SwitchCase": 1 }],
3533
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
3634
"linebreak-style": 0,
3735
"lines-around-comment": 0,
38-
"max-depth": 0,
39-
"max-len": 0,
4036
"max-nested-callbacks": 0,
41-
"max-params": 0,
42-
"max-statements": 0,
4337
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
4438
"new-parens": 2,
4539
"newline-after-var": 0,
4640
"no-alert": 0,
4741
"no-array-constructor": 2,
48-
"no-bitwise": 0,
4942
"no-caller": 2,
5043
"no-catch-shadow": 0,
51-
"no-comma-dangle": 0,
5244
"no-cond-assign": 2,
5345
"no-console": 0,
5446
"no-constant-condition": 0,
@@ -63,7 +55,6 @@
6355
"no-else-return": 0,
6456
"no-empty": 0,
6557
"no-empty-character-class": 2,
66-
"no-empty-class": 0,
6758
"no-empty-label": 2,
6859
"no-eq-null": 0,
6960
"no-eval": 2,
@@ -73,7 +64,6 @@
7364
"no-extra-boolean-cast": 2,
7465
"no-extra-parens": 0,
7566
"no-extra-semi": 0,
76-
"no-extra-strict": 0,
7767
"no-fallthrough": 2,
7868
"no-floating-decimal": 2,
7969
"no-func-assign": 2,
@@ -106,21 +96,18 @@
10696
"no-octal-escape": 2,
10797
"no-param-reassign": 0,
10898
"no-path-concat": 0,
109-
"no-plusplus": 0,
11099
"no-process-env": 0,
111100
"no-process-exit": 0,
112101
"no-proto": 0,
113102
"no-redeclare": 2,
114103
"no-regex-spaces": 2,
115-
"no-reserved-keys": 0,
116104
"no-restricted-modules": 0,
117105
"no-return-assign": 2,
118106
"no-script-url": 0,
119107
"no-self-compare": 2,
120108
"no-sequences": 2,
121109
"no-shadow": 0,
122110
"no-shadow-restricted-names": 2,
123-
"no-space-before-semi": 0,
124111
"no-spaced-func": 2,
125112
"no-sparse-arrays": 2,
126113
"no-sync": 0,
@@ -155,18 +142,14 @@
155142
"semi": [2, "never"],
156143
"semi-spacing": 0,
157144
"sort-vars": 0,
158-
"space-after-function-name": 0,
159145
"space-after-keywords": [2, "always"],
160146
"space-before-blocks": [2, "always"],
161147
"space-before-function-paren": [2, "always"],
162-
"space-before-function-parentheses": 0,
163-
"space-in-brackets": 0,
164148
"space-in-parens": [2, "never"],
165149
"space-infix-ops": 2,
166150
"space-return-throw-case": 2,
167151
"space-unary-ops": [2, { "words": true, "nonwords": false }],
168152
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"] }],
169-
"spaced-line-comment": 0,
170153
"strict": 0,
171154
"use-isnan": 2,
172155
"valid-jsdoc": 0,

lib/loader.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,25 @@ module.exports = function (content) {
9494
} else {
9595
// unknown lang, assume a loader for it is used
9696
switch (type) {
97-
case 'template':
98-
return 'vue-html!' + rewriter + 'template-html?raw&engine=' + lang + '!'
99-
case 'style':
100-
return 'style!css!' + rewriter + lang + '!'
101-
case 'script':
102-
return lang + '!'
97+
case 'template':
98+
return 'vue-html!' + rewriter + 'template-html?raw&engine=' + lang + '!'
99+
case 'style':
100+
return 'style!css!' + rewriter + lang + '!'
101+
case 'script':
102+
return lang + '!'
103103
}
104104
}
105105
}
106106

107107
function getRewriter (type, scoped) {
108108
var meta = '?id=' + moduleId + '&file=' + fileName
109109
switch (type) {
110-
case 'template':
111-
return scoped ? (rewriters.template + meta + '!') : ''
112-
case 'style':
113-
return rewriters.style + meta + (scoped ? '&scoped=true!' : '!')
114-
default:
115-
return ''
110+
case 'template':
111+
return scoped ? (rewriters.template + meta + '!') : ''
112+
case 'style':
113+
return rewriters.style + meta + (scoped ? '&scoped=true!' : '!')
114+
default:
115+
return ''
116116
}
117117
}
118118

lib/parser.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ module.exports = function (content) {
7373

7474
var result
7575
if (type === 'script') {
76-
result =
77-
commentScript(content.slice(0, start)) +
78-
content.slice(start, end) +
79-
commentScript(content.slice(end))
76+
// Pad the source code with extra blank lines
77+
// so the source-mapped line numbers corresponds to
78+
// the original *.vue file.
79+
result = padLines(content.slice(0, start)) + content.slice(start, end)
8080
} else {
8181
result = content.slice(start, end).trim()
8282
}
@@ -91,16 +91,10 @@ module.exports = function (content) {
9191
cb(null, 'module.exports = ' + JSON.stringify(output))
9292
}
9393

94-
function commentScript (content) {
94+
function padLines (content) {
9595
return content
9696
.split(/\n\r|\n|\r/g)
97-
.map(function (line) {
98-
if (line.trim() === '') {
99-
return line
100-
} else {
101-
return '// ' + line
102-
}
103-
})
97+
.map(function (line) { return '' })
10498
.join('\n')
10599
}
106100

0 commit comments

Comments
 (0)