File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -98,13 +98,16 @@ function extractFirstScript(originalText) {
98
98
parser . stop ( )
99
99
}
100
100
} )
101
- parser . on ( "text" , ( scriptText , location ) => {
101
+ parser . on ( "text" , ( _ , location ) => {
102
102
if ( startToken != null ) {
103
+ const start = location . startOffset
103
104
const countLines = location . line - 1
104
105
const lineTerminators = "\n" . repeat ( countLines )
105
- const spaces = " " . repeat ( location . startOffset - countLines )
106
+ const spaces = " " . repeat ( start - countLines )
107
+ const scriptText = originalText . slice ( start , location . endOffset )
108
+
106
109
text = `${ spaces } ${ lineTerminators } ${ scriptText } `
107
- offset = location . startOffset
110
+ offset = start
108
111
}
109
112
} )
110
113
parser . end ( originalText )
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <p >{{ greeting }} World!</p >
3
+ </template >
4
+
5
+ <script >
6
+ /* eslint linebreak-style: [error, windows] */
7
+
8
+ module .exports = {
9
+ data () {
10
+ return {greeting: " Hello" }
11
+ },
12
+ }
13
+ </script >
14
+
15
+ <style scoped>
16
+ p {
17
+ font-size : 2em ;
18
+ text-align : center ;
19
+ }
20
+ </style >
Original file line number Diff line number Diff line change @@ -175,3 +175,26 @@ describe("About fixtures/lines-around-directive.vue", () => {
175
175
assert ( actual === expected )
176
176
} )
177
177
} )
178
+
179
+ describe ( "About fixtures/crlf.vue" , ( ) => {
180
+ beforeEach ( ( ) => {
181
+ fs . copySync ( ORIGINAL_FIXTURE_DIR , FIXTURE_DIR )
182
+ } )
183
+ afterEach ( ( ) => {
184
+ fs . removeSync ( FIXTURE_DIR )
185
+ } )
186
+
187
+ it ( "should notify no 'indent' error" , ( ) => {
188
+ const cli = new CLIEngine ( {
189
+ cwd : FIXTURE_DIR ,
190
+ envs : [ "es6" , "node" ] ,
191
+ parser : PARSER_PATH ,
192
+ rules : { indent : "error" } ,
193
+ useEslintrc : false ,
194
+ } )
195
+ const report = cli . executeOnFiles ( [ "crlf.vue" ] )
196
+ const messages = report . results [ 0 ] . messages
197
+
198
+ assert ( messages . length === 0 )
199
+ } )
200
+ } )
You can’t perform that action at this time.
0 commit comments