Skip to content

Commit 4ecd4f8

Browse files
authored
Refresh lock file and format (#273)
* Refresh lock file and format * update
1 parent 6801d72 commit 4ecd4f8

21 files changed

+2407
-2990
lines changed

docs/.vuepress/components/eslint-code-block.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,13 @@ export default {
192192
)
193193
})
194194
// Load linter.
195-
const [
196-
{ Linter },
197-
vueESLintParser,
198-
jsoncESLintParser,
199-
yamlESLintParser
200-
] = await Promise.all([
201-
import('eslint'),
202-
import('espree').then(() => import('vue-eslint-parser')),
203-
import('espree').then(() => import('jsonc-eslint-parser')),
204-
import('yaml-eslint-parser')
205-
])
195+
const [{ Linter }, vueESLintParser, jsoncESLintParser, yamlESLintParser] =
196+
await Promise.all([
197+
import('eslint'),
198+
import('espree').then(() => import('vue-eslint-parser')),
199+
import('espree').then(() => import('jsonc-eslint-parser')),
200+
import('yaml-eslint-parser')
201+
])
206202
207203
const linter = (this.linter = new Linter({ cwd: '/path' }))
208204

docs/.vuepress/config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ module.exports = {
3232
),
3333
esquery$: require.resolve('esquery/dist/esquery'),
3434
fs: require.resolve('./shim/fs'),
35-
[path.resolve(
36-
__dirname,
37-
'../../dist/utils/glob-utils'
38-
)]: require.resolve('./shim/eslint-plugin-vue-i18n/utils/glob-utils')
35+
[path.resolve(__dirname, '../../dist/utils/glob-utils')]:
36+
require.resolve('./shim/eslint-plugin-vue-i18n/utils/glob-utils')
3937
}
4038
}
4139
}

lib/rules/no-duplicate-keys-in-locale.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,8 @@ function create(context: RuleContext): RuleListener {
348348
}
349349

350350
const sourceCode = context.getSourceCode()
351-
const otherLocaleMessages: LocaleMessage[] = localeMessages.localeMessages.filter(
352-
lm => lm !== targetLocaleMessage
353-
)
351+
const otherLocaleMessages: LocaleMessage[] =
352+
localeMessages.localeMessages.filter(lm => lm !== targetLocaleMessage)
354353

