Skip to content

Commit 7717a53

Browse files
committedJul 18, 2022
feat: rename parse-tags to javascript-tag-names
1 parent 594b3a2 commit 7717a53

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed
 

‎README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [`html/xml-extensions`](#htmlxml-extensions)
1616
- [`html/indent`](#htmlindent)
1717
- [`html/report-bad-indent`](#htmlreport-bad-indent)
18-
- [`html/parse-tags`](#htmlparse-tags)
18+
- [`html/javascript-tag-names`](#htmljavascript-tag-names)
1919
- [`html/javascript-mime-types`](#htmljavascript-mime-types)
2020
- [Troubleshooting](#troubleshooting)
2121
- [No file linted when running `eslint` on a directory](#no-file-linted-when-running-eslint-on-a-directory)
@@ -162,7 +162,7 @@ display errors. Example:
162162
}
163163
```
164164

165-
### `html/parse-tags`
165+
### `html/javascript-tag-names`
166166

167167
By default, the code between `<script>` tags is considered as JavaScript. You can customize which
168168
tags should be considered JavaScript by providing one or multiple tag names.
@@ -173,7 +173,7 @@ Example:
173173
{
174174
"plugins": [ "html" ],
175175
"settings": {
176-
"html/parse-tags": ["script", "customscript"],
176+
"html/javascript-tag-names": ["script", "customscript"],
177177
}
178178
}
179179
```

‎src/__tests__/extract.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function test(params) {
2525
dedent(params.input),
2626
params.indent,
2727
params.xmlMode,
28-
params.parseTags || ["script"],
28+
params.javaScriptTagNames || ["script"],
2929
params.isJavaScriptMIMEType
3030
)
3131
expect(infos.code.map((code) => code.toString())).toMatchSnapshot()
@@ -331,6 +331,6 @@ it("extract multiple tags types", () => {
331331
var bar = 1;
332332
</customscript>
333333
`,
334-
parseTags: ["script", "customscript"],
334+
javaScriptTagNames: ["script", "customscript"],
335335
})
336336
})

‎src/extract.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function iterateScripts(code, options, onChunk) {
88

99
const xmlMode = options.xmlMode
1010
const isJavaScriptMIMEType = options.isJavaScriptMIMEType || (() => true)
11-
const parseTags = options.parseTags || ['script']
11+
const javaScriptTagNames = options.javaScriptTagNames || ['script']
1212
let index = 0
1313
let inScript = false
1414
let cdata = []
@@ -24,7 +24,7 @@ function iterateScripts(code, options, onChunk) {
2424
{
2525
onopentag(name, attrs) {
2626
// Test if current tag is a valid <script> tag.
27-
if (!parseTags.includes(name)) {
27+
if (!javaScriptTagNames.includes(name)) {
2828
return
2929
}
3030

@@ -54,7 +54,7 @@ function iterateScripts(code, options, onChunk) {
5454
},
5555

5656
onclosetag(name) {
57-
if (!parseTags.includes(name) || !inScript) {
57+
if (!javaScriptTagNames.includes(name) || !inScript) {
5858
return
5959
}
6060

@@ -180,13 +180,13 @@ function* dedent(indent, slice) {
180180
}
181181
}
182182

183-
function extract(code, indentDescriptor, xmlMode, parseTags, isJavaScriptMIMEType) {
183+
function extract(code, indentDescriptor, xmlMode, javaScriptTagNames, isJavaScriptMIMEType) {
184184
const badIndentationLines = []
185185
const codeParts = []
186186
let lineNumber = 1
187187
let previousHTML = ""
188188

189-
iterateScripts(code, { xmlMode, parseTags, isJavaScriptMIMEType }, (chunk) => {
189+
iterateScripts(code, { xmlMode, javaScriptTagNames, isJavaScriptMIMEType }, (chunk) => {
190190
const slice = code.slice(chunk.start, chunk.end)
191191
if (chunk.type === "html") {
192192
const match = slice.match(/\r\n|\n|\r/g)

‎src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function patch(Linter) {
146146
textOrSourceCode,
147147
pluginSettings.indent,
148148
mode === "xml",
149-
pluginSettings.parseTags,
149+
pluginSettings.javaScriptTagNames,
150150
pluginSettings.isJavaScriptMIMEType
151151
)
152152

‎src/settings.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ function getSettings(settings) {
5050
getSetting(settings, "xml-extensions") ||
5151
filterOut(defaultXMLExtensions, getSetting(settings, "html-extensions"))
5252

53-
const parseTags =
54-
getSetting(settings, "parse-tags") || ["script"]
53+
const javaScriptTagNames = getSetting(settings, "javascript-tag-names") || [
54+
"script",
55+
]
5556

5657
let reportBadIndent
5758
switch (getSetting(settings, "report-bad-indent")) {
@@ -105,7 +106,7 @@ function getSettings(settings) {
105106
return {
106107
htmlExtensions,
107108
xmlExtensions,
108-
parseTags,
109+
javaScriptTagNames,
109110
indent,
110111
reportBadIndent,
111112
isJavaScriptMIMEType,

0 commit comments

Comments
 (0)
Please sign in to comment.