Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5240f68454 | ||
|
79c8de557e | ||
|
3f13db706b | ||
|
7a5daf6f38 | ||
|
79b63bc0c9 | ||
|
60002c33fd | ||
|
502f6b0c37 | ||
|
d1cd722857 | ||
|
d2150eec3b | ||
|
d3c3e1b84d | ||
|
3963633712 | ||
|
e9193343e8 | ||
|
e8d73f737e | ||
|
3a74c8e351 | ||
|
3fa861730d | ||
|
ebbc1a7f78 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.0.0",
|
||||
"packageManager": "pnpm@8.1.1",
|
||||
"scripts": {
|
||||
"build": "vite-ssg build",
|
||||
"dev": "vite --port 3333 --open",
|
||||
@@ -26,7 +26,7 @@
|
||||
"vue-router": "^4.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^0.37.0",
|
||||
"@antfu/eslint-config": "^0.38.3",
|
||||
"@iconify-json/carbon": "^1.1.16",
|
||||
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
|
||||
"@types/markdown-it-link-attributes": "^3.0.1",
|
||||
@@ -41,10 +41,10 @@
|
||||
"https-localhost": "^4.7.1",
|
||||
"markdown-it-link-attributes": "^4.0.1",
|
||||
"markdown-it-shiki": "^0.8.0",
|
||||
"pnpm": "^8.0.0",
|
||||
"pnpm": "^8.1.1",
|
||||
"shiki": "^0.14.1",
|
||||
"taze": "^0.9.1",
|
||||
"typescript": "^5.0.2",
|
||||
"typescript": "^5.0.3",
|
||||
"unocss": "^0.50.6",
|
||||
"unplugin-auto-import": "^0.15.2",
|
||||
"unplugin-vue-components": "^0.24.1",
|
||||
|
12
package.json
12
package.json
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-monorepo",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@8.0.0",
|
||||
"packageManager": "pnpm@8.1.1",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
@@ -12,11 +12,11 @@
|
||||
"release": "bumpp -r && pnpm -r publish"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "*",
|
||||
"bumpp": "^9.0.0",
|
||||
"@antfu/eslint-config": "workspace:*",
|
||||
"bumpp": "^9.1.0",
|
||||
"eslint": "^8.37.0",
|
||||
"eslint-plugin-antfu": "workspace:*",
|
||||
"eslint-plugin-antfu": "link:./packages/eslint-plugin-antfu",
|
||||
"rimraf": "^4.4.1",
|
||||
"typescript": "^5.0.2"
|
||||
"typescript": "^5.0.3"
|
||||
}
|
||||
}
|
||||
|
@@ -207,6 +207,7 @@ module.exports = {
|
||||
'import/no-mutable-exports': 'error',
|
||||
'import/no-unresolved': 'off',
|
||||
'import/no-absolute-path': 'off',
|
||||
'import/newline-after-import': ['error', { count: 1 }],
|
||||
|
||||
// Common
|
||||
'semi': ['error', 'never'],
|
||||
@@ -314,6 +315,11 @@ module.exports = {
|
||||
'operator-linebreak': ['error', 'before'],
|
||||
'max-statements-per-line': ['error', { max: 1 }],
|
||||
|
||||
// node
|
||||
// 'n/prefer-global/process': ['error', 'never'], // Not sure if we need it as we are using `process.env.NODE_ENV` a lot in front-end.
|
||||
'n/prefer-global/buffer': ['error', 'never'],
|
||||
'n/no-callback-literal': 'off',
|
||||
|
||||
// unicorns
|
||||
// Pass error message when throwing errors
|
||||
'unicorn/error-message': 'error',
|
||||
@@ -345,7 +351,6 @@ module.exports = {
|
||||
'import/no-named-as-default-member': 'off',
|
||||
'import/no-named-as-default': 'off',
|
||||
'import/namespace': 'off',
|
||||
'n/no-callback-literal': 'off',
|
||||
|
||||
'sort-imports': [
|
||||
'error',
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-basic",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"description": "",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-react",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"description": "",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
@@ -26,6 +26,6 @@
|
||||
"devDependencies": {
|
||||
"eslint": "^8.37.0",
|
||||
"react": "^18.2.0",
|
||||
"typescript": "^5.0.2"
|
||||
"typescript": "^5.0.3"
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-ts",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"description": "",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
@@ -18,8 +18,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@antfu/eslint-config-basic": "workspace:*",
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||
"@typescript-eslint/parser": "^5.57.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
||||
"@typescript-eslint/parser": "^5.57.1",
|
||||
"eslint-plugin-jest": "^27.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config-vue",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"description": "",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@antfu/eslint-config",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"description": "Anthony's ESLint config",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
||||
"license": "MIT",
|
||||
@@ -17,8 +17,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@antfu/eslint-config-vue": "workspace:*",
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
||||
"@typescript-eslint/parser": "^5.57.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
||||
"@typescript-eslint/parser": "^5.57.1",
|
||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||
"eslint-plugin-html": "^7.1.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eslint-plugin-antfu",
|
||||
"version": "0.38.0",
|
||||
"version": "0.38.4",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/antfu/eslint-config",
|
||||
"main": "./dist/index.cjs",
|
||||
@@ -16,11 +16,11 @@
|
||||
"prepublishOnly": "nr build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/utils": "^5.57.0"
|
||||
"@typescript-eslint/utils": "^5.57.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.11",
|
||||
"unbuild": "^1.1.2",
|
||||
"unbuild": "^1.2.0",
|
||||
"vitest": "^0.29.8"
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,9 @@ const valids = [
|
||||
'const foo = (() => {}) as any',
|
||||
// allow iife
|
||||
';(() => {})()',
|
||||
// allow export default
|
||||
'export default () => {}',
|
||||
'export default defineConfig(() => {})',
|
||||
]
|
||||
|
||||
const invalids = [
|
||||
@@ -23,7 +26,7 @@ const invalids = [
|
||||
],
|
||||
[
|
||||
'const foo = <K, T extends Boolean>(as: string, bar: number): Omit<T, K> => as + bar',
|
||||
'function foo <K, T extends Boolean>(as: string, bar: number): Omit<T, K> { return as + bar }',
|
||||
'function foo <K, T extends Boolean>(as: string, bar: number): Omit<T, K> {\n return as + bar\n}',
|
||||
],
|
||||
[
|
||||
'export const foo = () => {}',
|
||||
@@ -31,7 +34,11 @@ const invalids = [
|
||||
],
|
||||
[
|
||||
'export const foo = () => ({})',
|
||||
'export function foo () { return {} }',
|
||||
'export function foo () {\n return {}\n}',
|
||||
],
|
||||
[
|
||||
'export const foo = async () => ({})',
|
||||
'export async function foo () {\n return {}\n}',
|
||||
],
|
||||
]
|
||||
|
||||
|
@@ -48,8 +48,8 @@ export default createEslintRule<Options, MessageIds>({
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: node.loc.start,
|
||||
end: node.loc.end,
|
||||
start: id.loc.start,
|
||||
end: body.loc.start,
|
||||
},
|
||||
messageId: 'topLevelFunctionDeclaration',
|
||||
fix(fixer) {
|
||||
@@ -60,19 +60,21 @@ export default createEslintRule<Options, MessageIds>({
|
||||
: ''
|
||||
const textBody = body.type === 'BlockStatement'
|
||||
? code.slice(body.range[0], body.range[1])
|
||||
: `{ return ${code.slice(body.range[0], body.range[1])} }`
|
||||
: `{\n return ${code.slice(body.range[0], body.range[1])}\n}`
|
||||
const textGeneric = arrowFn.typeParameters
|
||||
? code.slice(arrowFn.typeParameters.range[0], arrowFn.typeParameters.range[1])
|
||||
: ''
|
||||
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)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
1713
pnpm-lock.yaml
generated
1713
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user