Compare commits

..

7 Commits

Author SHA1 Message Date
Anthony Fu
60002c33fd chore: release v0.38.3 2023-04-03 14:42:06 +02:00
曾明健
502f6b0c37 feat(basic): prefer non global object of node (#159)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
2023-04-03 14:41:41 +02:00
曾明健
d1cd722857 feat(basic): new line after import (#161) 2023-04-03 14:30:54 +02:00
Anthony Fu
d2150eec3b fix(top-level-function): narrow warning range 2023-03-30 11:02:49 +02:00
Anthony Fu
d3c3e1b84d chore: update lock 2023-03-30 10:57:04 +02:00
Anthony Fu
3963633712 chore: release v0.38.2 2023-03-30 10:53:40 +02:00
Anthony Fu
e9193343e8 chore: format 2023-03-30 10:53:36 +02:00
11 changed files with 58 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-monorepo",
"version": "0.38.1",
"version": "0.38.3",
"private": true,
"packageManager": "pnpm@8.0.0",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",

View File

@@ -49,6 +49,7 @@ module.exports = {
'antfu',
'no-only-tests',
'unused-imports',
'node',
],
settings: {
'import/resolver': {
@@ -207,6 +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 }],
// Common
'semi': ['error', 'never'],
@@ -314,6 +316,10 @@ module.exports = {
'operator-linebreak': ['error', 'before'],
'max-statements-per-line': ['error', { max: 1 }],
// node
// 'node/prefer-global/process': ['error', 'never'], // Not sure if we need it as we are using `process.env.NODE_ENV` a lot in front-end.
'node/prefer-global/buffer': ['error', 'never'],
// unicorns
// Pass error message when throwing errors
'unicorn/error-message': 'error',

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-basic",
"version": "0.38.1",
"version": "0.38.3",
"description": "",
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
"license": "MIT",
@@ -27,6 +27,7 @@
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^46.0.0",
"eslint-plugin-unused-imports": "^2.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@antfu/eslint-config-react",
"version": "0.38.1",
"version": "0.38.3",
"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.1",
"version": "0.38.3",
"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.1",
"version": "0.38.3",
"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.1",
"version": "0.38.3",
"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.1",
"version": "0.38.3",
"license": "MIT",
"homepage": "https://github.com/antfu/eslint-config",
"main": "./dist/index.cjs",

View File

@@ -26,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 = () => {}',
@@ -34,11 +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 () { return {} }',
'export async function foo () {\n return {}\n}',
],
]

View File

@@ -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,7 +60,7 @@ 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])
: ''

47
pnpm-lock.yaml generated
View File

@@ -98,6 +98,9 @@ importers:
eslint-plugin-no-only-tests:
specifier: ^3.1.0
version: 3.1.0
eslint-plugin-node:
specifier: ^11.1.0
version: 11.1.0(eslint@8.37.0)
eslint-plugin-promise:
specifier: ^6.1.1
version: 6.1.1(eslint@8.37.0)
@@ -1172,8 +1175,8 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
dependencies:
caniuse-lite: 1.0.30001472
electron-to-chromium: 1.4.342
caniuse-lite: 1.0.30001473
electron-to-chromium: 1.4.345
node-releases: 2.0.10
update-browserslist-db: 1.0.10(browserslist@4.21.5)
dev: true
@@ -1220,8 +1223,8 @@ packages:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'}
/caniuse-lite@1.0.30001472:
resolution: {integrity: sha512-xWC/0+hHHQgj3/vrKYY0AAzeIUgr7L9wlELIcAvZdDUHlhL/kNxMdnQLOSOQfP8R51ZzPhmHdyMkI0MMpmxCfg==}
/caniuse-lite@1.0.30001473:
resolution: {integrity: sha512-ewDad7+D2vlyy+E4UJuVfiBsU69IL+8oVmTuZnH5Q6CIUbxNfI50uVpRHbUPDD6SUaN2o0Lh4DhTrvLG/Tn1yg==}
dev: true
/chai@4.3.7:
@@ -1443,8 +1446,8 @@ packages:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
dev: true
/electron-to-chromium@1.4.342:
resolution: {integrity: sha512-dTei3VResi5bINDENswBxhL+N0Mw5YnfWyTqO75KGsVldurEkhC9+CelJVAse8jycWyP8pv3VSj4BSyP8wTWJA==}
/electron-to-chromium@1.4.345:
resolution: {integrity: sha512-znGhOQK2TUYLICgS25uaM0a7pHy66rSxbre7l762vg9AUoCcJK+Bu+HCPWpjL/U/kK8/Hf+6E0szAUJSyVYb3Q==}
dev: true
/emoji-regex@9.2.2:
@@ -1608,6 +1611,17 @@ packages:
- supports-color
dev: false
/eslint-plugin-es@3.0.1(eslint@8.37.0):
resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==}
engines: {node: '>=8.10.0'}
peerDependencies:
eslint: '>=4.19.1'
dependencies:
eslint: 8.37.0
eslint-utils: 2.1.0
regexpp: 3.2.0
dev: false
/eslint-plugin-es@4.1.0(eslint@8.37.0):
resolution: {integrity: sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==}
engines: {node: '>=8.10.0'}
@@ -1736,6 +1750,21 @@ packages:
engines: {node: '>=5.0.0'}
dev: false
/eslint-plugin-node@11.1.0(eslint@8.37.0):
resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==}
engines: {node: '>=8.10.0'}
peerDependencies:
eslint: '>=5.16.0'
dependencies:
eslint: 8.37.0
eslint-plugin-es: 3.0.1(eslint@8.37.0)
eslint-utils: 2.1.0
ignore: 5.2.4
minimatch: 3.1.2
resolve: 1.22.1
semver: 6.3.0
dev: false
/eslint-plugin-promise@6.1.1(eslint@8.37.0):
resolution: {integrity: sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1829,7 +1858,7 @@ packages:
nth-check: 2.1.1
postcss-selector-parser: 6.0.11
semver: 7.3.8
vue-eslint-parser: 9.1.0(eslint@8.37.0)
vue-eslint-parser: 9.1.1(eslint@8.37.0)
xml-name-validator: 4.0.0
transitivePeerDependencies:
- supports-color
@@ -3705,8 +3734,8 @@ packages:
- terser
dev: true
/vue-eslint-parser@9.1.0(eslint@8.37.0):
resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==}
/vue-eslint-parser@9.1.1(eslint@8.37.0):
resolution: {integrity: sha512-C2aI/r85Q6tYcz4dpgvrs4wH/MqVrRAVIdpYedrxnATDHHkb+TroeRcDpKWGZCx/OcECMWfz7tVwQ8e+Opy6rA==}
engines: {node: ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: '>=6.0.0'