Skip to content

Commit 21d6f36

Browse files
committed
add oxlint
1 parent 7387723 commit 21d6f36

File tree

5 files changed

+177
-16
lines changed

5 files changed

+177
-16
lines changed

.oxlintrc.json

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": [
4+
"unicorn",
5+
"typescript",
6+
"oxc"
7+
],
8+
"categories": {},
9+
"rules": {
10+
"for-direction": "warn",
11+
"no-async-promise-executor": "warn",
12+
"no-caller": "warn",
13+
"no-class-assign": "warn",
14+
"no-compare-neg-zero": "warn",
15+
"no-cond-assign": "warn",
16+
"no-const-assign": "warn",
17+
"no-constant-binary-expression": "warn",
18+
"no-constant-condition": "warn",
19+
"no-control-regex": "warn",
20+
"no-debugger": "warn",
21+
"no-delete-var": "warn",
22+
"no-dupe-class-members": "warn",
23+
"no-dupe-else-if": "warn",
24+
"no-dupe-keys": "warn",
25+
"no-duplicate-case": "warn",
26+
"no-empty-character-class": "warn",
27+
"no-empty-pattern": "warn",
28+
"no-empty-static-block": "warn",
29+
"no-eval": "warn",
30+
"no-ex-assign": "warn",
31+
"no-extra-boolean-cast": "warn",
32+
"no-func-assign": "warn",
33+
"no-global-assign": "warn",
34+
"no-import-assign": "warn",
35+
"no-invalid-regexp": "warn",
36+
"no-irregular-whitespace": "warn",
37+
"no-loss-of-precision": "warn",
38+
"no-new-native-nonconstructor": "warn",
39+
"no-nonoctal-decimal-escape": "warn",
40+
"no-obj-calls": "warn",
41+
"no-self-assign": "warn",
42+
"no-setter-return": "warn",
43+
"no-shadow-restricted-names": "warn",
44+
"no-sparse-arrays": "warn",
45+
"no-this-before-super": "warn",
46+
"no-unassigned-vars": "warn",
47+
"no-unsafe-finally": "warn",
48+
"no-unsafe-negation": "warn",
49+
"no-unsafe-optional-chaining": "warn",
50+
"no-unused-expressions": "warn",
51+
"no-unused-labels": "warn",
52+
"no-unused-private-class-members": "warn",
53+
"no-unused-vars": "warn",
54+
"no-useless-backreference": "warn",
55+
"no-useless-catch": "warn",
56+
"no-useless-escape": "warn",
57+
"no-useless-rename": "warn",
58+
"no-with": "warn",
59+
"require-yield": "warn",
60+
"use-isnan": "warn",
61+
"valid-typeof": "warn",
62+
"oxc/bad-array-method-on-arguments": "warn",
63+
"oxc/bad-char-at-comparison": "warn",
64+
"oxc/bad-comparison-sequence": "warn",
65+
"oxc/bad-min-max-func": "warn",
66+
"oxc/bad-object-literal-comparison": "warn",
67+
"oxc/bad-replace-all-arg": "warn",
68+
"oxc/const-comparisons": "warn",
69+
"oxc/double-comparisons": "warn",
70+
"oxc/erasing-op": "warn",
71+
"oxc/missing-throw": "warn",
72+
"oxc/number-arg-out-of-range": "warn",
73+
"oxc/only-used-in-recursion": "warn",
74+
"oxc/uninvoked-array-callback": "warn",
75+
"typescript/await-thenable": "warn",
76+
"typescript/no-array-delete": "warn",
77+
"typescript/no-base-to-string": "warn",
78+
"typescript/no-duplicate-enum-values": "warn",
79+
"typescript/no-duplicate-type-constituents": "warn",
80+
"typescript/no-extra-non-null-assertion": "warn",
81+
"typescript/no-floating-promises": "warn",
82+
"typescript/no-for-in-array": "warn",
83+
"typescript/no-implied-eval": "warn",
84+
"typescript/no-meaningless-void-operator": "warn",
85+
"typescript/no-misused-new": "warn",
86+
"typescript/no-misused-spread": "warn",
87+
"typescript/no-non-null-asserted-optional-chain": "warn",
88+
"typescript/no-redundant-type-constituents": "warn",
89+
"typescript/no-this-alias": "warn",
90+
"typescript/no-unnecessary-parameter-property-assignment": "warn",
91+
"typescript/no-unsafe-declaration-merging": "warn",
92+
"typescript/no-unsafe-unary-minus": "warn",
93+
"typescript/no-useless-empty-export": "warn",
94+
"typescript/no-wrapper-object-types": "warn",
95+
"typescript/prefer-as-const": "warn",
96+
"typescript/require-array-sort-compare": "warn",
97+
"typescript/restrict-template-expressions": "warn",
98+
"typescript/triple-slash-reference": "warn",
99+
"typescript/unbound-method": "warn",
100+
"unicorn/no-await-in-promise-methods": "warn",
101+
"unicorn/no-empty-file": "warn",
102+
"unicorn/no-invalid-fetch-options": "warn",
103+
"unicorn/no-invalid-remove-event-listener": "warn",
104+
"unicorn/no-new-array": "warn",
105+
"unicorn/no-single-promise-in-promise-methods": "warn",
106+
"unicorn/no-thenable": "warn",
107+
"unicorn/no-unnecessary-await": "warn",
108+
"unicorn/no-useless-fallback-in-spread": "warn",
109+
"unicorn/no-useless-length-check": "warn",
110+
"unicorn/no-useless-spread": "warn",
111+
"unicorn/prefer-set-size": "warn",
112+
"unicorn/prefer-string-starts-ends-with": "warn"
113+
},
114+
"settings": {
115+
"jsx-a11y": {
116+
"polymorphicPropName": null,
117+
"components": {},
118+
"attributes": {}
119+
},
120+
"next": {
121+
"rootDir": []
122+
},
123+
"react": {
124+
"formComponents": [],
125+
"linkComponents": []
126+
},
127+
"jsdoc": {
128+
"ignorePrivate": false,
129+
"ignoreInternal": false,
130+
"ignoreReplacesDocs": true,
131+
"overrideReplacesDocs": true,
132+
"augmentsExtendsReplacesDocs": false,
133+
"implementsReplacesDocs": false,
134+
"exemptDestructuredRootsFromChecks": false,
135+
"tagNamePreference": {}
136+
}
137+
},
138+
"env": {
139+
"builtin": true
140+
},
141+
"globals": {},
142+
"ignorePatterns": []
143+
}

.prettierrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module.exports = {
22
bracketSpacing: true,
3-
jsxBracketSameLine: true,
43
singleQuote: true,
54
trailingComma: 'all',
65
};

bun.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@
1010
"@types/invariant": "^2.2.2",
1111
"@types/react-native": "^0.66.8",
1212
"oxlint": "^1.24.0",
13+
"oxlint-tsgolint": "^0.3.0",
1314
"prettier": "^2.7.1",
1415
"typescript": "^3.8.3",
1516
},
1617
},
1718
},
1819
"packages": {
20+
"@oxlint-tsgolint/darwin-arm64": ["@oxlint-tsgolint/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-AoK80jrY1DhqnGtpWCyyUuFBl6smiwHXeW25OimCzOHwVy7MFgMMaVU4LTcMFOD524UI4sIBl7aN3PLPa/X92A=="],
21+
22+
"@oxlint-tsgolint/darwin-x64": ["@oxlint-tsgolint/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-jTvH5xE80KVeExMv2TG1EQ/EpxtfsIx1tL65UY3cwMEScgb5lB5zWYJqTTDeA1873XK4/siHL60l03m21eCzTg=="],
23+
24+
"@oxlint-tsgolint/linux-arm64": ["@oxlint-tsgolint/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-C/Op/gguoLQv20dCmUrnWCcLvlAnymhp+pACTDTe+vr+y1LlCJtFXeespJrUWOF5rXPjOxtPGajiJI82B6hZsA=="],
25+
26+
"@oxlint-tsgolint/linux-x64": ["@oxlint-tsgolint/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-WjWMBY1VduR57lKqId3F3TqN3DRWZRsGm7J3Bd0hoos0x3x+q3wRuvJoFiovVFcswUM+YLIePKZ1582bWxrQvA=="],
27+
28+
"@oxlint-tsgolint/win32-arm64": ["@oxlint-tsgolint/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-6nXOceZrldiZOPPdPFErgrqCeWzI5Xza4C5IzRRnjI1WrqKokho0sJGp9WKqgSIGRuMQ2ITfLy+L5Qs3Ham2mg=="],
29+
30+
"@oxlint-tsgolint/win32-x64": ["@oxlint-tsgolint/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-sHxS4DUIi3P9CL9PXSfj+YtAR8MLTArpVRqb7Vo+ribybHqKWveswookhpI09pyVcQ2Px4ARMFywBkY2tXHRVg=="],
31+
1932
"@oxlint/darwin-arm64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-1Kd2+Ai1ttskhbJR+DNU4Y4YEDyP/cd50nWt2rAe2aE78dMOalaVGps3s8UnJkXpDL9ZqkgOHVDE5Doj2lxatw=="],
2033

2134
"@oxlint/darwin-x64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-/R9VbnuTp7bLIBh6ucDHjx0po0wLQODLqzy+L/Frn5z4ifMVdE63DB+LHO8QAj+WEQleQq3u/MMms7RFPulCLA=="],
@@ -52,6 +65,8 @@
5265

