Compare commits

...

9 Commits

Author SHA1 Message Date
Anthony Fu
a602eb1b4f chore: release v0.38.5 2023-04-18 14:01:56 +02:00
Anthony Fu
9114acddf6 chore: update build 2023-04-18 13:56:51 +02:00
Anthony Fu
e8cec1e2d5 chore: update deps 2023-04-18 13:56:00 +02:00
曾明健
506d17c3f7 feat(plugin): allow some one-line arrow functions (#172) 2023-04-18 13:54:50 +02:00
曾明健
ff74d69719 feat: enable no-invalid-this (#173) 2023-04-18 13:42:48 +02:00
曾明健
e28861a247 fix(basic): allow require imports in js file (#169) 2023-04-11 09:50:52 +02:00
曾明健
9fde0f404f feat(ts): ban namespace in ts file (#166) 2023-04-10 17:45:46 +02:00
曾明健
78b405f91a feat: ban requrie imports in ts file (#165) 2023-04-10 17:39:06 +02:00
曾明健
ebb96c422e feat(basic): consider comments for newline-after-import (#164) 2023-04-10 13:57:57 +02:00
13 changed files with 530 additions and 439 deletions

View File

@@ -1,7 +1,7 @@
{
"type": "module",
"private": true,
"packageManager": "pnpm@8.1.1",
"packageManager": "pnpm@8.3.0",
"scripts": {
"build": "vite-ssg build",
"dev": "vite --port 3333 --open",
@@ -15,18 +15,18 @@
"up": "taze major -I"
},
"dependencies": {
"@unocss/reset": "^0.50.6",
"@vueuse/core": "^9.13.0",
"@vueuse/head": "^1.1.23",
"@unocss/reset": "^0.51.4",
"@vueuse/core": "^10.0.2",
"@vueuse/head": "^1.1.26",
"nprogress": "^0.2.0",
"pinia": "^2.0.33",
"pinia": "^2.0.34",
"vue": "^3.2.47",
"vue-demi": "^0.13.11",
"vue-demi": "^0.14.0",
"vue-i18n": "^9.2.2",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.3",
"@antfu/eslint-config": "^0.38.4",
"@iconify-json/carbon": "^1.1.16",
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
"@types/markdown-it-link-attributes": "^3.0.1",
@@ -35,28 +35,28 @@
"@vue/test-utils": "^2.3.2",
"critters": "^0.0.16",
"cross-env": "^7.0.3",
"cypress": "^12.9.0",
"eslint": "^8.37.0",
"cypress": "^12.10.0",
"eslint": "^8.38.0",
"eslint-plugin-cypress": "^2.13.2",
"https-localhost": "^4.7.1",
"markdown-it-link-attributes": "^4.0.1",
"markdown-it-shiki": "^0.8.0",
"pnpm": "^8.1.1",
"pnpm": "^8.3.0",
"shiki": "^0.14.1",
"taze": "^0.9.1",
"typescript": "^5.0.3",
"unocss": "^0.50.6",
"unplugin-auto-import": "^0.15.2",
"typescript": "^5.0.4",
"unocss": "^0.51.4",
"unplugin-auto-import": "^0.15.3",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.2.1",
"vite-plugin-inspect": "^0.7.18",
"vite": "^4.2.2",
"vite-plugin-inspect": "^0.7.22",
"vite-plugin-pages": "^0.29.0",
"vite-plugin-pwa": "^0.14.7",
"vite-plugin-vue-layouts": "^0.8.0",
"vite-plugin-vue-markdown": "^0.22.4",
"vite-ssg": "^0.22.1",
"vite-plugin-vue-markdown": "^0.22.5",
"vite-ssg": "^0.22.2",
"vite-ssg-sitemap": "^0.4.3",
"vitest": "^0.29.8",
"vitest": "^0.30.1",
"vue-tsc": "^1.2.0"
}
}

View File

@@ -1,22 +1,23 @@
{
"name": "@antfu/eslint-config-monorepo",
"version": "0.38.4",
"version": "0.38.5",
"private": true,
"packageManager": "pnpm@8.1.1",
"packageManager": "pnpm@8.3.0",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
"scripts": {
"lint": "eslint .",
"lint": "pnpm run stub && eslint .",
"test": "pnpm -r run test",
"build": "pnpm -r run build",
"prepare": "pnpm -r run stub",
"release": "bumpp -r && pnpm -r publish"
},
"devDependencies": {
"@antfu/eslint-config": "workspace:*",
"bumpp": "^9.1.0",
"eslint": "^8.37.0",
"eslint": "^8.38.0",
"eslint-plugin-antfu": "link:./packages/eslint-plugin-antfu",
"rimraf": "^4.4.1",
"typescript": "^5.0.3"
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
}
}

View File

@@ -154,9 +154,10 @@ module.exports = {
},
},
{
files: ['*.js', '*.cjs'],
files: ['*.js', '*.cjs', '*.jsx'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
{
@@ -207,7 +208,7 @@ module.exports = {
'import/no-mutable-exports': 'error',
'import/no-unresolved': 'off',
'import/no-absolute-path': 'off',
'import/newline-after-import': ['error', { count: 1 }],
'import/newline-after-import': ['error', { count: 1, considerComments: true }],
// Common
'semi': ['error', 'never'],
@@ -309,6 +310,7 @@ module.exports = {
'no-with': 'error',
'no-void': 'error',
'no-useless-escape': 'off',
'no-invalid-this': 'error',
'vars-on-top': 'error',
'require-await': 'off',
'no-return-assign': 'off',

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-basic",
"version": "0.38.4",
"version": "0.38.5",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -35,6 +35,6 @@
"yaml-eslint-parser": "^1.2.0"
},
"devDependencies": {
"eslint": "^8.37.0"
"eslint": "^8.38.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-react",
"version": "0.38.4",
"version": "0.38.5",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -24,8 +24,8 @@
"eslint-plugin-react-hooks": "^4.6.0"
},
"devDependencies": {
"eslint": "^8.37.0",
"eslint": "^8.38.0",
"react": "^18.2.0",
"typescript": "^5.0.3"
"typescript": "^5.0.4"
}
}

View File

@@ -71,6 +71,7 @@ module.exports = {
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports', disallowTypeAnnotations: false }],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-require-imports': 'error',
// Override JS
'no-useless-constructor': 'off',
@@ -113,6 +114,8 @@ module.exports = {
],
offsetTernaryExpressions: true,
}],
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': 'error',
'no-use-before-define': 'off',
@@ -169,7 +172,6 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
// handled by unused-imports/no-unused-imports
'@typescript-eslint/no-unused-vars': 'off',

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-ts",
"version": "0.38.4",
"version": "0.38.5",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -18,11 +18,11 @@
},
"dependencies": {
"@antfu/eslint-config-basic": "workspace:*",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint-plugin-jest": "^27.2.1"
},
"devDependencies": {
"eslint": "^8.37.0"
"eslint": "^8.38.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-vue",
"version": "0.38.4",
"version": "0.38.5",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -17,10 +17,10 @@
"dependencies": {
"@antfu/eslint-config-basic": "workspace:*",
"@antfu/eslint-config-ts": "workspace:*",
"eslint-plugin-vue": "^9.10.0",
"eslint-plugin-vue": "^9.11.0",
"local-pkg": "^0.4.3"
},
"devDependencies": {
"eslint": "^8.37.0"
"eslint": "^8.38.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config",
"version": "0.38.4",
"version": "0.38.5",
"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.1",
"@typescript-eslint/parser": "^5.57.1",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.27.5",
@@ -26,12 +26,12 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^46.0.0",
"eslint-plugin-vue": "^9.10.0",
"eslint-plugin-vue": "^9.11.0",
"eslint-plugin-yml": "^1.5.0",
"jsonc-eslint-parser": "^2.2.0",
"yaml-eslint-parser": "^1.2.0"
},
"devDependencies": {
"eslint": "^8.37.0"
"eslint": "^8.38.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-antfu",
"version": "0.38.4",
"version": "0.38.5",
"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.1"
"@typescript-eslint/utils": "^5.59.0"
},
"devDependencies": {
"@types/node": "^18.15.11",
"unbuild": "^1.2.0",
"vitest": "^0.29.8"
"unbuild": "^1.2.1",
"vitest": "^0.30.1"
}
}

View File

@@ -17,15 +17,24 @@ const valids = [
// allow export default
'export default () => {}',
'export default defineConfig(() => {})',
// allow one-line arrow function
'const foo = (x, y) => x + y',
'const foo = async (x, y) => x + y',
'const foo = () => String(123)',
'const foo = () => ({})',
]
const invalids = [
[
'const foo = (x, y) => \nx + y',
'function foo (x, y) {\n return x + y\n}',
],
[
'const foo = (as: string, bar: number) => { return as + bar }',
'function foo (as: string, bar: number) { return as + bar }',
],
[
'const foo = <K, T extends Boolean>(as: string, bar: number): Omit<T, K> => as + bar',
'const foo = <K, T extends Boolean>(as: string, bar: number): Omit<T, K> => \nas + bar',
'function foo <K, T extends Boolean>(as: string, bar: number): Omit<T, K> {\n return as + bar\n}',
],
[
@@ -33,11 +42,11 @@ const invalids = [
'export function foo () {}',
],
[
'export const foo = () => ({})',
'export const foo = () => \n({})',
'export function foo () {\n return {}\n}',
],
[
'export const foo = async () => ({})',
'export const foo = async () => \n({})',
'export async function foo () {\n return {}\n}',
],
]

View File

@@ -40,6 +40,11 @@ export default createEslintRule<Options, MessageIds>({
return
if (declaration.id.typeAnnotation)
return
if (
declaration.init.body.type !== 'BlockStatement'
&& declaration.id?.loc.start.line === declaration.init?.body.loc.end.line
)
return
const arrowFn = declaration.init
const body = declaration.init.body

848
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff