Skip to content

Commit

Permalink
all: update eslint / prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland committed Jul 19, 2024
1 parent 2548bd7 commit 1f6d350
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 264 deletions.
103 changes: 103 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import prettier from "eslint-plugin-prettier";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
).map(config => ({files: ["**/*.ts"], ...config})), {
plugins: {
"@typescript-eslint": typescriptEslint,
prettier,
"simple-import-sort": simpleImportSort,
},

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
self: true,
},

parser: tsParser,
},

settings: {
"import/resolver": {
node: {
extensions: [".js", ".json", ".ts"],
},
},
},

rules: {
"no-console": 0,

"max-len": ["error", {
code: 140,
ignoreUrls: true,
}],

"prefer-template": "off",
"arrow-body-style": "off",
"padded-blocks": "off",
"class-methods-use-this": "off",
"no-else-return": "off",
"lines-between-class-members": "off",
"no-param-reassign": "off",
"no-return-assign": "off",
"no-plusplus": "off",
"prefer-destructuring": "off",
"sort-imports": "off",
"simple-import-sort/imports": "warn",
"no-restricted-globals": "off",

"@typescript-eslint/explicit-function-return-type": ["warn", {
allowExpressions: true,
}],

"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-member-accessibility": "error",

"@typescript-eslint/no-inferrable-types": ["error", {
ignoreParameters: true,
ignoreProperties: true,
}],

"@typescript-eslint/no-explicit-any": ["warn", {
fixToUnknown: true,
}],

"@typescript-eslint/no-unused-vars": ["warn", {
argsIgnorePattern: "^_",
}],

"prettier/prettier": "warn",
},
}, {
files: ["**/*.test.ts"],

languageOptions: {
globals: {
window: true,
},
},

rules: {
"import/first": 0,
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
},
}];
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@
"react-native": "*"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@types/jest": "^27.0.2",
"@types/react": "^17.0.33",
"@types/react-native": "^0.66.1",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"eslint": "^9.7.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"expo-module-scripts": "^3.5.2",
"globals": "^15.8.0",
"jest": "^27.3.1",
"prettier": "^1.14.2",
"prettier": "^3.3.3",
"react-native": "^0.66.1",
"ts-jest": "^27.0.7",
"typedoc": "^0.22.7",
Expand Down
3 changes: 2 additions & 1 deletion src/BatchInboxFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const parseNotifications = (notifications: IInboxNotification[]): IInboxNotifica
return notifications.map(notification => {
if (!notification.payload) return notification;

const batchPayload = notification.payload['com.batch'];
const batchPayload = notification.payload['com.batch'] as string;

// Try parsing the raw batch payload
try {
Expand All @@ -114,6 +114,7 @@ const parseNotifications = (notifications: IInboxNotification[]): IInboxNotifica
},
};
} catch (error) {
console.warn('Failed parsing notification.', error);
return notification;
}
});
Expand Down
5 changes: 4 additions & 1 deletion src/BatchUserAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export enum BatchUserAttributeType {
}

export class BatchUserAttribute {
public constructor(private _type: BatchUserAttributeType, private _value: unknown) {}
public constructor(
private _type: BatchUserAttributeType,
private _value: unknown
) {}

public getType(): BatchUserAttributeType {
return this._type;
Expand Down
Loading

0 comments on commit 1f6d350

Please sign in to comment.