-
-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy patheslint.config.ts
More file actions
121 lines (116 loc) · 3.66 KB
/
eslint.config.ts
File metadata and controls
121 lines (116 loc) · 3.66 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
/*
👋 Hi! This ESLint configuration contains a lot more stuff than many repos'!
You can read from it to see all sorts of linting goodness, but don't worry -
it's not something you need to exhaustively understand immediately. 💙
If you're interested in learning more, see the 'getting started' docs on:
- ESLint: https://eslint.org
- typescript-eslint: https://typescript-eslint.io
*/
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
import eslint from "@eslint/js";
import markdown from "@eslint/markdown";
import vitest from "@vitest/eslint-plugin";
import jsdoc from "eslint-plugin-jsdoc";
import jsonc from "eslint-plugin-jsonc";
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, globalIgnores } from "eslint/config";
import tseslint from "typescript-eslint";
export default defineConfig(
globalIgnores(
["**/*.snap", "coverage", "lib", "node_modules", "pnpm-lock.yaml"],
"Global Ignores",
),
{ linterOptions: { reportUnusedDisableDirectives: "error" } },
{
extends: [
comments.recommended,
eslint.configs.recommended,
jsdoc.configs["flat/contents-typescript-error"],
jsdoc.configs["flat/logical-typescript-error"],
jsdoc.configs["flat/stylistic-typescript-error"],
n.configs["flat/recommended"],
perfectionist.configs["recommended-natural"],
regexp.configs["flat/recommended"],
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
],
files: ["**/*.{js,ts}"],
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.config.*s", "bin/index.js"],
},
},
},
rules: {
// These on-by-default rules work well for this repo if configured
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{ ignorePrimitives: true },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowBoolean: true, allowNullish: true, allowNumber: true },
],
"n/no-unsupported-features/node-builtins": [
"error",
{ allowExperimental: true, ignores: ["import.meta.dirname"] },
],
// Stylistic concerns that don't interfere with Prettier
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"no-useless-rename": "error",
"object-shorthand": "error",
"operator-assignment": "error",
// https://github.com/eslint-community/eslint-plugin-n/issues/472
"n/no-unpublished-bin": "off",
},
settings: { perfectionist: { partitionByComment: true, type: "natural" } },
},
{
extends: [jsonc.configs["flat/recommended-with-json"]],
files: ["**/*.json"],
},
{
extends: [markdown.configs.recommended],
files: ["**/*.md"],
rules: {
// https://github.com/eslint/markdown/issues/294
"markdown/no-missing-label-refs": "off",
},
},
{
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.md/*.ts"],
rules: { "n/no-missing-import": "off" },
},
{
extends: [vitest.configs.recommended],
files: ["**/*.test.*"],
rules: { "@typescript-eslint/no-unsafe-assignment": "off" },
settings: { vitest: { typecheck: true } },
},
{
extends: [yml.configs["flat/standard"], yml.configs["flat/prettier"]],
files: ["**/*.{yml,yaml}"],
rules: {
"yml/file-extension": "error",
"yml/sort-keys": [
"error",
{ order: { type: "asc" }, pathPattern: "^.*$" },
],
"yml/sort-sequence-values": [
"error",
{ order: { type: "asc" }, pathPattern: "^.*$" },
],
},
},
{ extends: [packageJson.configs.recommended], files: ["package.json"] },
);