Use eslint to lint the eslint-config package itself
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
7
packages/eslint-config/src/baseConfigs.ts
Normal file
7
packages/eslint-config/src/baseConfigs.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import js from "@eslint/js";
|
||||
|
||||
export const baseConfigs = [
|
||||
{ ignores: ["dist", "node_modules", "**/*.d.ts"] },
|
||||
{ files: ["**/*.js", "**/*.ts", "**/*.tsx"] },
|
||||
js.configs.recommended,
|
||||
];
|
||||
16
packages/eslint-config/src/index.ts
Normal file
16
packages/eslint-config/src/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { baseConfigs } from "./baseConfigs";
|
||||
import { browserLanguageOptionsConfig, nodeLanguageOptionsConfig } from "./languageOptionsConfigs";
|
||||
import { tsConfigs } from "./tsConfigs";
|
||||
import { reactConfigs } from "./reactConfigs";
|
||||
import { stylisticConfigs } from "./stylisticConfigs";
|
||||
|
||||
export const configs = {
|
||||
base: baseConfigs,
|
||||
ts: tsConfigs,
|
||||
languageOptions: {
|
||||
browser: browserLanguageOptionsConfig,
|
||||
node: nodeLanguageOptionsConfig,
|
||||
},
|
||||
react: reactConfigs,
|
||||
stylistic: stylisticConfigs,
|
||||
};
|
||||
37
packages/eslint-config/src/languageOptionsConfigs.ts
Normal file
37
packages/eslint-config/src/languageOptionsConfigs.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as globals from "globals";
|
||||
|
||||
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 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
8
packages/eslint-config/src/reactConfigs.ts
Normal file
8
packages/eslint-config/src/reactConfigs.ts
Normal file
@@ -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,
|
||||
];
|
||||
25
packages/eslint-config/src/stylisticConfigs.ts
Normal file
25
packages/eslint-config/src/stylisticConfigs.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import stylistic from "@stylistic/eslint-plugin";
|
||||
import { type Linter } from "eslint";
|
||||
|
||||
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 },
|
||||
],
|
||||
},
|
||||
} satisfies Linter.Config,
|
||||
];
|
||||
23
packages/eslint-config/src/tsConfigs.ts
Normal file
23
packages/eslint-config/src/tsConfigs.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { type Linter } from "eslint";
|
||||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
} satisfies Linter.Config,
|
||||
];
|
||||
Reference in New Issue
Block a user