Skip to content

Commit

Permalink
refactor: upgrade eslint-config
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jun 4, 2023
1 parent 005664f commit e877a5d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .changeset/dull-bobcats-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@vue-macros/reactivity-transform': patch
'@vue-macros/named-template': patch
'@vue-macros/define-emit': patch
'@vue-macros/test-utils': patch
---

upgrade eslint-config
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/types": "^7.22.4",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.1",
"@sxzz/eslint-config": "^3.0.0-beta.11",
"@sxzz/eslint-config": "^3.0.0-beta.12",
"@types/node": "^20.2.5",
"@vitest/coverage-c8": "^0.31.4",
"@vitest/ui": "^0.31.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/define-emit/tests/define-emit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('defineEmit', () => {
'test.vue'
)

const code = result?.code ? result.code.trim().replace(/\s+/g, ' ') : ''
const code = result?.code ? result.code.trim().replaceAll(/\s+/g, ' ') : ''

expect(code).includes(
`const ${EMIT_VARIABLE_NAME} = defineEmits(["foo", "bar"])`
Expand Down
2 changes: 1 addition & 1 deletion packages/named-template/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,5 @@ export function postTransformMainEntry(
}

function escapeTemplateName(name: string) {
return name.replace(/-/g, '$DASH')
return name.replaceAll('-', '$DASH')
}
2 changes: 1 addition & 1 deletion packages/named-template/src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function getChildrenLocation(
node: ElementNode
): [number, number] | undefined {
if (node.children.length > 0) {
const lastChild = node.children[node.children.length - 1]
const lastChild = node.children.at(-1)
return [node.children[0].loc.start.offset, lastChild.loc.end.offset]
} else {
return undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity-transform/src/core/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ export function transformAST(
isFunctionType(node)
) {
scopeStack.pop()
currentScope = scopeStack[scopeStack.length - 1] || null
currentScope = scopeStack.at(-1) || null
}
if (node === escapeScope) {
escapeScope = undefined
Expand Down
6 changes: 3 additions & 3 deletions packages/test-utils/src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export { default as RollupJson } from '@rollup/plugin-json'
export const RollupToStringPlugin = (): Plugin => {
return {
name: 'to-string',
transform: (code) => `export default \`${code.replace(/`/g, '\\`')}\``,
transform: (code) => `export default \`${code.replaceAll('`', '\\`')}\``,
}
}

Expand All @@ -27,7 +27,7 @@ export const RollupRemoveVueFilePathPlugin = (): Plugin => {
name: 'remove-vue-filepath',
transform(code: string) {
const transformed = code
.replace(REGEX[0], '__FILE__')
.replaceAll(REGEX[0], '__FILE__')
.replace(REGEX[1], '__FILE__')
if (code !== transformed) return transformed
},
Expand All @@ -42,7 +42,7 @@ export const RollupEscapeNullCharacterPlugin = (): Plugin => {
const b = bundle[filename]
if (b.type !== 'chunk') continue
if (b.code.includes('\0')) {
b.code = b.code.replace(/\0/g, '[NULL]')
b.code = b.code.replaceAll('\0', '[NULL]')
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/src/strings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function removeSpaces(s: string) {
return s
.trim()
.replace(/[\n\r]/g, '')
.replace(/\s+/g, ' ')
.replaceAll(/[\n\r]/g, '')
.replaceAll(/\s+/g, ' ')
}
21 changes: 13 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e877a5d

Please sign in to comment.