Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8d73f737e | ||
|
|
3a74c8e351 | ||
|
|
3fa861730d | ||
|
|
ebbc1a7f78 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config-monorepo",
|
"name": "@antfu/eslint-config-monorepo",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@8.0.0",
|
"packageManager": "pnpm@8.0.0",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"release": "bumpp -r && pnpm -r publish"
|
"release": "bumpp -r && pnpm -r publish"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antfu/eslint-config": "*",
|
"@antfu/eslint-config": "workspace:*",
|
||||||
"bumpp": "^9.0.0",
|
"bumpp": "^9.0.0",
|
||||||
"eslint": "^8.37.0",
|
"eslint": "^8.37.0",
|
||||||
"eslint-plugin-antfu": "workspace:*",
|
"eslint-plugin-antfu": "workspace:*",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config-basic",
|
"name": "@antfu/eslint-config-basic",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config-react",
|
"name": "@antfu/eslint-config-react",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config-ts",
|
"name": "@antfu/eslint-config-ts",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config-vue",
|
"name": "@antfu/eslint-config-vue",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@antfu/eslint-config",
|
"name": "@antfu/eslint-config",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"description": "Anthony's ESLint config",
|
"description": "Anthony's ESLint config",
|
||||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-plugin-antfu",
|
"name": "eslint-plugin-antfu",
|
||||||
"version": "0.38.0",
|
"version": "0.38.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/antfu/eslint-config",
|
"homepage": "https://github.com/antfu/eslint-config",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ const valids = [
|
|||||||
'const foo = (() => {}) as any',
|
'const foo = (() => {}) as any',
|
||||||
// allow iife
|
// allow iife
|
||||||
';(() => {})()',
|
';(() => {})()',
|
||||||
|
// allow export default
|
||||||
|
'export default () => {}',
|
||||||
|
'export default defineConfig(() => {})',
|
||||||
]
|
]
|
||||||
|
|
||||||
const invalids = [
|
const invalids = [
|
||||||
@@ -33,6 +36,10 @@ const invalids = [
|
|||||||
'export const foo = () => ({})',
|
'export const foo = () => ({})',
|
||||||
'export function foo () { return {} }',
|
'export function foo () { return {} }',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'export const foo = async () => ({})',
|
||||||
|
'export async function foo () { return {} }',
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
it('runs', () => {
|
it('runs', () => {
|
||||||
|
|||||||
@@ -67,12 +67,14 @@ export default createEslintRule<Options, MessageIds>({
|
|||||||
const textTypeReturn = arrowFn.returnType
|
const textTypeReturn = arrowFn.returnType
|
||||||
? code.slice(arrowFn.returnType.range[0], arrowFn.returnType.range[1])
|
? 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({
|
// console.log({
|
||||||
// input: code.slice(node.range[0], node.range[1]),
|
// 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
1338
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user