Skip to content

Commit

Permalink
wip: eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
jafin committed Jul 10, 2024
1 parent 1f7462b commit 83e797a
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 819 deletions.
16 changes: 0 additions & 16 deletions .eslintignore

This file was deleted.

164 changes: 0 additions & 164 deletions .eslintrc.cjs

This file was deleted.

186 changes: 186 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import testingLibrary from "eslint-plugin-testing-library";
import react from "eslint-plugin-react";
import prettier from "eslint-plugin-prettier";
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 [{
ignores: [
"**/*.d.ts",
"packages/**/dist/**/*",
"packages/**/public/**/*",
"packages/**/coverage/**/*",
"packages/**/fixtures/**/*",
"**/node_modules",
"public/**/*",
"examples/**/static/**/*",
"examples/**/dist/**/*",
"examples/**/OidcTrustedDomains.js",
"examples/**/OidcServiceWorker.js",
"scripts/**/*",
"**/.github",
"**/.changeset",
"**/vite.config.js",
],
}, ...fixupConfigRules(compat.extends(
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:jsx-a11y/recommended",
"prettier",
)), {
plugins: {
"@typescript-eslint": fixupPluginRules(typescriptEslint),
"simple-import-sort": simpleImportSort,
"testing-library": testingLibrary,
react: fixupPluginRules(react),
prettier,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",

parserOptions: {
project: ["./tsconfig.eslint.json", "./packages/*/tsconfig.eslint.json"],

ecmaFeatures: {
jsx: true,
},

warnOnUnsupportedTypeScriptVersion: true,
},
},

settings: {
react: {
version: "detect",
},

"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
},
},

rules: {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-unused-vars": "off",

"@typescript-eslint/no-unused-vars": ["error", {
argsIgnorePattern: "^_|req|res|next|err|ctx|args|context|info|index|data",
ignoreRestSiblings: true,
}],

"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "warn",
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": "warn",
"no-use-before-define": "off",

"@typescript-eslint/no-use-before-define": ["warn", {
functions: false,
classes: false,
variables: false,
typedefs: false,
}],

"no-unused-expressions": "off",

"@typescript-eslint/no-unused-expressions": ["error", {
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
}],

"@typescript-eslint/triple-slash-reference": "off",

"@typescript-eslint/member-delimiter-style": ["error", {
multiline: {
delimiter: "semi",
requireLast: true,
},

singleline: {
delimiter: "semi",
requireLast: false,
},
}],

camelcase: "off",

"comma-dangle": ["error", {
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "always-multiline",
}],

"array-callback-return": "warn",
"jsx-quotes": ["error", "prefer-double"],
indent: "off",
semi: ["error", "always"],
"space-before-function-paren": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/default": "off",
"import/named": "off",
"import/namespace": "off",
"import/no-unresolved": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"react/prop-types": "off",
"react/jsx-wrap-multilines": "error",
"react/react-in-jsx-scope": "off",
"react/display-name": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "off",
},
}, {
files: ["**/*.js", "**/*.jsx"],

rules: {
"@typescript-eslint/no-var-requires": "off",

"react/no-unknown-property": [2, {
ignore: ["jsx", "global"],
}],
},
}, ...compat.extends("plugin:testing-library/react").map(config => ({
...config,
files: ["**/?(*.)+(spec|test).[jt]s?(x)"],
})), {
files: ["**/?(*.)+(spec|test).[jt]s?(x)"],

rules: {
// "testing-library/await-async-query": "error",
// "testing-library/no-await-sync-query": "error",
// "testing-library/no-debugging-utils": "warn",
// "testing-library/no-dom-import": "off",
// "testing-library/no-unnecessary-act": "off",
},
}];
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"format": "prettier --write --cache .",
"lint": "eslint --cache .",
"lint-fix": "eslint --cache --fix .",
"outdated": "pnpm outdated -r",
"outdated": "pnpm outdated --recursive",
"test": "pnpm --if-present --recursive run test ",
"build": "pnpm -r --filter=./packages/* run build"
"build": "pnpm --recursive --filter=./packages/* run build"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "7.9.0",
Expand Down
Loading

0 comments on commit 83e797a

Please sign in to comment.