Compare commits

..

4 Commits

Author SHA1 Message Date
Anthony Fu
e8d73f737e chore: release v0.38.1 2023-03-30 10:51:35 +02:00
Anthony Fu
3a74c8e351 fix(top-level-function): support async function 2023-03-30 10:51:29 +02:00
Anthony Fu
3fa861730d test: add more test case 2023-03-30 01:08:42 +02:00
Anthony Fu
ebbc1a7f78 chore: rebuild lock file 2023-03-29 15:52:45 +02:00
10 changed files with 608 additions and 761 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-monorepo",
"version": "0.38.0",
"version": "0.38.1",
"private": true,
"packageManager": "pnpm@8.0.0",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
@@ -12,7 +12,7 @@
"release": "bumpp -r && pnpm -r publish"
},
"devDependencies": {
"@antfu/eslint-config": "*",
"@antfu/eslint-config": "workspace:*",
"bumpp": "^9.0.0",
"eslint": "^8.37.0",
"eslint-plugin-antfu": "workspace:*",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-basic",
"version": "0.38.0",
"version": "0.38.1",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-react",
"version": "0.38.0",
"version": "0.38.1",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-ts",
"version": "0.38.0",
"version": "0.38.1",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-vue",
"version": "0.38.0",
"version": "0.38.1",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config",
"version": "0.38.0",
"version": "0.38.1",
"description": "Anthony's ESLint config",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-antfu",
"version": "0.38.0",
"version": "0.38.1",
"license": "MIT",
"homepage": "https://github.com/antfu/eslint-config",
"main": "./dist/index.cjs",

View File

@@ -14,6 +14,9 @@ const valids = [
'const foo = (() => {}) as any',
// allow iife
';(() => {})()',
// allow export default
'export default () => {}',
'export default defineConfig(() => {})',
]
const invalids = [
@@ -33,6 +36,10 @@ const invalids = [
'export const foo = () => ({})',
'export function foo () { return {} }',
],
[
'export const foo = async () => ({})',
'export async function foo () { return {} }',
],
]
it('runs', () => {

View File

@@ -67,12 +67,14 @@ export default createEslintRule<Options, MessageIds>({
const textTypeReturn = arrowFn.returnType
? code.slice(arrowFn.returnType.range[0], arrowFn.returnType.range[1])
: ''
const text = `function ${textName} ${textGeneric}(${textArgs})${textTypeReturn} ${textBody}`
const textAsync = arrowFn.async ? 'async ' : ''
const final = `${textAsync}function ${textName} ${textGeneric}(${textArgs})${textTypeReturn} ${textBody}`
// console.log({
// input: code.slice(node.range[0], node.range[1]),
// output: text,
// output: final,
// })
return fixer.replaceTextRange([node.range[0], node.range[1]], text)
return fixer.replaceTextRange([node.range[0], node.range[1]], final)
},
})
},

1338
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff