Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install Packages
run: npm install --legacy-peer-deps
- name: Lint
run: npm run lint

test:
name: Test
strategy:
matrix:
node: [16, 17]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js v${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Packages
run: npm install --legacy-peer-deps
- name: Test
run: npm test
8 changes: 4 additions & 4 deletions lib/rules/component-tags-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
],
messages: {
unexpected:
'<{{elementName}}{{elementAttributes}}> should be above <{{firstUnorderedName}}{{firstUnorderedAttributes}}> on line {{line}}.'
"'<{{elementName}}{{elementAttributes}}>' should be above '<{{firstUnorderedName}}{{firstUnorderedAttributes}}>' on line {{line}}."
}
},
/**
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = {

return `${attribute.key.name}${
attribute.value && attribute.value.value
? '=' + attribute.value.value
? `=${attribute.value.value}`
: ''
}`
})
Expand Down Expand Up @@ -177,11 +177,11 @@ module.exports = {
data: {
elementName: element.name,
elementAttributes: elementAttributes
? ' ' + elementAttributes
? ` ${elementAttributes}`
: '',
firstUnorderedName: firstUnordered.name,
firstUnorderedAttributes: firstUnorderedttributes
? ' ' + firstUnorderedttributes
? ` ${firstUnorderedttributes}`
: '',
line: firstUnordered.loc.start.line
},
Expand Down
51 changes: 28 additions & 23 deletions tests/lib/rules/component-tags-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,18 @@ tester.run('component-tags-order', rule, {
{
code: '<script setup></script><script></script><template></template><style></style>',
output: null,
options: [{ order: ['script[setup]', 'script:not([setup])', 'template', 'style'] }]
options: [
{ order: ['script[setup]', 'script:not([setup])', 'template', 'style'] }
]
},
{
code: '<template></template><script setup></script><script></script><style></style>',
output: null,
options: [{ order: [['script[setup]', 'script:not([setup])', 'template'], 'style'] }]
options: [
{
order: [['script[setup]', 'script:not([setup])', 'template'], 'style']
}
]
},
{
code: '<script></script><script setup></script><template></template><style></style>',
Expand All @@ -122,7 +128,7 @@ tester.run('component-tags-order', rule, {
{
code: '<template></template><script></script><script setup></script><style></style>',
output: null,
options: [{ order: [['script, 'template'], 'style'] }]
options: [{ order: [['script', 'template'], 'style'] }]
},
{
code: '<script></script><script setup></script><template></template><style></style>',
Expand Down Expand Up @@ -155,7 +161,6 @@ tester.run('component-tags-order', rule, {
}
]
},
,
{
code: '<template></template><script></script><script setup></script><style scoped></style><style></style><i18n lang="en"></i18n><i18n lang="ja"></i18n>',
output: null,
Expand Down Expand Up @@ -200,12 +205,12 @@ tester.run('component-tags-order', rule, {
code: '<style></style><template></template><script></script>',
errors: [
{
message: '<template> should be above <style> on line 1.',
message: "'<template>' should be above '<style>' on line 1.",
line: 1,
column: 16
},
{
message: '<script> should be above <style> on line 1.',
message: "'<script>' should be above '<style>' on line 1.",
line: 1,
column: 37
}
Expand All @@ -217,7 +222,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['script', 'template', 'style'] }],
errors: [
{
message: '<script> should be above <template> on line 1.',
message: "'<script>' should be above '<template>' on line 1.",
line: 1,
column: 22
}
Expand All @@ -233,7 +238,7 @@ tester.run('component-tags-order', rule, {
<script></script>`,
errors: [
{
message: '<script> should be above <style> on line 4.',
message: "'<script>' should be above '<style>' on line 4.",
line: 6
}
],
Expand All @@ -254,7 +259,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['script', 'template', 'style'] }],
errors: [
{
message: '<script> should be above <template> on line 2.',
message: "'<script>' should be above '<template>' on line 2.",
line: 3
}
],
Expand All @@ -274,7 +279,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['template', 'script', 'style'] }],
errors: [
{
message: '<template> should be above <script> on line 2.',
message: "'<template>' should be above '<script>' on line 2.",
line: 3
}
],
Expand All @@ -295,7 +300,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['docs', 'template', 'script', 'style'] }],
errors: [
{
message: '<docs> should be above <template> on line 2.',
message: "'<docs>' should be above '<template>' on line 2.",
line: 3
}
],
Expand All @@ -317,7 +322,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['script', 'template', 'style'] }],
errors: [
{
message: '<script> should be above <template> on line 2.',
message: "'<script>' should be above '<template>' on line 2.",
line: 4
}
],
Expand All @@ -340,7 +345,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['script', 'template', 'style'] }],
errors: [
{
message: '<script> should be above <template> on line 2.',
message: "'<script>' should be above '<template>' on line 2.",
line: 5
}
],
Expand All @@ -361,7 +366,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['template', 'script'] }],
errors: [
{
message: '<template> should be above <script> on line 2.',
message: "'<template>' should be above '<script>' on line 2.",
line: 3
}
],
Expand All @@ -376,11 +381,11 @@ tester.run('component-tags-order', rule, {
`,
errors: [
{
message: '<template> should be above <style> on line 2.',
message: "'<template>' should be above '<style>' on line 2.",
line: 3
},
{
message: '<script> should be above <style> on line 2.',
message: "'<script>' should be above '<style>' on line 2.",
line: 4
}
],
Expand All @@ -400,11 +405,11 @@ tester.run('component-tags-order', rule, {
`,
errors: [
{
message: '<template> should be above <style> on line 2.',
message: "'<template>' should be above '<style>' on line 2.",
line: 4
},
{
message: '<script> should be above <style> on line 2.',
message: "'<script>' should be above '<style>' on line 2.",
line: 5
}
],
Expand All @@ -424,7 +429,7 @@ tester.run('component-tags-order', rule, {
`,
errors: [
{
message: '<script> should be above <style> on line 2.',
message: "'<script>' should be above '<style>' on line 2.",
line: 3
}
],
Expand All @@ -437,7 +442,7 @@ tester.run('component-tags-order', rule, {
errors: [
{
message:
'<i18n locale=en> should be above <i18n locale=ja> on line 1.',
"'<i18n locale=en>' should be above '<i18n locale=ja>' on line 1.",
line: 1
}
]
Expand All @@ -448,7 +453,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['style:not([scoped])', 'style[scoped]'] }],
errors: [
{
message: '<style> should be above <style scoped> on line 1.',
message: "'<style>' should be above '<style scoped>' on line 1.",
line: 1
}
]
Expand All @@ -459,7 +464,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['style[scoped]', 'style:not([scoped])'] }],
errors: [
{
message: '<style scoped> should be above <style> on line 1.',
message: "'<style scoped>' should be above '<style>' on line 1.",
line: 1
}
]
Expand All @@ -470,7 +475,7 @@ tester.run('component-tags-order', rule, {
options: [{ order: ['script:not([scoped])', 'style:not([scoped])'] }],
errors: [
{
message: '<script> should be above <style> on line 1.',
message: "'<script>' should be above '<style>' on line 1.",
line: 1
}
]
Expand Down