Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
162 lines (155 loc) · 4.27 KB
/
Copy patheslint.config.js
File metadata and controls
162 lines (155 loc) · 4.27 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
import eslint from "@eslint/js";
import vitest from "@vitest/eslint-plugin";
import jsdoc from "eslint-plugin-jsdoc";
import jsonc from "eslint-plugin-jsonc";
import markdown from "eslint-plugin-markdown";
import n from "eslint-plugin-n";
import packageJson from "eslint-plugin-package-json";
import perfectionist from "eslint-plugin-perfectionist";
import * as regexp from "eslint-plugin-regexp";
import yml from "eslint-plugin-yml";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";
export default defineConfig(
{
ignores: [
"coverage*",
"docs/generated",
"lib",
"node_modules",
"pnpm-lock.yaml",
"**/*.snap",
],
},
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
},
eslint.configs.recommended,
...jsonc.configs["flat/recommended-with-json"],
...markdown.configs.recommended,
...yml.configs["flat/recommended"],
...yml.configs["flat/prettier"],
comments.recommended,
jsdoc.configs["flat/contents-typescript-error"],
jsdoc.configs["flat/logical-typescript-error"],
jsdoc.configs["flat/stylistic-typescript-error"],
n.configs["flat/recommended"],
packageJson.configs["recommended-publishable"],
packageJson.configs.stylistic,
perfectionist.configs["recommended-natural"],
regexp.configs["flat/recommended"],
{
extends: [
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
files: ["**/*.js", "**/*.ts"],
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.*s", "eslint.config.js"],
},
// eslint-disable-next-line n/no-unsupported-features/node-builtins
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"no-restricted-syntax": [
"error",
// Forbid default import from "typescript"
{
message: 'Default import from "typescript" is not allowed.',
selector:
'ImportDeclaration[source.value="typescript"] > ImportDefaultSpecifier',
},
],
// These off-by-default rules work well for this repo and we like them on.
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"operator-assignment": "error",
// These on-by-default rules don't work well for this repo and we like them off.
"jsdoc/lines-before-block": "off",
"jsdoc/text-escaping": "off",
"n/no-missing-import": "off",
"no-constant-condition": "off",
// These on-by-default rules work well for this repo if configured
"jsdoc/check-tag-names": ["error", { definedTags: ["category"] }],
"perfectionist/sort-objects": [
"error",
{
order: "asc",
partitionByComment: true,
type: "natural",
},
],
// Stylistic concerns that don't interfere with Prettier
"no-useless-rename": "error",
"object-shorthand": "error",
// TODO?
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/prefer-literal-enum-member": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
},
},
{
files: ["*.jsonc"],
rules: {
"jsonc/comma-dangle": "off",
"jsonc/no-comments": "off",
"jsonc/sort-keys": "error",
},
},
{
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.md/*.ts"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
"n/no-missing-import": [
"error",
{ allowModules: ["notion-rich-text-to-markdown", "ts-api-utils"] },
],
},
},
{
files: ["**/*.test.*"],
languageOptions: {
globals: vitest.environments.env.globals,
},
plugins: { vitest },
rules: {
...vitest.configs.recommended.rules,
// These on-by-default rules aren't useful in test files.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
{
files: ["**/*.{yml,yaml}"],
rules: {
"yml/file-extension": ["error", { extension: "yml" }],
"yml/sort-keys": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
"yml/sort-sequence-values": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
},
},
);