Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Achaak committed Nov 24, 2022
1 parent 2104bfd commit 699000c
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 383 deletions.
2 changes: 1 addition & 1 deletion apps/app/src/server/routers/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const publicProcedure = t.procedure;
* users are logged in
*/
const isAuth = t.middleware(async ({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) {
if (!ctx?.session?.user) {
throw new TRPCError({ code: 'UNAUTHORIZED' });
}
return next({
Expand Down
2 changes: 1 addition & 1 deletion packages/database/src/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const DEFAULT_USERS = [
name: 'Tim Apple',
email: 'tim@apple.com',
},
] as Partial<User>[];
] as Array<Partial<User>>;

const seed = async (): Promise<void> => {
try {
Expand Down
271 changes: 143 additions & 128 deletions packages/eslint-config-custom/index.cjs
Original file line number Diff line number Diff line change
@@ -1,136 +1,151 @@
const path = require("path");

module.exports = {
env: {
browser: true,
es2022: true,
node: true,
jest: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
"plugin:github/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"turbo",
"prettier",
"plugin:prettier/recommended",
],
ignorePatterns: [
"node_modules",
"build",
"dist",
"public"
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.json", "./__tests__/tsconfig.json"],
sourceType: "module",
},
plugins: [
"@typescript-eslint",
"github",
"json-format",
"promise",
"import",
"prettier",
],
settings: {
"import/resolver": {
typescript: true,
node: true,
},
},
rules: {
env: {
browser: true,
es2022: true,
node: true,
jest: true,
},
globals: {
NodeJS: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking",
// "plugin:@typescript-eslint/strict",
"plugin:github/typescript",
"plugin:import/recommended",
"plugin:import/typescript",
"turbo",
"prettier",
"plugin:prettier/recommended",
],
ignorePatterns: ["node_modules", "build", "dist", "public"],
parser: "@typescript-eslint/parser",
parserOptions: {
// Use relative project path to avoid issues with monorepos
project: ["./tsconfig.json", "./*/tsconfig.json"],
sourceType: "module",
},
plugins: [
"@typescript-eslint",
"github",
"json-format",
"promise",
"import",
"prettier",
],
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
// "project": [
// "packages/*/tsconfig.json",
// "other-packages/*/tsconfig.json"
// ]
},
},
},
rules: {
// ESLint
"prefer-const": "error",
eqeqeq: "error",
"lines-between-class-members": "error",
curly: "error",
"no-constant-condition": "error",
"linebreak-style": ["error", "unix"],
semi: ["error", "always"],
"func-style": ["error", "expression"],
"no-extra-semi": "error",
"default-case": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-console": "warn",
"no-misleading-character-class": "error",
"no-multi-assign": "error",
"no-multi-str": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-object": "error",
"no-new-symbol": "error",
"no-new-wrappers": "error",
"no-obj-calls": "error",
"no-path-concat": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-sparse-arrays": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-this-before-super": "error",
"no-unreachable-loop": "error",
'no-unused-vars': "off",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"symbol-description": "error",
"arrow-body-style": ["error", "as-needed"],

// Import
"import/no-unresolved": "error",
"import/no-duplicates": ["error", { considerQueryString: true }],
"import/default": "error",
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
"import/named": "off",
"import/namespace": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
//
"prefer-const": "error",
eqeqeq: "error",
// "import/extensions": ["error", "ignorePackages"], ONLY ESM


// typescript-eslint
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/method-signature-style": "error",
// "@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-dynamic-delete": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
// "@typescript-eslint/no-unnecessary-condition": "error",
// "@typescript-eslint/no-unnecessary-qualifier": "error",
// "@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
// "@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/sort-type-union-intersection-members": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/brace-style": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/default-param-last": "error",

// Github
"filenames/match-regex": 0,
"github/no-then": 0,

// Prettier
"prettier/prettier": "error",
"lines-between-class-members": "error",
curly: "error",
"no-constant-condition": "error",
"linebreak-style": ["error", "unix"],
semi: ["error", "always"],
"func-style": ["error", "expression"],
"no-extra-semi": "error",
"default-case": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-console": "warn",
"no-misleading-character-class": "error",
"no-multi-assign": "error",
"no-multi-str": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-object": "error",
"no-new-symbol": "error",
"no-new-wrappers": "error",
"no-obj-calls": "error",
"no-path-concat": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-this-before-super": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"symbol-description": "error",
"import/no-duplicates": ["error", { considerQueryString: true }],
"no-unreachable-loop": "error",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-dynamic-delete": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/sort-type-union-intersection-members": "error",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/brace-style": "error",
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/default-param-last": "error",
"arrow-body-style": ["error", "as-needed"],
"filenames/match-regex": 0,
"github/no-then": 0,
"eslint-comments/no-use": 0,
"import/default": "error",
// "import/extensions": ["error", "ignorePackages"], ONLY ESM
"i18n-text/no-en": 0,
},
},
};
20 changes: 10 additions & 10 deletions packages/eslint-config-custom/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "eslint-config-custom",
"version": "0.0.0",
"main": "index.cjs",
"license": "MIT",
"main": "index.cjs",
"scripts": {
"clean": "rm -rf .turbo node_modules"
},
"devDependencies": {
"@next/eslint-plugin-next": "13.0.1",
"@typescript-eslint/eslint-plugin": "5.42.0",
"@typescript-eslint/parser": "5.42.0",
"eslint": "8.26.0",
"eslint-config-next": "^13.0.1",
"@next/eslint-plugin-next": "13.0.4",
"@typescript-eslint/eslint-plugin": "5.44.0",
"@typescript-eslint/parser": "5.44.0",
"eslint": "8.28.0",
"eslint-config-next": "^13.0.2",
"eslint-config-prettier": "^8.5.0",
"eslint-config-turbo": "^0.0.4",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-github": "^4.4.0",
"eslint-plugin-github": "^4.4.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-json-format": "^2.0.1",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "7.31.10",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0",
"prettier": "^2.7.1",
"typescript": "^4.8.4"
"prettier": "^2.8.0",
"typescript": "4.9.3"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit 699000c

Please sign in to comment.