init commit
This commit is contained in:
88
tooling/eslint/base.ts
Normal file
88
tooling/eslint/base.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import * as path from "node:path";
|
||||
import { includeIgnoreFile } from "@eslint/compat";
|
||||
import eslint from "@eslint/js";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import turboPlugin from "eslint-plugin-turbo";
|
||||
import { defineConfig } from "eslint/config";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
/**
|
||||
* All packages that leverage t3-env should use this rule
|
||||
*/
|
||||
export const restrictEnvAccess = defineConfig(
|
||||
{ ignores: ["**/env.ts"] },
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
||||
rules: {
|
||||
"no-restricted-properties": [
|
||||
"error",
|
||||
{
|
||||
object: "process",
|
||||
property: "env",
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
name: "process",
|
||||
importNames: ["env"],
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export const baseConfig = defineConfig(
|
||||
// Ignore files not tracked by VCS and any config files
|
||||
includeIgnoreFile(path.join(import.meta.dirname, "../../.gitignore")),
|
||||
{ ignores: ["**/*.config.*"] },
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
turbo: turboPlugin,
|
||||
},
|
||||
extends: [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
rules: {
|
||||
...turboPlugin.configs.recommended.rules,
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
"@typescript-eslint/consistent-type-imports": [
|
||||
"warn",
|
||||
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
|
||||
],
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
2,
|
||||
{ checksVoidReturn: { attributes: false } },
|
||||
],
|
||||
"@typescript-eslint/no-unnecessary-condition": [
|
||||
"error",
|
||||
{
|
||||
allowConstantLoopConditions: true,
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
||||
},
|
||||
},
|
||||
{
|
||||
linterOptions: { reportUnusedDisableDirectives: true },
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user