Skip to content

Commit

Permalink
Update eslint and eslint-plugin-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Feb 18, 2023
1 parent 18b4322 commit 77ac337
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 422 deletions.
19 changes: 11 additions & 8 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,25 @@
},
"homepage": "https://github.com/vuejs/vetur/tree/master/server",
"dependencies": {
"eslint": "^7.32.0",
"eslint-plugin-vue": "^7.19.1",
"eslint": "^8.34.0",
"eslint-plugin-vue": "^9.9.0",
"prettier": "^2.8.4",
"pug-lexer": "^5.0.1",
"tslint": "6.1.3",
"typescript": "^4.9.5"
},
"resolutions": {
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"@types/eslint": "8.21.1",
"@types/estree": "1.0.0"
},
"devDependencies": {
"@prettier/plugin-pug": "^2.4.1",
"@starptech/prettyhtml": "^0.10.0",
"@types/eslint": "7.2.2",
"@types/eslint-scope": "^3.7.1",
"@types/eslint-visitor-keys": "^1.0.0",
"@types/eslint": "8.21.1",
"@types/eslint-scope": "^3.7.4",
"@types/eslint-visitor-keys": "^3.3.0",
"@types/estree": "1.0.0",
"@types/glob": "^8.0.1",
"@types/js-beautify": "1.13.3",
"@types/lodash": "^4.14.176",
Expand All @@ -59,7 +62,7 @@
"nuxt-helper-json": "^1.0.0",
"nyc": "^15.1.0",
"parse-gitignore": "^2.0.0",
"prettier-eslint": "^13.0.0",
"prettier-eslint": "^15.0.1",
"prettier-tslint": "^0.4.2",
"rollup": "^3.17.0",
"sass-formatter": "^0.7.6",
Expand All @@ -73,7 +76,7 @@
"vscode-languageserver-types": "3.16.0",
"vscode-uri": "^3.0.7",
"vscode-web-custom-data": "^0.3.6",
"vue-eslint-parser": "^8.0.1",
"vue-eslint-parser": "^9.1.0",
"vue-onsenui-helper-json": "^1.0.2"
},
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion server/src/modes/plugins/autoImportSfcPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ export function createAutoImportSfcPlugin(

function getNoDuplicateComponentName(childComponents: ChildComponent[], componentCompletionName: string) {
let index = 1;
while (childComponents.some(el => el.name.toLowerCase() === componentCompletionName.toLowerCase())) {
while (
childComponents.some(el =>
[componentCompletionName, componentCompletionName.toLowerCase(), kebabCase(componentCompletionName)].includes(
el.name
)
)
) {
componentCompletionName = `${componentCompletionName}${index++}`;
}
return upperFirst(componentCompletionName);
Expand Down
677 changes: 288 additions & 389 deletions server/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test/interpolation/features/diagnostics/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ describe('Should find template-diagnostics in <template> region', () => {
});

const noErrorTests: string[] = [
'class.vue',
'style.vue',
'class-in-template.vue',
'style-in-template.vue',
'hyphen-attrs.vue',
'template-literal.vue',
'no-implicit-any-parameters.vue',
Expand Down
25 changes: 14 additions & 11 deletions test/lsp/features/completion/autoImport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe('Should import vue component to script in template', () => {
position(3, 5),
[
{
label: 'child',
label: 'child-comp',
documentationStart: 'child component description'
},
{
label: 'child',
documentationStart: '\n```typescript\nimport Child from'
label: 'child-comp',
documentationStart: '\n```typescript\nimport ChildComp from'
}
],
ei => result => {
Expand Down Expand Up @@ -75,10 +75,13 @@ describe('Should import vue component to script in template', () => {
position(2, 5),
[
{
label: 'child',
label: 'child-comp',
additionalTextEdits: [
textEdit(sameLineRange(7, 0, 0), `import Child from '../template/childComponent/Child.vue'${NEW_LINE}`),
textEdit(sameLineRange(7, 16, 16), `${NEW_LINE} components: { Child },`)
textEdit(
sameLineRange(7, 0, 0),
`import ChildComp from '../template/childComponent/ChildComp.vue'${NEW_LINE}`
),
textEdit(sameLineRange(7, 16, 16), `${NEW_LINE} components: { ChildComp },`)
]
}
],
Expand All @@ -92,13 +95,13 @@ describe('Should import vue component to script in template', () => {
position(3, 5),
[
{
label: 'child',
label: 'child-comp',
additionalTextEdits: [
textEdit(
sameLineRange(8, 0, 0),
`import Child1 from '../../diagnostics/noScriptRegion/Child.vue'${NEW_LINE}`
`import ChildComp1 from '../../diagnostics/noScriptRegion/ChildComp.vue'${NEW_LINE}`
),
textEdit(sameLineRange(12, 9, 9), `,${NEW_LINE} Child1`)
textEdit(sameLineRange(12, 13, 13), `,${NEW_LINE} ChildComp1`)
]
}
],
Expand All @@ -118,7 +121,7 @@ describe('Should import vue component to script in template', () => {
label: 'es-lint',
additionalTextEdits: [
textEdit(sameLineRange(8, 0, 0), `import ESLint from '../../diagnostics/ESLint.vue'${NEW_LINE}`),
textEdit(sameLineRange(12, 9, 9), `,${NEW_LINE} ESLint`)
textEdit(sameLineRange(12, 13, 13), `,${NEW_LINE} ESLint`)
]
}
],
Expand All @@ -138,7 +141,7 @@ describe('Should import vue component to script in template', () => {
label: 'kebab-case',
additionalTextEdits: [
textEdit(sameLineRange(9, 0, 0), `import KebabCase from './kebab-case.vue'${NEW_LINE}`),
textEdit(sameLineRange(12, 9, 9), `,${NEW_LINE} KebabCase`)
textEdit(sameLineRange(12, 13, 13), `,${NEW_LINE} KebabCase`)
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions test/lsp/features/diagnostics/noScriptRegion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { testNoDiagnostics } from '../../../diagnosticHelper';
import { getDocUri } from '../../path';

describe('Should find no error when <script> is not present', () => {
const childUri = getDocUri('diagnostics/noScriptRegion/Child.vue');
const parentUri = getDocUri('diagnostics/noScriptRegion/Parent.vue');
const childUri = getDocUri('diagnostics/noScriptRegion/ChildComp.vue');
const parentUri = getDocUri('diagnostics/noScriptRegion/ParentComp.vue');

it('shows no diagnostics error for component without <script> region', async () => {
await testNoDiagnostics(childUri);
Expand Down
2 changes: 1 addition & 1 deletion test/lsp/fixture/completion/autoImport/defineInOneLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</template>

<script>
import Child from '../template/childComponent/Child.vue'
import Child from '../template/childComponent/ChildComp.vue'
export default {
components: {Child},
data () {
Expand Down
6 changes: 3 additions & 3 deletions test/lsp/fixture/completion/autoImport/sameComponentName.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<div>
<child />
<child-comp />
<
</div>
</template>

<script>
import Child from '../template/childComponent/Child.vue'
import ChildComp from '../template/childComponent/ChildComp.vue'
export default {
components: {
Child,
ChildComp,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* child component description
*/
export default {
name: 'child',
name: 'childComp',
props: {
/**
* First attr
Expand All @@ -17,4 +17,4 @@ export default {
}
}
};
</script>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</template>

<script>
import ChildComp from './Child.vue'
import ChildComp from './ChildComp.vue'
export default {
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
</template>

<script>
import Child from './Child.vue'
import ChildComp from './ChildComp.vue'
export default {
components: {
Child
ChildComp
}
}
</script>

0 comments on commit 77ac337

Please sign in to comment.