Rework configs using tseslint InfiniteArray
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
import js from "@eslint/js";
|
||||
import type { Linter } from "eslint";
|
||||
import { globalIgnores } from "eslint/config";
|
||||
import type { FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const baseConfigs = [
|
||||
{ ignores: ["dist", "node_modules", "**/*.d.ts"] } satisfies Pick<Linter.Config, "ignores">,
|
||||
export const baseConfigs: FlatConfig.ConfigArray = [
|
||||
{ files: ["**/*.js", "**/*.mjs", "**/*.ts", "**/*.tsx"] },
|
||||
globalIgnores([
|
||||
".turbo/",
|
||||
"**/dist/",
|
||||
"**/node_modules/",
|
||||
"**/__generated__/",
|
||||
"**/*.d.ts",
|
||||
]),
|
||||
js.configs.recommended,
|
||||
];
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
||||
import { importX } from "eslint-plugin-import-x";
|
||||
import type { FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const importsConfigs = [
|
||||
export const importsConfigs: FlatConfig.ConfigArray = [
|
||||
importX.flatConfigs.recommended,
|
||||
{
|
||||
...importX.flatConfigs.typescript,
|
||||
settings: {
|
||||
"import-x/resolver-next": createTypeScriptImportResolver({
|
||||
alwaysTryTypes: true,
|
||||
project: "tsconfig.json",
|
||||
}),
|
||||
},
|
||||
},
|
||||
importX.flatConfigs.typescript,
|
||||
{
|
||||
rules: {
|
||||
"import-x/order": [
|
||||
@@ -37,5 +30,11 @@ export const importsConfigs = [
|
||||
},
|
||||
],
|
||||
},
|
||||
settings: {
|
||||
"import-x/resolver-next": createTypeScriptImportResolver({
|
||||
alwaysTryTypes: true,
|
||||
project: "tsconfig.json",
|
||||
}),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { baseConfigs } from "./baseConfigs.ts";
|
||||
import { browserLanguageOptionsConfig, nodeLanguageOptionsConfig } from "./languageOptionsConfigs.ts";
|
||||
import { tsConfigs } from "./tsConfigs.ts";
|
||||
import { importsConfigs } from "./importsConfigs.ts";
|
||||
import { browserLanguageOptionsConfigs, nodeLanguageOptionsConfigs } from "./languageOptionsConfigs.ts";
|
||||
import { reactConfigs } from "./reactConfigs.ts";
|
||||
import { stylisticConfigs } from "./stylisticConfigs.ts";
|
||||
import { importsConfigs } from "./importsConfigs.ts";
|
||||
import { tsConfigs } from "./tsConfigs.ts";
|
||||
|
||||
export const configs = {
|
||||
base: baseConfigs,
|
||||
imports: importsConfigs,
|
||||
ts: tsConfigs,
|
||||
languageOptions: {
|
||||
browser: browserLanguageOptionsConfig,
|
||||
node: nodeLanguageOptionsConfig,
|
||||
},
|
||||
react: reactConfigs,
|
||||
stylistic: stylisticConfigs,
|
||||
languageOptions: {
|
||||
browser: browserLanguageOptionsConfigs,
|
||||
node: nodeLanguageOptionsConfigs,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
import type { Linter } from "eslint";
|
||||
import * as globals from "globals";
|
||||
import globals from "globals";
|
||||
import type { FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const browserLanguageOptionsConfig = {
|
||||
languageOptions: {
|
||||
// Same as the ones we use in our tsconfig compilerOptions.lib for browser
|
||||
ecmaVersion: 2022,
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2022,
|
||||
},
|
||||
sourceType: "module",
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
export const browserLanguageOptionsConfigs: FlatConfig.ConfigArray = [
|
||||
{
|
||||
languageOptions: {
|
||||
// Same as the ones we use in our tsconfig compilerOptions.lib for browser
|
||||
ecmaVersion: 2022,
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.es2022,
|
||||
},
|
||||
sourceType: "module",
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies Pick<Linter.Config, "languageOptions">;
|
||||
];
|
||||
|
||||
export const nodeLanguageOptionsConfig = {
|
||||
languageOptions: {
|
||||
// Same as the ones we use in our tsconfig compilerOptions.lib for node
|
||||
ecmaVersion: 2023,
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.es2023,
|
||||
},
|
||||
sourceType: "module",
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
export const nodeLanguageOptionsConfigs: FlatConfig.ConfigArray = [
|
||||
{
|
||||
languageOptions: {
|
||||
// Same as the ones we use in our tsconfig compilerOptions.lib for node
|
||||
ecmaVersion: 2023,
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.es2023,
|
||||
},
|
||||
sourceType: "module",
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
ecmaFeatures: {
|
||||
impliedStrict: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies Pick<Linter.Config, "languageOptions">;
|
||||
];
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import react from "eslint-plugin-react";
|
||||
import * as reactHooks from "eslint-plugin-react-hooks";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import type { FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const reactConfigs = [
|
||||
export const reactConfigs: FlatConfig.ConfigArray = [
|
||||
{
|
||||
...react.configs.flat.recommended,
|
||||
...react.configs.flat["jsx-runtime"],
|
||||
...reactHooks.configs.flat.recommended,
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
},
|
||||
},
|
||||
},
|
||||
reactHooks.configs.flat.recommended,
|
||||
];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import stylistic from "@stylistic/eslint-plugin";
|
||||
import type { Linter } from "eslint";
|
||||
import type { FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const stylisticConfigs = [
|
||||
export const stylisticConfigs: FlatConfig.ConfigArray = [
|
||||
stylistic.configs.customize({
|
||||
arrowParens: false, // Will actually set it to "as-needed"
|
||||
blockSpacing: true,
|
||||
@@ -28,5 +28,5 @@ export const stylisticConfigs = [
|
||||
},
|
||||
],
|
||||
},
|
||||
} satisfies Linter.Config,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import type { Linter } from "eslint";
|
||||
import { configs } from "typescript-eslint";
|
||||
import { configs, type FlatConfig } from "typescript-eslint";
|
||||
|
||||
export const tsConfigs = [
|
||||
export const tsConfigs: FlatConfig.ConfigArray = [
|
||||
...configs.recommendedTypeChecked,
|
||||
{
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
@@ -19,10 +17,5 @@ export const tsConfigs = [
|
||||
},
|
||||
],
|
||||
},
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
},
|
||||
},
|
||||
} satisfies Linter.Config,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user