Skip to content

Commit 1f6d350

Browse files
committed
all: update eslint / prettier
1 parent 2548bd7 commit 1f6d350

File tree

5 files changed

+343
-264
lines changed

5 files changed

+343
-264
lines changed

eslint.config.mjs

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
2+
import prettier from "eslint-plugin-prettier";
3+
import simpleImportSort from "eslint-plugin-simple-import-sort";
4+
import globals from "globals";
5+
import tsParser from "@typescript-eslint/parser";
6+
import path from "node:path";
7+
import { fileURLToPath } from "node:url";
8+
import js from "@eslint/js";
9+
import { FlatCompat } from "@eslint/eslintrc";
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all
17+
});
18+
export default [...compat.extends(
19+
"eslint:recommended",
20+
"plugin:@typescript-eslint/recommended",
21+
).map(config => ({files: ["**/*.ts"], ...config})), {
22+
plugins: {
23+
"@typescript-eslint": typescriptEslint,
24+
prettier,
25+
"simple-import-sort": simpleImportSort,
26+
},
27+
28+
languageOptions: {
29+
globals: {
30+
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
31+
self: true,
32+
},
33+
34+
parser: tsParser,
35+
},
36+
37+
settings: {
38+
"import/resolver": {
39+
node: {
40+
extensions: [".js", ".json", ".ts"],
41+
},
42+
},
43+
},
44+
45+
rules: {
46+
"no-console": 0,
47+
48+
"max-len": ["error", {
49+
code: 140,
50+
ignoreUrls: true,
51+
}],
52+
53+
"prefer-template": "off",
54+
"arrow-body-style": "off",
55+
"padded-blocks": "off",
56+
"class-methods-use-this": "off",
57+
"no-else-return": "off",
58+
"lines-between-class-members": "off",
59+
"no-param-reassign": "off",
60+
"no-return-assign": "off",
61+
"no-plusplus": "off",
62+
"prefer-destructuring": "off",
63+
"sort-imports": "off",
64+
"simple-import-sort/imports": "warn",
65+
"no-restricted-globals": "off",
66+
67+
"@typescript-eslint/explicit-function-return-type": ["warn", {
68+
allowExpressions: true,
69+
}],
70+
71+
"@typescript-eslint/interface-name-prefix": "off",
72+
"@typescript-eslint/explicit-member-accessibility": "error",
73+
74+
"@typescript-eslint/no-inferrable-types": ["error", {
75+
ignoreParameters: true,
76+
ignoreProperties: true,
77+
}],
78+
79+
"@typescript-eslint/no-explicit-any": ["warn", {
80+
fixToUnknown: true,
81+
}],
82+
83+
"@typescript-eslint/no-unused-vars": ["warn", {
84+
argsIgnorePattern: "^_",
85+
}],
86+
87+
"prettier/prettier": "warn",
88+
},
89+
}, {
90+
files: ["**/*.test.ts"],
91+
92+
languageOptions: {
93+
globals: {
94+
window: true,
95+
},
96+
},
97+
98+
rules: {
99+
"import/first": 0,
100+
"@typescript-eslint/no-explicit-any": "off",
101+
"@typescript-eslint/no-unused-vars": "off",
102+
},
103+
}];

package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@
3535
"react-native": "*"
3636
},
3737
"devDependencies": {
38+
"@eslint/eslintrc": "^3.1.0",
39+
"@eslint/js": "^9.7.0",
3840
"@types/jest": "^27.0.2",
3941
"@types/react": "^17.0.33",
4042
"@types/react-native": "^0.66.1",
41-
"@typescript-eslint/eslint-plugin": "^5.27.0",
42-
"@typescript-eslint/parser": "^5.27.0",
43-
"eslint": "^8.16.0",
44-
"eslint-plugin-prettier": "^4.0.0",
45-
"eslint-plugin-simple-import-sort": "^7.0.0",
43+
"@typescript-eslint/eslint-plugin": "^7.16.1",
44+
"@typescript-eslint/parser": "^7.16.1",
45+
"eslint": "^9.7.0",
46+
"eslint-plugin-prettier": "^5.2.1",
47+
"eslint-plugin-simple-import-sort": "^12.1.1",
4648
"expo-module-scripts": "^3.5.2",
49+
"globals": "^15.8.0",
4750
"jest": "^27.3.1",
48-
"prettier": "^1.14.2",
51+
"prettier": "^3.3.3",
4952
"react-native": "^0.66.1",
5053
"ts-jest": "^27.0.7",
5154
"typedoc": "^0.22.7",

src/BatchInboxFetcher.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const parseNotifications = (notifications: IInboxNotification[]): IInboxNotifica
102102
return notifications.map(notification => {
103103
if (!notification.payload) return notification;
104104

105-
const batchPayload = notification.payload['com.batch'];
105+
const batchPayload = notification.payload['com.batch'] as string;
106106

107107
// Try parsing the raw batch payload
108108
try {
@@ -114,6 +114,7 @@ const parseNotifications = (notifications: IInboxNotification[]): IInboxNotifica
114114
},
115115
};
116116
} catch (error) {
117+
console.warn('Failed parsing notification.', error);
117118
return notification;
118119
}
119120
});

src/BatchUserAttribute.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ export enum BatchUserAttributeType {
88
}
99

1010
export class BatchUserAttribute {
11-
public constructor(private _type: BatchUserAttributeType, private _value: unknown) {}
11+
public constructor(
12+
private _type: BatchUserAttributeType,
13+
private _value: unknown
14+
) {}
1215

1316
public getType(): BatchUserAttributeType {
1417
return this._type;

0 commit comments

Comments
 (0)