File tree Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Expand file tree Collapse file tree 2 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 12
12
* @typedef { import("@html-eslint/types").TemplateLiteral } TemplateLiteral
13
13
* @typedef { import("@html-eslint/types").OpenTemplate } OpenTemplate
14
14
* @typedef { import("@html-eslint/types").CloseTemplate } CloseTemplate
15
+ * @typedef { import("@html-eslint/types").ScriptTag } ScriptTag
16
+ * @typedef { import("@html-eslint/types").StyleTag } StyleTag
15
17
*
16
18
* @typedef {AnyNode | Line } AnyNodeOrLine
17
19
* @typedef {Object } IndentType
@@ -40,6 +42,8 @@ const {
40
42
isLine,
41
43
isTag,
42
44
hasTemplate,
45
+ isScript,
46
+ isStyle,
43
47
} = require ( "../utils/node" ) ;
44
48
const {
45
49
shouldCheckTaggedTemplateExpression,
@@ -121,7 +125,7 @@ module.exports = {
121
125
const { indentType, indentSize, indentChar } = getIndentOptionInfo ( context ) ;
122
126
123
127
/**
124
- * @param {Tag } node
128
+ * @param {Tag | ScriptTag | StyleTag } node
125
129
* @return {number }
126
130
*/
127
131
function getTagIncreasingLevel ( node ) {
@@ -150,7 +154,7 @@ module.exports = {
150
154
if ( isLine ( node ) ) {
151
155
return 1 ;
152
156
}
153
- if ( isTag ( node ) ) {
157
+ if ( isTag ( node ) || isScript ( node ) || isStyle ( node ) ) {
154
158
return getTagIncreasingLevel ( node ) ;
155
159
}
156
160
const type = node . type ;
Original file line number Diff line number Diff line change @@ -391,6 +391,44 @@ function createTests() {
391
391
} ,
392
392
{
393
393
code : `
394
+ <!DOCTYPE html>
395
+ <html>
396
+ <body>
397
+ </body>
398
+ <script src=""></script>
399
+ </html>
400
+ ` ,
401
+ options : [
402
+ 2 ,
403
+ {
404
+ tagChildrenIndent : {
405
+ html : 0 ,
406
+ body : 0 ,
407
+ } ,
408
+ } ,
409
+ ] ,
410
+ } ,
411
+ {
412
+ code : `
413
+ <!DOCTYPE html>
414
+ <html>
415
+ <body>
416
+ </body>
417
+ <style></style>
418
+ </html>
419
+ ` ,
420
+ options : [
421
+ 2 ,
422
+ {
423
+ tagChildrenIndent : {
424
+ html : 0 ,
425
+ body : 0 ,
426
+ } ,
427
+ } ,
428
+ ] ,
429
+ } ,
430
+ {
431
+ code : `
394
432
<style>
395
433
</style>
396
434
<script>
You can’t perform that action at this time.
0 commit comments