diff --git a/packages/eslint-config/baseConfigs.ts b/packages/eslint-config/baseConfigs.ts new file mode 100644 index 000000000..cb8039ae2 --- /dev/null +++ b/packages/eslint-config/baseConfigs.ts @@ -0,0 +1,6 @@ +import * as js from "@eslint/js"; + +export const baseConfigs = [ + { ignores: ["dist", "node_modules", "**/*.d.ts"] }, + js.configs.recommended, +]; diff --git a/packages/eslint-config/languageOptionsConfigs.ts b/packages/eslint-config/languageOptionsConfigs.ts new file mode 100644 index 000000000..0e33fd3b0 --- /dev/null +++ b/packages/eslint-config/languageOptionsConfigs.ts @@ -0,0 +1,35 @@ +import { browser, es2022, es2023, node } from "globals" + +export const browserLanguageOptionsConfig = { + languageOptions: { + // Same as the ones we use in our tsconfig compilerOptions.lib for browser + ecmaVersion: 2022, + globals: { + ...browser, + ...es2022, + }, + sourceType: "module", + parserOptions: { + ecmaFeatures: { + impliedStrict: true, + }, + }, + }, +}; + +export const nodeLanguageOptionsConfig = { + languageOptions: { + // Same as the ones we use in our tsconfig compilerOptions.lib for node + ecmaVersion: 2023, + globals: { + ...node, + ...es2023, + }, + sourceType: "module", + parserOptions: { + ecmaFeatures: { + impliedStrict: true, + }, + }, + }, +}; diff --git a/packages/eslint-config/reactConfigs.ts b/packages/eslint-config/reactConfigs.ts new file mode 100644 index 000000000..903cec617 --- /dev/null +++ b/packages/eslint-config/reactConfigs.ts @@ -0,0 +1,8 @@ +import * as react from "eslint-plugin-react"; +import * as reactHooks from "eslint-plugin-react-hooks"; + +export const reactConfigs = [ + react.configs.flat.recommended, + react.configs.flat["jsx-runtime"], + reactHooks.configs.flat.recommended, +]; diff --git a/packages/eslint-config/stylisticConfigs.ts b/packages/eslint-config/stylisticConfigs.ts new file mode 100644 index 000000000..cc4f7de67 --- /dev/null +++ b/packages/eslint-config/stylisticConfigs.ts @@ -0,0 +1,24 @@ +import stylistic from "@stylistic/eslint-plugin"; + +export const stylisticConfigs = [ + stylistic.configs.customize({ + arrowParens: false, // Will actually set it to "as-needed" + blockSpacing: true, + braceStyle: "1tbs", + commaDangle: "always-multiline", + indent: 2, + quotes: "double", + quoteProps: "consistent-as-needed", + semi: true, + jsx: true, + severity: "error", + }), + { + rules: { + "@stylistic/max-len": [ + "warn", + { code: 120, ignoreUrls: true, ignoreStrings: true }, + ], + }, + }, +]; diff --git a/packages/eslint-config/tsConfigs.ts b/packages/eslint-config/tsConfigs.ts new file mode 100644 index 000000000..867dfb3a8 --- /dev/null +++ b/packages/eslint-config/tsConfigs.ts @@ -0,0 +1,22 @@ +import tseslint from "typescript-eslint"; + +export const tsConfigs = [ + ...tseslint.configs.recommendedTypeChecked, + { + files: ["**/*.{ts,tsx}"], + rules: { + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "all", + "argsIgnorePattern": "^_", + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^_", + "destructuredArrayIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "ignoreRestSiblings": true + }, + ], + }, + }, +]; diff --git a/packages/eslint-config/tsconfig.json b/packages/eslint-config/tsconfig.json new file mode 100644 index 000000000..b74f1124c --- /dev/null +++ b/packages/eslint-config/tsconfig.json @@ -0,0 +1,18 @@ +{ + "complierOptions": { + "lib": ["ES2023"], + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "nodenext", + "moduleDetection": "force", + "verbatimModuleSyntax": true, + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["./*.ts"] +}