355354
if (context.parserServices.isJSON) {
356355
return createVisitorForJson(

lib/rules/no-missing-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function create(context: RuleContext): RuleListener {
1818
},
1919

2020
["VElement:matches([name=i18n], [name=i18n-t]) > VStartTag > VAttribute[key.name='path']," +
21-
"VElement[name=i18n-t] > VStartTag > VAttribute[key.name='keypath']"](
21+
"VElement[name=i18n-t] > VStartTag > VAttribute[key.name='keypath']"](
2222
node: VAST.VAttribute
2323
) {
2424
checkComponent(context, node)

lib/rules/prefer-sfc-lang-attr.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function create(context: RuleContext): RuleListener {
2727
if (langAttrs) {
2828
return fixer.replaceTextRange(langAttrs.range, 'lang="json"')
2929
}
30-
const tokenStore = context.parserServices.getTemplateBodyTokenStore()
30+
const tokenStore =
31+
context.parserServices.getTemplateBodyTokenStore()
3132
const closeToken = tokenStore.getLastToken(i18n.startTag)
3233
const beforeToken = tokenStore.getTokenBefore(closeToken)
3334
return fixer.insertTextBeforeRange(

lib/rules/valid-message-syntax.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ function create(context: RuleContext): RuleListener {
7474
parent: JSONAST.JSONNode
7575
) {
7676
let message
77-
let getReportOffset:
78-
| ((error: CompileError) => number | null)
79-
| null = null
77+
let getReportOffset: ((error: CompileError) => number | null) | null =
78+
null
8079
if (node) {
8180
if (
8281
node.type === 'JSONArrayExpression' ||
@@ -126,9 +125,8 @@ function create(context: RuleContext): RuleListener {
126125
parent: YAMLAST.YAMLNode
127126
) {
128127
let message
129-
let getReportOffset:
130-
| ((error: CompileError) => number | null)
131-
| null = null
128+
let getReportOffset: ((error: CompileError) => number | null) | null =
129+
null
132130
if (node) {
133131
const valueNode = node.type === 'YAMLWithMeta' ? node.value : node
134132
if (

lib/types/eslint.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ export interface SourceCode extends TokenStore {
126126
getText(node?: MaybeNode, beforeCount?: number, afterCount?: number): string
127127
getLines(): string[]
128128
getAllComments(): MaybeToken[]
129-
getComments(
130-
node: MaybeNode
131-
): { leading: MaybeToken[]; trailing: MaybeToken[] }
129+
getComments(node: MaybeNode): {
130+
leading: MaybeToken[]
131+
trailing: MaybeToken[]
132+
}
132133
getJSDocComment(node: MaybeNode): MaybeToken | null
133134
getNodeByRangeIndex(index: number): MaybeNode
134135
isSpaceBetweenTokens(first: MaybeToken, second: MaybeToken): boolean

lib/utils/collect-keys.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ function getKeyFromI18nComponent(node: VAST.VAttribute) {
7373
}
7474
}
7575

76-
function getParser(
77-
parser: string | undefined
78-
): {
76+
function getParser(parser: string | undefined): {
7977
parseForESLint?: typeof parseForESLint
8078
parse: (code: string, options: unknown) => VAST.ESLintProgram
8179
} {

lib/utils/glob-sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GlobSync.prototype._readdir = function (abs, inGlobStar) {
3535
return Sync.prototype._readdir.call(this, abs, inGlobStar)
3636
}
3737

38-
export default (GlobSync as never) as new (
38+
export default GlobSync as never as new (
3939
pattern: string,
4040
options: IOptions,
4141
shouldIgnore: (absolutePath: string) => boolean

lib/utils/glob-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ export function listFilesToProcess(
228228
pathDescriptor => pathDescriptor.behavior === SILENTLY_IGNORE
229229
)
230230
) {
231-
throw new (pathsForCurrentGlob.length
232-
? AllFilesIgnoredError
233-
: NoFilesFoundError)(globPatterns[index])
231+
throw new (
232+
pathsForCurrentGlob.length ? AllFilesIgnoredError : NoFilesFoundError
233+
)(globPatterns[index])
234234
}
235235

236236
pathsForCurrentGlob.forEach(pathDescriptor => {

lib/utils/ignored-paths.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ export class IgnoredPaths {
177177
try {
178178
statSync(options.ignorePath)
179179
ignorePath = options.ignorePath
180-
} catch (e) {
180+
} catch (
181+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
182+
e: any
183+
) {
181184
e.message = `Cannot read ignore file: ${options.ignorePath}\nError: ${e.message}`
182185
throw e
183186
}
@@ -209,7 +212,10 @@ export class IgnoredPaths {
209212
packageJSONOptions = JSON.parse(
210213
readFileSync(packageJSONPath, 'utf8')
211214
)
212-
} catch (e) {
215+
} catch (
216+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
217+
e: any
218+
) {
213219
debug(
214220
'Could not read package.json file to check eslintIgnore property'
215221
)

lib/utils/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,9 @@ export function isI18nBlock(
489489
* Get the static attribute values from a given element.
490490
* @param element The element to get.
491491
*/
492-
export function getStaticAttributes(
493-
element: VAST.VElement
494-
): { [name: string]: string | undefined } {
492+
export function getStaticAttributes(element: VAST.VElement): {
493+
[name: string]: string | undefined
494+
} {
495495
const attrs: { [name: string]: string | undefined } = {}
496496
for (const attr of element.startTag.attributes) {
497497
if (!attr.directive && attr.value) {

lib/utils/message-compiler/parser-v8.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import type {
1818
import lodash from 'lodash'
1919
import { NodeTypes } from './utils'
2020

21-
export function parse(
22-
code: string
23-
): {
21+
export function parse(code: string): {
2422
ast: ResourceNode
2523
errors: CompileError[]
2624
} {

lib/utils/message-compiler/parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { CompileError, ResourceNode } from '@intlify/message-compiler'
22
import { createParser } from '@intlify/message-compiler'
33

4-
export function parse(
5-
code: string
6-
): {
4+
export function parse(code: string): {
75
ast: ResourceNode
86
errors: CompileError[]
97
} {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"docs:build": "npm run build && vuepress build docs",
110110
"generate": "ts-node scripts/update.ts && prettier . --write",
111111
"lint": "eslint . --ext js,ts,vue,md --ignore-pattern \"/tests/fixtures\"",
112+
"lint-fix": "eslint . --ext js,ts,vue,md --ignore-pattern \"/tests/fixtures\" --fix",
112113
"lint:docs": "prettier docs --check",
113114
"release:prepare": "shipjs prepare",
114115
"release:trigger": "shipjs trigger",

scripts/lib/eslint-compat.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ export namespace ESLint {
77
}
88
export const ESLint = eslint.ESLint || getESLintClassForV6()
99

10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11+
type ESLintCLIEngine = any
12+
1013
function getESLintClassForV6(): typeof eslint.ESLint {
14+
const CLIEngine: ESLintCLIEngine =
15+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
16+
(eslint as any).CLIEngine
1117
class ESLintForV6 {
12-
private engine: eslint.CLIEngine
18+
private engine: ESLintCLIEngine
1319
static get version() {
14-
return eslint.CLIEngine.version
20+
return CLIEngine.version
1521
}
1622

1723
constructor(options?: eslint.ESLint.Options) {
@@ -26,7 +32,7 @@ function getESLintClassForV6(): typeof eslint.ESLint {
2632
plugins: pluginsMap,
2733
...otherOptions
2834
} = options || {}
29-
const newOptions: eslint.CLIEngine.Options = {
35+
const newOptions: ESLintCLIEngine['Options'] = {
3036
fix: Boolean(fix),
3137
reportUnusedDisableDirectives: reportUnusedDisableDirectives
3238
? reportUnusedDisableDirectives !== 'off'
@@ -43,11 +49,11 @@ function getESLintClassForV6(): typeof eslint.ESLint {
4349
o[ruleId] = opt
4450
}
4551
return o
46-
}, {} as NonNullable<eslint.CLIEngine.Options['rules']>)
52+
}, {} as NonNullable<ESLintCLIEngine['Options']['rules']>)
4753
: undefined,
4854
...overrideConfig
4955
}
50-
this.engine = new eslint.CLIEngine(newOptions)
56+
this.engine = new CLIEngine(newOptions)
5157

5258
for (const [name, plugin] of Object.entries(pluginsMap || {})) {
5359
this.engine.addPlugin(name, plugin)

tests-integrations/config-recommended/.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
module.exports = {
44
root: true,
55
extends: ['plugin:vue/recommended', 'plugin:@intlify/vue-i18n/recommended'],
6+
rules: {
7+
'vue/multi-word-component-names': 'off'
8+
},
69
settings: {
710
'vue-i18n': {
811
localeDir: `./src/resources/*.json`

0 commit comments

Comments
 (0)