Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf60ceb4

Browse files
committed
more
1 parente00d49a commitf60ceb4

11 files changed

+373
-463
lines changed

‎tests/lib/rules/no-boolean-default.js‎

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
'use strict'
66

7-
constsemver=require('semver')
87
construle=require('../../../lib/rules/no-boolean-default')
98

109
constRuleTester=require('../../eslint-compat').RuleTester
@@ -484,15 +483,9 @@ ruleTester.run('no-boolean-default', rule, {
484483
}
485484
]
486485
},
487-
...(semver.lt(
488-
require('@typescript-eslint/parser/package.json').version,
489-
'4.0.0'
490-
)
491-
?[]
492-
:[
493-
{
494-
filename:'test.vue',
495-
code:`
486+
{
487+
filename:'test.vue',
488+
code:`
496489
<script setup lang="ts">
497490
interface Props {
498491
foo: boolean
@@ -502,26 +495,26 @@ ruleTester.run('no-boolean-default', rule, {
502495
})
503496
</script>
504497
`,
505-
languageOptions:{
506-
parser:require('vue-eslint-parser'),
507-
parserOptions:{
508-
parser:require.resolve('@typescript-eslint/parser')
509-
}
510-
},
511-
errors:[
512-
{
513-
message:
514-
'Boolean prop should not set a default (Vue defaults it to false).',
515-
line:7,
516-
column:14,
517-
endLine:7,
518-
endColumn:19
519-
}
520-
]
521-
},
522-
{
523-
filename:'test.vue',
524-
code:`
498+
languageOptions:{
499+
parser:require('vue-eslint-parser'),
500+
parserOptions:{
501+
parser:require.resolve('@typescript-eslint/parser')
502+
}
503+
},
504+
errors:[
505+
{
506+
message:
507+
'Boolean prop should not set a default (Vue defaults it to false).',
508+
line:7,
509+
column:14,
510+
endLine:7,
511+
endColumn:19
512+
}
513+
]
514+
},
515+
{
516+
filename:'test.vue',
517+
code:`
525518
<script setup lang="ts">
526519
interface Props {
527520
foo: boolean
@@ -531,24 +524,23 @@ ruleTester.run('no-boolean-default', rule, {
531524
})
532525
</script>
533526
`,
534-
languageOptions:{
535-
parser:require('vue-eslint-parser'),
536-
parserOptions:{
537-
parser:require.resolve('@typescript-eslint/parser')
538-
}
539-
},
540-
options:['default-false'],
541-
errors:[
542-
{
543-
message:'Boolean prop should only be defaulted to false.',
544-
line:7,
545-
column:14,
546-
endLine:7,
547-
endColumn:18
548-
}
549-
]
550-
}
551-
]),
527+
options:['default-false'],
528+
languageOptions:{
529+
parser:require('vue-eslint-parser'),
530+
parserOptions:{
531+
parser:require.resolve('@typescript-eslint/parser')
532+
}
533+
},
534+
errors:[
535+
{
536+
message:'Boolean prop should only be defaulted to false.',
537+
line:7,
538+
column:14,
539+
endLine:7,
540+
endColumn:18
541+
}
542+
]
543+
},
552544
{
553545
filename:'test.vue',
554546
code:`

‎tests/lib/rules/no-export-in-script-setup.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ ruleTester.run('no-export-in-script-setup', rule, {
4242
</script>
4343
`
4444
},
45-
...(semver.gte(
46-
require('@typescript-eslint/parser/package.json').version,
47-
'5.4.0'
48-
)&&
49-
semver.satisfies(require('typescript/package.json').version,'>=4.5.0-0')
45+
...(semver.satisfies(
46+
require('typescript/package.json').version,
47+
'>=4.5.0-0'
48+
)
5049
?[
5150
{
5251
filename:'test.vue',

‎tests/lib/rules/no-implicit-coercion.js‎

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ tester.run('no-implicit-coercion', rule, {
4949
]
5050
},
5151
`<template><div :data-foo="Number(foo)" /></template>`,
52-
...(semver.gte(ESLint.version,'8.28.0')
53-
?[`<template><div :data-foo="foo * 1/4" /></template>`]
54-
:[]),
52+
`<template><div :data-foo="foo * 1/4" /></template>`,
5553
{
5654
filename:'test.vue',
5755
code:`<template><div :data-foo="+foo" /></template>`,
@@ -238,40 +236,35 @@ tester.run('no-implicit-coercion', rule, {
238236
}
239237
]
240238
},
241-
...(semver.gte(ESLint.version,'7.24.0')
242-
?[
243-
{
244-
filename:'test.vue',
245-
code:`<template><div :data-foo="\`\${foo}\`" /></template>`,
246-
output:semver.gte(ESLint.version,'9.0.0')
247-
?null
248-
:`<template><div :data-foo="String(foo)" /></template>`,
249-
options:[
250-
{
251-
disallowTemplateShorthand:true
252-
}
253-
],
254-
errors:[
255-
{
256-
message:getExpectedErrorMessage('String(foo)'),
257-
line:1,
258-
column:27,
259-
endLine:1,
260-
endColumn:35,
261-
suggestions:semver.gte(ESLint.version,'9.0.0')
262-
?[
263-
{
264-
messageId:'useRecommendation',
265-
data:{recommendation:'String(foo)'},
266-
output:
267-
'<template><div :data-foo="String(foo)" /></template>'
268-
}
269-
]
270-
:[]
271-
}
272-
]
273-
}
274-
]
275-
:[])
239+
{
240+
filename:'test.vue',
241+
code:`<template><div :data-foo="\`\${foo}\`" /></template>`,
242+
output:semver.gte(ESLint.version,'9.0.0')
243+
?null
244+
:`<template><div :data-foo="String(foo)" /></template>`,
245+
options:[
246+
{
247+
disallowTemplateShorthand:true
248+
}
249+
],
250+
errors:[
251+
{
252+
message:getExpectedErrorMessage('String(foo)'),
253+
line:1,
254+
column:27,
255+
endLine:1,
256+
endColumn:35,
257+
suggestions:semver.gte(ESLint.version,'9.0.0')
258+
?[
259+
{
260+
messageId:'useRecommendation',
261+
data:{recommendation:'String(foo)'},
262+
output:'<template><div :data-foo="String(foo)" /></template>'
263+
}
264+
]
265+
:[]
266+
}
267+
]
268+
}
276269
]
277270
})

‎tests/lib/rules/no-loss-of-precision.js‎

Lines changed: 60 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
*/
55
'use strict'
66

7-
const{ RuleTester, ESLint}=require('../../eslint-compat')
8-
constsemver=require('semver')
7+
const{ RuleTester}=require('../../eslint-compat')
98
construle=require('../../../lib/rules/no-loss-of-precision')
109

1110
consttester=newRuleTester({
@@ -17,86 +16,66 @@ const tester = new RuleTester({
1716
})
1817
tester.run('no-loss-of-precision',rule,{
1918
valid:[
20-
...(semver.gte(ESLint.version,'7.1.0')
21-
?[
22-
{
23-
filename:'test.vue',
24-
code:`
25-
<template>
26-
{{12345}}
27-
{{123.45}}
28-
</template>
29-
`
30-
},
31-
{
32-
filename:'test.vue',
33-
code:`
34-
<template>
35-
<MyComponent num="12345678901234567890" />
36-
</template>
37-
`
38-
}
39-
]
40-
:[])
19+
{
20+
filename:'test.vue',
21+
code:`
22+
<template>
23+
{{12345}}
24+
{{123.45}}
25+
</template>
26+
`
27+
},
28+
{
29+
filename:'test.vue',
30+
code:`
31+
<template>
32+
<MyComponent num="12345678901234567890" />
33+
</template>
34+
`
35+
}
4136
],
4237
invalid:[
43-
...(semver.gte(ESLint.version,'7.1.0')
44-
?[
45-
{
46-
filename:'test.vue',
47-
code:`
48-
<template>
49-
{{12345678901234567890}}
50-
{{0.12345678901234567890}}
51-
</template>
52-
`,
53-
errors:[
54-
{
55-
message:'This number literal will lose precision at runtime.',
56-
line:3,
57-
column:17,
58-
endLine:3,
59-
endColumn:37
60-
},
61-
{
62-
message:'This number literal will lose precision at runtime.',
63-
line:4,
64-
column:17,
65-
endLine:4,
66-
endColumn:39
67-
}
68-
]
69-
},
70-
{
71-
filename:'test.vue',
72-
code:`
73-
<template>
74-
<MyComponent :num="12345678901234567890" />
75-
</template>
76-
`,
77-
errors:[
78-
{
79-
message:'This number literal will lose precision at runtime.',
80-
line:3,
81-
column:34,
82-
endLine:3,
83-
endColumn:54
84-
}
85-
]
86-
}
87-
]
88-
:[
89-
{
90-
filename:'test.vue',
91-
code:`
92-
<template>
93-
<MyComponent :num="12345678901234567890" />
94-
</template>
95-
`,
96-
errors:[
97-
'Failed to extend ESLint core rule "no-loss-of-precision". You may be able to use this rule by upgrading the version of ESLint. If you cannot upgrade it, turn off this rule.'
98-
]
99-
}
100-
])
38+
{
39+
filename:'test.vue',
40+
code:`
41+
<template>
42+
{{12345678901234567890}}
43+
{{0.12345678901234567890}}
44+
</template>
45+
`,
46+
errors:[
47+
{
48+
message:'This number literal will lose precision at runtime.',
49+
line:3,
50+
column:13,
51+
endLine:3,
52+
endColumn:33
53+
},
54+
{
55+
message:'This number literal will lose precision at runtime.',
56+
line:4,
57+
column:13,
58+
endLine:4,
59+
endColumn:35
60+
}
61+
]
62+
},
63+
{
64+
filename:'test.vue',
65+
code:`
66+
<template>
67+
<MyComponent :num="12345678901234567890" />
68+
</template>
69+
`,
70+
errors:[
71+
{
72+
message:'This number literal will lose precision at runtime.',
73+
line:3,
74+
column:30,
75+
endLine:3,
76+
endColumn:50
77+
}
78+
]
79+
}
10180
]
10281
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp