Skip to content

Commit

Permalink
feat(lint): 更新规则限制
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed May 3, 2024
1 parent c83afef commit 02b845d
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"build:binding:release": "pnpm --filter @tarojs/binding run build",
"format::rs": "cargo fmt --all",
"clear-all": "rimraf **/node_modules",
"lint": "eslint ./packages/ --ext .js,.jsx,.ts,.tsx",
"lint": "eslint ./packages/ --ext .js,.jsx,.ts,.tsx,.mjs,.mts",
"lint:style": "stylelint ./packages/**/*.{css,scss}",
"format": "prettier --write --cache .",
"format:check": "prettier --check --cache .",
Expand Down
1 change: 1 addition & 0 deletions packages/rollup-plugin-copy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import Taro from '@tarojs/api'
let abilityAccessCtrl

try {
// @ts-ignore
global.require
abilityAccessCtrl = requireNapi('abilityAccessCtrl')
} catch (error) {
}
} catch (e) {} // eslint-disable-line no-empty

// @ts-ignore
export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () => {
Expand Down Expand Up @@ -36,50 +35,42 @@ export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () =>
try {
albumAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.album)
albumAuthorized = grantStatus(albumAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let bluetoothAuthorized = 'not determined'
try {
bluetoothAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.bluetooth)
bluetoothAuthorized = grantStatus(bluetoothAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let cameraAuthorized = 'not determined'
try {
cameraAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.camera)
cameraAuthorized = grantStatus(cameraAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let locationAuthorized = 'not determined'
try {
locationAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.location)
locationAuthorized = grantStatus(locationAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let locationAccuracy = 'not determined'
try {
locationAccuracy =
atManager.checkAccessTokenSync(tokenID, permissionsList.locationAccuracy) === 0 ? 'full' : 'reduced'
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let microphoneAuthorized = 'not determined'
try {
microphoneAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.microphone)
microphoneAuthorized = grantStatus(microphoneAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let notificationAuthorized = 'not determined'
try {
notificationAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.notification)
notificationAuthorized = grantStatus(notificationAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
let phoneCalendarAuthorized = 'not determined'
try {
phoneCalendarAuthorized = atManager.checkAccessTokenSync(tokenID, permissionsList.phoneCalendar)
phoneCalendarAuthorized = grantStatus(phoneCalendarAuthorized)
} catch (e) {
}
} catch (e) {} // eslint-disable-line no-empty
const result = {
albumAuthorized,
bluetoothAuthorized,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ let geoLocationManager
let wifiManager

try {
// @ts-ignore
display = requireNapi('display')

// @ts-ignore
bluetooth = requireNapi('bluetooth')

// @ts-ignore
geoLocationManager = requireNapi('geoLocationManager')

// @ts-ignore
wifiManager = requireNapi('wifi')
} catch (error) {}
} catch (e) {} // eslint-disable-line no-empty

// @ts-ignore
export const getSystemSetting: typeof Taro.getSystemSetting = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import Taro from '@tarojs/taro'
let inputMethod

try {
// @ts-ignore
inputMethod = requireNapi('inputMethod')
} catch (error) {}
} catch (e) {} // eslint-disable-line no-empty

export const hideKeyboard:typeof Taro.hideKeyboard = () => {
return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import Taro from '@tarojs/api'
let call

try {
// @ts-ignore
call = requireNapi('telephony.call')
} catch (error) {}
} catch (e) {} // eslint-disable-line no-empty

const ErrorCode = {
PARAMETER_ERROR: 202,
Expand Down
1 change: 1 addition & 0 deletions packages/taro-platform-harmony-hybrid/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ declare module '*.json' {
const value: Record<string, any>
export default value
}
declare var requireNapi: NodeRequire
1 change: 0 additions & 1 deletion packages/taro-transformer-wx/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = {
'no-new-func': 'off',
'no-new': 'off',
'prefer-const': 'off',
'no-empty': 'off',
'no-unsafe-optional-chaining': 'off',
'no-prototype-builtins': 'off',
camelcase: 'off',
Expand Down
3 changes: 1 addition & 2 deletions packages/taro-transformer-wx/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@ export class RenderParser {
{ parentNode, parentPath, isFinalReturn, isIfStemInLoop }: JSXHandler
) {
if (t.isReturnStatement(parentNode)) {
if (!isFinalReturn && !isIfStemInLoop) {
} else {
if (isFinalReturn || isIfStemInLoop) {
const ifStatement = parentPath.findParent((p) => p.isIfStatement()) as any
const blockStatement = parentPath.findParent(
(p) => p.isBlockStatement() && p.parentPath === ifStatement
Expand Down
10 changes: 5 additions & 5 deletions packages/taro-transformer-wx/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function getSuperClassCode(path: NodePath<t.ClassDeclaration>) {
code,
sourcePath: sourceValue,
}
} catch (error) {}
} catch (e) {} // eslint-disable-line no-empty
}
}

Expand Down Expand Up @@ -791,8 +791,8 @@ export function printToLogFile() {

/**
* 将部分 ast 节点转为代码片段
* @param ast
* @returns
* @param ast
* @returns
*/
export function astToCode (ast) {
if (!ast) return ''
Expand Down Expand Up @@ -826,7 +826,7 @@ export class IReportError extends Error {

constructor (
message: string,
msgType?: string,
msgType?: string,
filePath?: string | 'JS_FILE' | 'WXML_FILE',
code?: string,
location?: { col: number, row: number } | undefined
Expand All @@ -837,4 +837,4 @@ export class IReportError extends Error {
this.code = code || ''
this.location = location || { col: 0, row: 0 }
}
}
}

0 comments on commit 02b845d

Please sign in to comment.