Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: intlify/eslint-plugin-vue-i18n
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0-next.6
Choose a base ref
...
head repository: intlify/eslint-plugin-vue-i18n
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.0-next.7
Choose a head ref
  • 3 commits
  • 7 files changed
  • 3 contributors

Commits on Feb 20, 2024

  1. test: fix test cases

    ota-meshi committed Feb 20, 2024
    Copy the full SHA
    56b1761 View commit details
  2. fix: wrong suggestion for remove all unused keys in `vue-i18n/no-unus…

    …ed-keys` rule (#474)
    
    * fix: wrong suggestion for remove all unused keys in `no-unused-keys` rule
    
    * Create ninety-snakes-scream.md
    ota-meshi authored Feb 20, 2024
    Copy the full SHA
    ebd7353 View commit details
  3. chore: release @intlify/eslint-plugin-vue-i18n (next) (#475)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Feb 20, 2024
    Copy the full SHA
    35de773 View commit details
Showing with 919 additions and 37 deletions.
  1. +5 −0 .changeset/ninety-snakes-scream.md
  2. +1 −0 .changeset/pre.json
  3. +9 −1 CHANGELOG.md
  4. +20 −12 lib/rules/no-unused-keys.ts
  5. +1 −1 package.json
  6. +0 −7 tests/lib/rules/no-missing-keys.ts
  7. +883 −16 tests/lib/rules/no-unused-keys.ts
5 changes: 5 additions & 0 deletions .changeset/ninety-snakes-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@intlify/eslint-plugin-vue-i18n": patch
---

fix: wrong suggestion for remove all unused keys in `vue-i18n/no-unused-keys` rule
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
"forty-tools-dream",
"fresh-squids-build",
"khaki-eyes-serve",
"ninety-snakes-scream",
"olive-chairs-invent",
"shiny-colts-search",
"ten-insects-deny"
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 3.0.0-next.2
# @intlify/eslint-plugin-vue-i18n

## 3.0.0-next.7

### Patch Changes

- [#474](https://github.com/intlify/eslint-plugin-vue-i18n/pull/474) [`ebd7353`](https://github.com/intlify/eslint-plugin-vue-i18n/commit/ebd7353ada4d65eec0f504887db0911a80819979) Thanks [@ota-meshi](https://github.com/ota-meshi)! - fix: wrong suggestion for remove all unused keys in `vue-i18n/no-unused-keys` rule

## 3.0.0-next.6

@@ -28,6 +34,8 @@

- [#413](https://github.com/intlify/eslint-plugin-vue-i18n/pull/413) [`0fadd81`](https://github.com/intlify/eslint-plugin-vue-i18n/commit/0fadd81f0551c380514744573b4c3fdac9b9d4fa) Thanks [@dargmuesli](https://github.com/dargmuesli)! - Pin `@intlify` dependencies to tag `beta` to try to prevent renovate from downgrading.

## 3.0.0-next.2

### Patch Changes

- [#394](https://github.com/intlify/eslint-plugin-vue-i18n/pull/394) [`3774e88`](https://github.com/intlify/eslint-plugin-vue-i18n/commit/3774e88ba06335efe2112594d0c92b8ac4e5d242) Thanks [@wolfgangwalther](https://github.com/wolfgangwalther)! - fix: no-missing-keys rule reports false positive with trailing dot
32 changes: 20 additions & 12 deletions lib/rules/no-unused-keys.ts
Original file line number Diff line number Diff line change
@@ -208,36 +208,44 @@ function create(context: RuleContext): RuleListener {
}

function* fixAllRemoveKeys(fixer: RuleFixer, nodes: JSONAST.JSONNode[]) {
const ranges = nodes.map(node => fixRemoveRange(node))

const removed = new Set<JSONAST.JSONNode>()
let preLast = 0
for (const range of ranges) {
yield fixer.removeRange([Math.max(preLast, range[0]), range[1]])
for (const node of nodes) {
const range = fixRemoveRange(node, removed)
const start = Math.max(preLast, range[0])
yield fixer.removeRange([start, range[1]])
preLast = range[1]
}
}

/**
* @param {JSONNode} node
*/
function fixRemoveRange(node: JSONAST.JSONNode): Range {
function fixRemoveRange(
node: JSONAST.JSONNode,
removedNodes: Set<JSONAST.JSONNode> = new Set()
): Range {
const parent = node.parent!
let removeNode
let isFirst = false
let isLast = false
if (parent.type === 'JSONProperty') {
removeNode = parent
const index = parent.parent.properties.indexOf(parent)
const properties = parent.parent.properties.filter(
p => !removedNodes.has(p)
)
const index = properties.indexOf(parent)
isFirst = index === 0
isLast = index === parent.parent.properties.length - 1
isLast = index === properties.length - 1
} else {
removeNode = node
if (parent.type === 'JSONArrayExpression') {
const index = parent.elements.indexOf(node as never)
const elements = parent.elements.filter(
e => e == null || !removedNodes.has(e)
)
const index = elements.indexOf(node as never)
isFirst = index === 0
isLast = index === parent.elements.length - 1
isLast = index === elements.length - 1
}
}
removedNodes.add(removeNode)
const range: Range = [...removeNode.range]

if (isLast || isFirst) {
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@intlify/eslint-plugin-vue-i18n",
"description": "ESLint plugin for Vue I18n",
"version": "3.0.0-next.6",
"version": "3.0.0-next.7",
"license": "MIT",
"homepage": "https://github.com/intlify/eslint-plugin-vue-i18n#readme",
"keywords": [
7 changes: 0 additions & 7 deletions tests/lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
@@ -297,13 +297,6 @@ tester.run('no-missing-keys', rule as never, {
`'messages.missing' does not exist in localization message resources`
]
},
{
// nested missing
code: `$t('messages.missing')`,
errors: [
`'messages.missing' does not exist in localization message resources`
]
},
{
// @ts-expect-error -- Type error for eslint v9
languageOptions: {
Loading