|
4 | 4 | 'use strict' |
5 | 5 |
|
6 | 6 | const rule = require('../../../lib/rules/component-name-in-template-casing') |
7 | | -const semver = require('semver') |
8 | 7 | const RuleTester = require('../../eslint-compat').RuleTester |
9 | 8 |
|
10 | 9 | const tester = new RuleTester({ |
@@ -218,42 +217,36 @@ tester.run('component-name-in-template-casing', rule, { |
218 | 217 | }, |
219 | 218 |
|
220 | 219 | // type-only imports |
221 | | - ...(semver.gte( |
222 | | - require('@typescript-eslint/parser/package.json').version, |
223 | | - '5.0.0' |
224 | | - ) |
225 | | - ? [ |
226 | | - { |
227 | | - code: ` |
228 | | - <script setup lang="ts"> |
229 | | - import type Foo from './Foo.vue' |
230 | | - import type { HelloWorld1 } from './components/HelloWorld' |
231 | | - import { type HelloWorld2 } from './components/HelloWorld2' |
232 | | - import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
233 | | - import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
234 | | - import { type default as HelloWorld5 } from './components/HelloWorld5'; |
235 | | - import { type Component } from 'vue'; |
236 | | - </script> |
237 | 220 |
|
238 | | - <template> |
239 | | - <foo /> |
240 | | - <hello-world1 /> |
241 | | - <hello-world2 /> |
242 | | - <hello-world3 /> |
243 | | - <hello-world4 /> |
244 | | - <hello-world5 /> |
245 | | - <component /> |
246 | | - </template> |
247 | | - `, |
248 | | - options: ['PascalCase', { registeredComponentsOnly: true }], |
249 | | - languageOptions: { |
250 | | - parserOptions: { |
251 | | - parser: require.resolve('@typescript-eslint/parser') |
252 | | - } |
253 | | - } |
254 | | - } |
255 | | - ] |
256 | | - : []) |
| 221 | + { |
| 222 | + code: ` |
| 223 | + <script setup lang="ts"> |
| 224 | + import type Foo from './Foo.vue' |
| 225 | + import type { HelloWorld1 } from './components/HelloWorld' |
| 226 | + import { type HelloWorld2 } from './components/HelloWorld2' |
| 227 | + import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
| 228 | + import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
| 229 | + import { type default as HelloWorld5 } from './components/HelloWorld5'; |
| 230 | + import { type Component } from 'vue'; |
| 231 | + </script> |
| 232 | +
|
| 233 | + <template> |
| 234 | + <foo /> |
| 235 | + <hello-world1 /> |
| 236 | + <hello-world2 /> |
| 237 | + <hello-world3 /> |
| 238 | + <hello-world4 /> |
| 239 | + <hello-world5 /> |
| 240 | + <component /> |
| 241 | + </template> |
| 242 | + `, |
| 243 | + options: ['PascalCase', { registeredComponentsOnly: true }], |
| 244 | + languageOptions: { |
| 245 | + parserOptions: { |
| 246 | + parser: require.resolve('@typescript-eslint/parser') |
| 247 | + } |
| 248 | + } |
| 249 | + } |
257 | 250 | ], |
258 | 251 | invalid: [ |
259 | 252 | { |
@@ -1305,106 +1298,99 @@ tester.run('component-name-in-template-casing', rule, { |
1305 | 1298 | ] |
1306 | 1299 | }, |
1307 | 1300 | // type-only imports |
1308 | | - ...(semver.gte( |
1309 | | - require('@typescript-eslint/parser/package.json').version, |
1310 | | - '5.0.0' |
1311 | | - ) |
1312 | | - ? [ |
1313 | | - { |
1314 | | - code: ` |
1315 | | - <script setup lang="ts"> |
1316 | | - import type Foo from './Foo.vue' |
1317 | | - import type { HelloWorld1 } from './components/HelloWorld' |
1318 | | - import { type HelloWorld2 } from './components/HelloWorld2' |
1319 | | - import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
1320 | | - import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
1321 | | - import { type default as HelloWorld5 } from './components/HelloWorld5'; |
1322 | | - import { type Component } from 'vue'; |
1323 | | - </script> |
| 1301 | + { |
| 1302 | + code: ` |
| 1303 | + <script setup lang="ts"> |
| 1304 | + import type Foo from './Foo.vue' |
| 1305 | + import type { HelloWorld1 } from './components/HelloWorld' |
| 1306 | + import { type HelloWorld2 } from './components/HelloWorld2' |
| 1307 | + import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
| 1308 | + import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
| 1309 | + import { type default as HelloWorld5 } from './components/HelloWorld5'; |
| 1310 | + import { type Component } from 'vue'; |
| 1311 | + </script> |
1324 | 1312 |
|
1325 | | - <template> |
1326 | | - <foo /> |
1327 | | - <hello-world1 /> |
1328 | | - <hello-world2 /> |
1329 | | - <hello-world3 /> |
1330 | | - <hello-world4 /> |
1331 | | - <hello-world5 /> |
1332 | | - <component /> |
1333 | | - </template> |
1334 | | - `, |
1335 | | - options: ['PascalCase', { registeredComponentsOnly: false }], |
1336 | | - languageOptions: { |
1337 | | - parserOptions: { |
1338 | | - parser: require.resolve('@typescript-eslint/parser') |
1339 | | - } |
1340 | | - }, |
1341 | | - output: ` |
1342 | | - <script setup lang="ts"> |
1343 | | - import type Foo from './Foo.vue' |
1344 | | - import type { HelloWorld1 } from './components/HelloWorld' |
1345 | | - import { type HelloWorld2 } from './components/HelloWorld2' |
1346 | | - import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
1347 | | - import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
1348 | | - import { type default as HelloWorld5 } from './components/HelloWorld5'; |
1349 | | - import { type Component } from 'vue'; |
1350 | | - </script> |
| 1313 | + <template> |
| 1314 | + <foo /> |
| 1315 | + <hello-world1 /> |
| 1316 | + <hello-world2 /> |
| 1317 | + <hello-world3 /> |
| 1318 | + <hello-world4 /> |
| 1319 | + <hello-world5 /> |
| 1320 | + <component /> |
| 1321 | + </template> |
| 1322 | + `, |
| 1323 | + output: ` |
| 1324 | + <script setup lang="ts"> |
| 1325 | + import type Foo from './Foo.vue' |
| 1326 | + import type { HelloWorld1 } from './components/HelloWorld' |
| 1327 | + import { type HelloWorld2 } from './components/HelloWorld2' |
| 1328 | + import type { HelloWorld as HelloWorld3 } from './components/HelloWorld3' |
| 1329 | + import { type HelloWorld as HelloWorld4 } from './components/HelloWorld4'; |
| 1330 | + import { type default as HelloWorld5 } from './components/HelloWorld5'; |
| 1331 | + import { type Component } from 'vue'; |
| 1332 | + </script> |
1351 | 1333 |
|
1352 | | - <template> |
1353 | | - <Foo /> |
1354 | | - <HelloWorld1 /> |
1355 | | - <HelloWorld2 /> |
1356 | | - <HelloWorld3 /> |
1357 | | - <HelloWorld4 /> |
1358 | | - <HelloWorld5 /> |
1359 | | - <component /> |
1360 | | - </template> |
1361 | | - `, |
1362 | | - errors: [ |
1363 | | - { |
1364 | | - message: 'Component name "foo" is not PascalCase.', |
1365 | | - line: 13, |
1366 | | - column: 17, |
1367 | | - endLine: 13, |
1368 | | - endColumn: 21 |
1369 | | - }, |
1370 | | - { |
1371 | | - message: 'Component name "hello-world1" is not PascalCase.', |
1372 | | - line: 14, |
1373 | | - column: 17, |
1374 | | - endLine: 14, |
1375 | | - endColumn: 30 |
1376 | | - }, |
1377 | | - { |
1378 | | - message: 'Component name "hello-world2" is not PascalCase.', |
1379 | | - line: 15, |
1380 | | - column: 17, |
1381 | | - endLine: 15, |
1382 | | - endColumn: 30 |
1383 | | - }, |
1384 | | - { |
1385 | | - message: 'Component name "hello-world3" is not PascalCase.', |
1386 | | - line: 16, |
1387 | | - column: 17, |
1388 | | - endLine: 16, |
1389 | | - endColumn: 30 |
1390 | | - }, |
1391 | | - { |
1392 | | - message: 'Component name "hello-world4" is not PascalCase.', |
1393 | | - line: 17, |
1394 | | - column: 17, |
1395 | | - endLine: 17, |
1396 | | - endColumn: 30 |
1397 | | - }, |
1398 | | - { |
1399 | | - message: 'Component name "hello-world5" is not PascalCase.', |
1400 | | - line: 18, |
1401 | | - column: 17, |
1402 | | - endLine: 18, |
1403 | | - endColumn: 30 |
1404 | | - } |
1405 | | - ] |
1406 | | - } |
1407 | | - ] |
1408 | | - : []) |
| 1334 | + <template> |
| 1335 | + <Foo /> |
| 1336 | + <HelloWorld1 /> |
| 1337 | + <HelloWorld2 /> |
| 1338 | + <HelloWorld3 /> |
| 1339 | + <HelloWorld4 /> |
| 1340 | + <HelloWorld5 /> |
| 1341 | + <component /> |
| 1342 | + </template> |
| 1343 | + `, |
| 1344 | + options: ['PascalCase', { registeredComponentsOnly: false }], |
| 1345 | + languageOptions: { |
| 1346 | + parserOptions: { |
| 1347 | + parser: require.resolve('@typescript-eslint/parser') |
| 1348 | + } |
| 1349 | + }, |
| 1350 | + errors: [ |
| 1351 | + { |
| 1352 | + message: 'Component name "foo" is not PascalCase.', |
| 1353 | + line: 13, |
| 1354 | + column: 11, |
| 1355 | + endLine: 13, |
| 1356 | + endColumn: 15 |
| 1357 | + }, |
| 1358 | + { |
| 1359 | + message: 'Component name "hello-world1" is not PascalCase.', |
| 1360 | + line: 14, |
| 1361 | + column: 11, |
| 1362 | + endLine: 14, |
| 1363 | + endColumn: 24 |
| 1364 | + }, |
| 1365 | + { |
| 1366 | + message: 'Component name "hello-world2" is not PascalCase.', |
| 1367 | + line: 15, |
| 1368 | + column: 11, |
| 1369 | + endLine: 15, |
| 1370 | + endColumn: 24 |
| 1371 | + }, |
| 1372 | + { |
| 1373 | + message: 'Component name "hello-world3" is not PascalCase.', |
| 1374 | + line: 16, |
| 1375 | + column: 11, |
| 1376 | + endLine: 16, |
| 1377 | + endColumn: 24 |
| 1378 | + }, |
| 1379 | + { |
| 1380 | + message: 'Component name "hello-world4" is not PascalCase.', |
| 1381 | + line: 17, |
| 1382 | + column: 11, |
| 1383 | + endLine: 17, |
| 1384 | + endColumn: 24 |
| 1385 | + }, |
| 1386 | + { |
| 1387 | + message: 'Component name "hello-world5" is not PascalCase.', |
| 1388 | + line: 18, |
| 1389 | + column: 11, |
| 1390 | + endLine: 18, |
| 1391 | + endColumn: 24 |
| 1392 | + } |
| 1393 | + ] |
| 1394 | + } |
1409 | 1395 | ] |
1410 | 1396 | }) |
0 commit comments