Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
netvs-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scc-net
netvs
netvs-core
Commits
d19b0145
Commit
d19b0145
authored
3 months ago
by
!! Julian Keck (old Account; do not use) !!
Browse files
Options
Downloads
Patches
Plain Diff
ADD: eslint-rule to enforce setup-attribute in script-tags
parent
4e1669a7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#394705
passed with warnings
3 months ago
Stage: build
Stage: lint
Stage: deploy
Stage: e2e
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eslint.config.js
+15
-1
15 additions, 1 deletion
eslint.config.js
eslint_rules/enforce-script-setup-tag.js
+43
-0
43 additions, 0 deletions
eslint_rules/enforce-script-setup-tag.js
with
58 additions
and
1 deletion
eslint.config.js
+
15
−
1
View file @
d19b0145
import
antfu
from
'
@antfu/eslint-config
'
import
enforceScriptSetupTag
from
'
./eslint_rules/enforce-script-setup-tag.js
'
export
default
antfu
()
export
default
antfu
().
append
([
{
rules
:
{
'
nextvs/enforce-script-setup-tag
'
:
'
error
'
,
},
plugins
:
{
nextvs
:
{
rules
:
{
'
enforce-script-setup-tag
'
:
enforceScriptSetupTag
,
}
}
}
}
])
This diff is collapsed.
Click to expand it.
eslint_rules/enforce-script-setup-tag.js
0 → 100644
+
43
−
0
View file @
d19b0145
export
default
{
meta
:
{
type
:
'
problem
'
,
docs
:
{
description
:
'
Enforce <script> to have the
\'
setup
\'
attribute
'
,
category
:
'
Best Practices
'
,
recommended
:
false
,
},
fixable
:
'
code
'
,
schema
:
[],
},
create
(
context
)
{
return
{
Program
(
_node
)
{
const
sourceCode
=
context
.
getSourceCode
()
const
tokens
=
sourceCode
.
ast
.
tokens
const
code
=
sourceCode
.
getText
()
const
file_name
=
context
.
getFilename
()
if
(
!
file_name
.
endsWith
(
'
.vue
'
))
{
return
}
if
(
file_name
.
includes
(
'
node_modules
'
))
{
return
}
tokens
.
forEach
((
token
)
=>
{
if
(
token
.
type
===
'
Punctuator
'
&&
token
.
value
===
'
<script>
'
)
{
const
script_tag
=
code
.
slice
(
token
.
range
[
0
],
token
.
range
[
1
])
if
(
!
/
\b
setup
\b
/
.
test
(
script_tag
))
{
context
.
report
({
node
:
token
,
message
:
'
<script> tags must have the
\'
setup
\'
attribute.
'
,
fix
(
fixer
)
{
return
fixer
.
replaceTextRange
([
token
.
range
[
0
],
token
.
range
[
0
]
+
'
<script
'
.
length
],
'
<script setup
'
)
},
})
}
}
})
},
}
},
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment