-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy patheslint.config.mjs
More file actions
138 lines (130 loc) · 4.88 KB
/
Copy patheslint.config.mjs
File metadata and controls
138 lines (130 loc) · 4.88 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
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2026 the VS Code Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import js from "@eslint/js";
import tsESLint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import sonarjs from "eslint-plugin-sonarjs";
import { defineConfig, globalIgnores } from "eslint/config";
import globals from "globals";
import vscodeSwiftPlugin from "./eslint-plugin-vscode-swift/index.mjs";
const baseLanguageOptions = {
ecmaVersion: 2022,
sourceType: "module",
};
export default defineConfig([
globalIgnores([
"./.vscode-test",
"./assets",
"./out",
"./dist",
"./userdocs",
"./src/typings/node-pty.d.ts",
]),
{
files: ["./**/*.{js,mjs}"],
extends: [js.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
...baseLanguageOptions,
globals: globals.node,
},
},
{
files: ["./**/*.ts"],
extends: [
js.configs.recommended,
tsESLint.configs["flat/recommended"],
sonarjs.configs.recommended,
eslintPluginPrettierRecommended,
vscodeSwiftPlugin.configs.recommended,
],
plugins: {
"@typescript-eslint": tsESLint,
},
languageOptions: {
...baseLanguageOptions,
parser: tsParser,
parserOptions: {
project: true,
},
},
rules: {
curly: "error",
eqeqeq: "error",
"no-throw-literal": "error",
"no-console": "error",
"no-restricted-syntax": [
"error",
{
selector: "ImportExpression",
message:
"Dynamic imports using 'import()' are not allowed. Use static imports at the top of the file instead.",
},
{
selector:
"CallExpression[arguments.length=1] > MemberExpression.callee > Identifier.property[name='reduce']",
message:
"Provide initialValue to .reduce(). Otherwise an empty array will throw a 'reduce of empty array with no initial value' error.",
},
{
selector:
"CallExpression[arguments.length=1] > MemberExpression.callee > Identifier.property[name='reduceRight']",
message:
"Provide initialValue to .reduceRight(). Otherwise an empty array will throw a 'reduce of empty array with no initial value' error.",
},
],
"@typescript-eslint/no-floating-promises": ["error", { checkThenables: true }],
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "none",
},
],
"sonarjs/cognitive-complexity": ["error", 15],
"sonarjs/use-type-alias": "off",
"sonarjs/function-return-type": "off",
"sonarjs/slow-regex": "off",
"sonarjs/publicly-writable-directories": "off",
"sonarjs/no-same-argument-assert": "off",
"sonarjs/no-invariant-returns": "off",
"sonarjs/fixme-tag": "off",
"sonarjs/todo-tag": "off",
// These should be progressively enabled over time as we fix the underlying issues
"sonarjs/no-ignored-exceptions": "off",
"sonarjs/no-async-constructor": "off",
// We have our own rule that uses type information from TypeScript to properly detect .only() in tests
"sonarjs/no-exclusive-tests": "off",
},
},
{
files: ["src/documentation/webview/**/*.ts"],
rules: {
"vscode-swift/use-custom-disposable": "off",
},
},
{
files: ["./test/**/*.ts"],
rules: {
"no-console": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-expressions": "off",
},
},
]);