Skip to content

Commit 02b845d

Browse files
committed
feat(lint): 更新规则限制
1 parent c83afef commit 02b845d

File tree

10 files changed

+22
-40
lines changed

10 files changed

+22
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"build:binding:release": "pnpm --filter @tarojs/binding run build",
2727
"format::rs": "cargo fmt --all",
2828
"clear-all": "rimraf **/node_modules",
29-
"lint": "eslint ./packages/ --ext .js,.jsx,.ts,.tsx",
29+
"lint": "eslint ./packages/ --ext .js,.jsx,.ts,.tsx,.mjs,.mts",
3030
"lint:style": "stylelint ./packages/**/*.{css,scss}",
3131
"format": "prettier --write --cache .",
3232
"format:check": "prettier --check --cache .",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

packages/taro-platform-harmony-hybrid/src/api/apis/base/getAppAuthorizeSetting/oschannel.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import Taro from '@tarojs/api'
44
let abilityAccessCtrl
55

66
try {
7-
// @ts-ignore
7+
global.require
88
abilityAccessCtrl = requireNapi('abilityAccessCtrl')
9-
} catch (error) {
10-
}
9+
} catch (e) {} // eslint-disable-line no-empty
1110

1211
// @ts-ignore
1312
export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () => {
@@ -36,50 +35,42 @@ export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () =>
3635
try {
3736
albumAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.album)
3837
albumAuthorized = grantStatus(albumAuthorized)
39-
} catch (e) {
40-
}
38+
} catch (e) {} // eslint-disable-line no-empty
4139
let bluetoothAuthorized = 'not determined'
4240
try {
4341
bluetoothAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.bluetooth)
4442
bluetoothAuthorized = grantStatus(bluetoothAuthorized)
45-
} catch (e) {
46-
}
43+
} catch (e) {} // eslint-disable-line no-empty
4744
let cameraAuthorized = 'not determined'
4845
try {
4946
cameraAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.camera)
5047
cameraAuthorized = grantStatus(cameraAuthorized)
51-
} catch (e) {
52-
}
48+
} catch (e) {} // eslint-disable-line no-empty
5349
let locationAuthorized = 'not determined'
5450
try {
5551
locationAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.location)
5652
locationAuthorized = grantStatus(locationAuthorized)
57-
} catch (e) {
58-
}
53+
} catch (e) {} // eslint-disable-line no-empty
5954
let locationAccuracy = 'not determined'
6055
try {
6156
locationAccuracy =
6257
atManager.checkAccessTokenSync(tokenID, permissionsList.locationAccuracy) === 0 ? 'full' : 'reduced'
63-
} catch (e) {
64-
}
58+
} catch (e) {} // eslint-disable-line no-empty
6559
let microphoneAuthorized = 'not determined'
6660
try {
6761
microphoneAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.microphone)
6862
microphoneAuthorized = grantStatus(microphoneAuthorized)
69-
} catch (e) {
70-
}
63+
} catch (e) {} // eslint-disable-line no-empty
7164
let notificationAuthorized = 'not determined'
7265
try {
7366
notificationAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.notification)
7467
notificationAuthorized = grantStatus(notificationAuthorized)
75-
} catch (e) {
76-
}
68+
} catch (e) {} // eslint-disable-line no-empty
7769
let phoneCalendarAuthorized = 'not determined'
7870
try {
7971
phoneCalendarAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.phoneCalendar)
8072
phoneCalendarAuthorized = grantStatus(phoneCalendarAuthorized)
81-
} catch (e) {
82-
}
73+
} catch (e) {} // eslint-disable-line no-empty
8374
const result = {
8475
albumAuthorized,
8576
bluetoothAuthorized,

packages/taro-platform-harmony-hybrid/src/api/apis/base/getSystemSetting/oschannel.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@ let geoLocationManager
66
let wifiManager
77

88
try {
9-
// @ts-ignore
109
display = requireNapi('display')
11-
12-
// @ts-ignore
1310
bluetooth = requireNapi('bluetooth')
14-
15-
// @ts-ignore
1611
geoLocationManager = requireNapi('geoLocationManager')
17-
18-
// @ts-ignore
1912
wifiManager = requireNapi('wifi')
20-
} catch (error) {}
13+
} catch (e) {} // eslint-disable-line no-empty
2114

2215
// @ts-ignore
2316
export const getSystemSetting: typeof Taro.getSystemSetting = () => {

packages/taro-platform-harmony-hybrid/src/api/apis/device/keyBoard/hideKeyboard/oschannel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import Taro from '@tarojs/taro'
33
let inputMethod
44

55
try {
6-
// @ts-ignore
76
inputMethod = requireNapi('inputMethod')
8-
} catch (error) {}
7+
} catch (e) {} // eslint-disable-line no-empty
98

109
export const hideKeyboard:typeof Taro.hideKeyboard = () => {
1110
return new Promise((resolve, reject) => {

packages/taro-platform-harmony-hybrid/src/api/apis/device/phone/oschannel.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import Taro from '@tarojs/api'
33
let call
44

55
try {
6-
// @ts-ignore
76
call = requireNapi('telephony.call')
8-
} catch (error) {}
7+
} catch (e) {} // eslint-disable-line no-empty
98

109
const ErrorCode = {
1110
PARAMETER_ERROR: 202,

packages/taro-platform-harmony-hybrid/types/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ declare module '*.json' {
33
const value: Record<string, any>
44
export default value
55
}
6+
declare var requireNapi: NodeRequire

packages/taro-transformer-wx/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module.exports = {
3232
'no-new-func': 'off',
3333
'no-new': 'off',
3434
'prefer-const': 'off',
35-
'no-empty': 'off',
3635
'no-unsafe-optional-chaining': 'off',
3736
'no-prototype-builtins': 'off',
3837
camelcase: 'off',

packages/taro-transformer-wx/src/render.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ export class RenderParser {
674674
{ parentNode, parentPath, isFinalReturn, isIfStemInLoop }: JSXHandler
675675
) {
676676
if (t.isReturnStatement(parentNode)) {
677-
if (!isFinalReturn && !isIfStemInLoop) {
678-
} else {
677+
if (isFinalReturn || isIfStemInLoop) {
679678
const ifStatement = parentPath.findParent((p) => p.isIfStatement()) as any
680679
const blockStatement = parentPath.findParent(
681680
(p) => p.isBlockStatement() && p.parentPath === ifStatement

packages/taro-transformer-wx/src/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function getSuperClassCode(path: NodePath<t.ClassDeclaration>) {
8484
code,
8585
sourcePath: sourceValue,
8686
}
87-
} catch (error) {}
87+
} catch (e) {} // eslint-disable-line no-empty
8888
}
8989
}
9090

@@ -791,8 +791,8 @@ export function printToLogFile() {
791791

792792
/**
793793
* 将部分 ast 节点转为代码片段
794-
* @param ast
795-
* @returns
794+
* @param ast
795+
* @returns
796796
*/
797797
export function astToCode (ast) {
798798
if (!ast) return ''
@@ -826,7 +826,7 @@ export class IReportError extends Error {
826826

827827
constructor (
828828
message: string,
829-
msgType?: string,
829+
msgType?: string,
830830
filePath?: string | 'JS_FILE' | 'WXML_FILE',
831831
code?: string,
832832
location?: { col: number, row: number } | undefined
@@ -837,4 +837,4 @@ export class IReportError extends Error {
837837
this.code = code || ''
838838
this.location = location || { col: 0, row: 0 }
839839
}
840-
}
840+
}

0 commit comments

Comments
 (0)