5366
"oxlint": ["[email protected]", "", { "optionalDependencies": { "@oxlint/darwin-arm64": "1.24.0", "@oxlint/darwin-x64": "1.24.0", "@oxlint/linux-arm64-gnu": "1.24.0", "@oxlint/linux-arm64-musl": "1.24.0", "@oxlint/linux-x64-gnu": "1.24.0", "@oxlint/linux-x64-musl": "1.24.0", "@oxlint/win32-arm64": "1.24.0", "@oxlint/win32-x64": "1.24.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.2.0" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint", "oxc_language_server": "bin/oxc_language_server" } }, "sha512-swXlnHT7ywcCApkctIbgOSjDYHwMa12yMU0iXevfDuHlYkRUcbQrUv6nhM5v6B0+Be3zTBMNDGPAMQv0oznzRQ=="],
5467

68+
"oxlint-tsgolint": ["[email protected]", "", { "optionalDependencies": { "@oxlint-tsgolint/darwin-arm64": "0.3.0", "@oxlint-tsgolint/darwin-x64": "0.3.0", "@oxlint-tsgolint/linux-arm64": "0.3.0", "@oxlint-tsgolint/linux-x64": "0.3.0", "@oxlint-tsgolint/win32-arm64": "0.3.0", "@oxlint-tsgolint/win32-x64": "0.3.0" }, "bin": { "tsgolint": "bin/tsgolint.js" } }, "sha512-q4ZI3TXwiBZsku1RzVlIyk09HY0lI33No87b/XIHLAGm6+3BeyW4D0kIcMok//O65Z5xINTJNlSNkazmkgx8pA=="],
69+
5570
"prettier": ["[email protected]", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="],
5671

5772
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q=="],

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"scripts": {
8-
"prepare": "yarn run build",
8+
"prepare": "bun run build",
99
"build": "tsc",
10-
"lint": "eslint src --ext .js,.jsx,.ts,.tsx; prettier --check src"
10+
"lint": "oxlint src && prettier --check src",
11+
"lint:fix": "oxlint src --fix && prettier --write src"
1112
},
1213
"dependencies": {
1314
"invariant": "^2.2.2"
@@ -16,6 +17,7 @@
1617
"@types/invariant": "^2.2.2",
1718
"@types/react-native": "^0.66.8",
1819
"oxlint": "^1.24.0",
20+
"oxlint-tsgolint": "^0.3.0",
1921
"prettier": "^2.7.1",
2022
"typescript": "^3.8.3"
2123
},

src/events/EventManager.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import {
33
NativeEventEmitter,
44
NativeModule,
55
} from 'react-native';
6+
import OSNotification from '../OSNotification';
67
import NotificationWillDisplayEvent from './NotificationWillDisplayEvent';
78
import {
8-
PERMISSION_CHANGED,
9-
SUBSCRIPTION_CHANGED,
10-
USER_STATE_CHANGED,
11-
NOTIFICATION_WILL_DISPLAY,
12-
NOTIFICATION_CLICKED,
139
IN_APP_MESSAGE_CLICKED,
14-
IN_APP_MESSAGE_WILL_DISPLAY,
15-
IN_APP_MESSAGE_WILL_DISMISS,
1610
IN_APP_MESSAGE_DID_DISMISS,
1711
IN_APP_MESSAGE_DID_DISPLAY,
12+
IN_APP_MESSAGE_WILL_DISMISS,
13+
IN_APP_MESSAGE_WILL_DISPLAY,
14+
NOTIFICATION_CLICKED,
15+
NOTIFICATION_WILL_DISPLAY,
16+
PERMISSION_CHANGED,
17+
SUBSCRIPTION_CHANGED,
18+
USER_STATE_CHANGED,
1819
} from './events';
19-
import OSNotification from '../OSNotification';
2020

2121
const eventList = [
2222
PERMISSION_CHANGED,
@@ -62,10 +62,12 @@ export default class EventManager {
6262
* @returns void
6363
*/
6464
addEventListener<T>(eventName: string, handler: (event: T) => void) {
65-
let handlerArray = this.eventListenerArrayMap.get(eventName);
66-
handlerArray && handlerArray.length > 0
67-
? handlerArray.push(handler)
68-
: this.eventListenerArrayMap.set(eventName, [handler]);
65+
const handlerArray = this.eventListenerArrayMap.get(eventName);
66+
if (handlerArray && handlerArray.length > 0) {
67+
handlerArray.push(handler);
68+
} else {
69+
this.eventListenerArrayMap.set(eventName, [handler]);
70+
}
6971
}
7072

7173
/**
@@ -90,7 +92,7 @@ export default class EventManager {
9092

9193
// returns an event listener with the js to native mapping
9294
generateEventListener(eventName: string): EmitterSubscription {
93-
const addListenerCallback = (payload: Object) => {
95+
const addListenerCallback = (payload: object) => {
9496
let handlerArray = this.eventListenerArrayMap.get(eventName);
9597
if (handlerArray) {
9698
if (eventName === NOTIFICATION_WILL_DISPLAY) {

0 commit comments

Comments
 (0)