-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.eslintrc.base.js
123 lines (114 loc) · 5.37 KB
/
.eslintrc.base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const fs = require("fs")
module.exports = (dirName, forceTS = false, project = undefined) => {
const enableTS = !!dirName && (forceTS || process.env.ESLINT_TS)
return {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
// https://github.com/typescript-eslint/typescript-eslint/issues/2094
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, // !process.env["TEST_USE_FULL_DIST"] && !process.env["TEST_USE_DIST"],
enableTS,
parser: "@typescript-eslint/parser",
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
...(enableTS ? {
tsconfigRootDir: dirName,
projectService: true,
} : undefined)
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
}, // this loads <rootdir>/tsconfig.json to eslint
},
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
enableTS ? "plugin:@typescript-eslint/recommended-requiring-type-checking" : null,
//"plugin:jest/recommended",
// "plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"plugin:@phaphoso/dprint/recommended"
].filter(x => x !== null),
plugins: ["import", "codegen", "sort-destructure-keys", "unused-imports"],
rules: {
"@phaphoso/dprint/dprint": [
"error",
{
config: {
// The TypeScript configuration of dprint
// See also https://dprint.dev/plugins/typescript/config/,
"indentWidth": 2,
"semiColons": "asi",
"quoteStyle": "alwaysDouble",
"trailingCommas": "never",
"arrowFunction.useParentheses": "force",
"memberExpression.linePerExpression": true,
"binaryExpression.linePerExpression": true,
}
}
],
"no-unexpected-multiline": "off",
"no-restricted-imports": ["error", { "paths": [
{ name: ".", "message": "Please import from the specific file instead. Imports from index in the same directory are almost always wrong (circular)."},
{ name: "./", "message": "Please import from the specific file instead. Imports from index in the same directory are almost always wrong (circular)."},
{ name: "./index", "message": "Please import from the specific file instead. Imports from index in the same directory are almost always wrong (circular)."}
] }],
"@typescript-eslint/consistent-type-imports": "error",
'codegen/codegen': ['error', { presets: require('@effect-app/eslint-codegen-model/dist/presets/barrel') }],
// We like namespaces, where ES modules cannot compete (augmenting existing types)
"@typescript-eslint/no-namespace": "off",
// "@typescript-eslint/no-unused-vars": [
// "error",
// { argsIgnorePattern: "^_", ignoreRestSiblings: true },
// ],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_", "ignoreRestSiblings": true }
],
// functions are alright, the problem is however that the functions may depend on classes or variables defined later...
"@typescript-eslint/no-use-before-define": ["warn", { functions: false, classes: true, variables: true}],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-empty-interface": [
"error",
{
allowSingleExtends: true,
},
],
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
"sort-destructure-keys/sort-destructure-keys": "error", // Mainly to sort render props
// we want to be able to use e.g Effect.gen without having to worry about lint.
"require-yield": "off",
"sort-imports": "off",
"import/first": "error",
//"import/no-cycle": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
// eslint don't understand some imports very well
"import/no-unresolved": "off",
"import/order": "off",
"object-shorthand": "error",
// a nice idea for some parts of the code, but definitely not all.
//"@typescript-eslint/explicit-module-boundary-types": "off",
...(enableTS ? {
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-misused-promises": "warn"
}: undefined)
},
}
}