Skip to content

Commit af2b13a

Browse files
kristof-matteigithub-actions[bot]
authored andcommitted
fix: ensure basic eslint apply even if eslint-config-love disable them
1 parent 63e9196 commit af2b13a

File tree

2 files changed

+121
-178
lines changed

2 files changed

+121
-178
lines changed

eslint.config.mjs

+83-139
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,74 @@ import prettier from "eslint-plugin-prettier/recommended";
1010
import promise from "eslint-plugin-promise";
1111

1212
import eslintPluginUnicorn from "eslint-plugin-unicorn";
13-
import globals from "globals";
1413
import tseslint from "typescript-eslint";
1514

15+
const sharedRules = {
16+
"arrow-body-style": ["error", "always"],
17+
18+
curly: ["error", "all"],
19+
"eol-last": ["error", "always"],
20+
eqeqeq: ["error", "always"],
21+
22+
"max-len": ["off"],
23+
"no-extra-semi": ["off"],
24+
"no-param-reassign": ["off"],
25+
"no-restricted-imports": [
26+
"error",
27+
{
28+
patterns: [".*"],
29+
},
30+
],
31+
"no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
32+
"no-return-await": ["error"],
33+
"no-shadow": ["error"],
34+
"no-underscore-dangle": ["off"],
35+
"no-unused-expressions": ["error"],
36+
"no-useless-constructor": ["off"],
37+
"object-shorthand": ["error", "always"],
38+
"prefer-template": ["error"],
39+
quotes: [
40+
"error",
41+
"double",
42+
{
43+
allowTemplateLiterals: false,
44+
avoidEscape: true,
45+
},
46+
],
47+
"require-await": ["error"],
48+
"sort-imports": [
49+
"error",
50+
{
51+
ignoreDeclarationSort: true,
52+
},
53+
],
54+
55+
"sort-keys": ["off"],
56+
"unicorn/no-null": ["off"],
57+
"unicorn/prefer-ternary": ["off"],
58+
59+
"import/extensions": [
60+
"error",
61+
"never",
62+
{
63+
json: "always",
64+
},
65+
],
66+
"import/newline-after-import": ["error"],
67+
"import/no-cycle": ["off"],
68+
"import/no-extraneous-dependencies": ["off"],
69+
"import/no-relative-packages": ["error"],
70+
"import/no-unresolved": ["error"],
71+
"import/order": [
72+
"error",
73+
{
74+
alphabetize: { caseInsensitive: true, order: "asc" },
75+
"newlines-between": "always-and-inside-groups",
76+
},
77+
],
78+
"import/prefer-default-export": ["off"],
79+
};
80+
1681
export default tseslint.config(
1782
js.configs.recommended,
1883
{
@@ -46,80 +111,12 @@ export default tseslint.config(
46111
...importPlugin.configs.recommended.rules,
47112
...eslintPluginUnicorn.configs.recommended.rules,
48113

49-
"import/export": ["error"],
50-
"import/first": ["error"],
51-
"import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
52-
"import/no-duplicates": ["error"],
53-
"import/no-named-default": ["error"],
54-
"import/no-webpack-loader-syntax": ["error"],
55-
"arrow-body-style": ["error", "always"],
56-
57-
curly: ["error", "all"],
58-
"eol-last": ["error", "always"],
59-
eqeqeq: ["error", "always"],
60-
61-
"max-len": ["off"],
62-
"no-dupe-keys": ["warn"],
63-
"no-extra-semi": ["off"],
64-
"no-param-reassign": ["off"],
65-
"no-restricted-imports": [
66-
"error",
67-
{
68-
patterns: [".*"],
69-
},
70-
],
71-
"no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
72-
"no-return-await": ["error"],
73-
"no-shadow": ["error"],
74-
"no-underscore-dangle": ["off"],
75-
"no-unused-expressions": ["error"],
76-
"no-useless-constructor": ["off"],
77-
"object-shorthand": ["error", "always"],
78-
"prefer-const": ["error"],
79-
"prefer-template": ["error"],
80-
quotes: [
81-
"error",
82-
"double",
83-
{
84-
allowTemplateLiterals: false,
85-
avoidEscape: true,
86-
},
87-
],
88-
"require-await": ["error"],
89-
"sort-imports": [
90-
"error",
91-
{
92-
ignoreDeclarationSort: true,
93-
},
94-
],
95-
96-
"sort-keys": ["off"],
97-
"unicorn/no-null": ["off"],
98-
"unicorn/prefer-ternary": ["off"],
99-
100-
"import/extensions": [
101-
"error",
102-
"never",
103-
{
104-
json: "always",
105-
},
106-
],
107-
"import/newline-after-import": ["error"],
108-
"import/no-cycle": ["off"],
109-
"import/no-extraneous-dependencies": ["off"],
110-
"import/no-relative-packages": ["error"],
111-
"import/no-unresolved": ["error"],
112-
"import/order": [
113-
"error",
114-
{
115-
alphabetize: { caseInsensitive: true, order: "asc" },
116-
"newlines-between": "always-and-inside-groups",
117-
},
118-
],
119-
"import/prefer-default-export": ["off"],
114+
...sharedRules,
120115
},
121116
},
122117
...tseslint.configs.strictTypeChecked,
118+
...tseslint.configs.recommendedTypeChecked,
119+
...tseslint.configs.stylisticTypeChecked,
123120
{
124121
files: ["**/*.ts", "**/*.tsx"],
125122
ignores: ["**/*.mjs"],
@@ -154,9 +151,11 @@ export default tseslint.config(
154151
rules: {
155152
...importPlugin.configs.typescript.rules,
156153
...love.rules,
154+
...sharedRules,
155+
156+
"no-return-await": ["off"],
157157

158158
"@stylistic/ts/no-extra-semi": ["error"],
159-
"@typescript-eslint/array-type": ["error", { default: "array" }],
160159

161160
"@typescript-eslint/consistent-type-imports": [
162161
"error",
@@ -165,51 +164,14 @@ export default tseslint.config(
165164
fixStyle: "separate-type-imports",
166165
prefer: "type-imports",
167166
},
168-
],
169-
167+
], // different than love
170168
"@typescript-eslint/prefer-destructuring": ["off"],
171-
172169
"@typescript-eslint/explicit-member-accessibility": ["error"],
173-
174170
"@typescript-eslint/explicit-module-boundary-types": ["error"],
175-
176-
"@typescript-eslint/member-ordering": [
177-
"error",
178-
{
179-
default: [
180-
// Index signature
181-
"signature",
182-
// Fields
183-
"private-field",
184-
"public-field",
185-
"protected-field",
186-
// Constructors
187-
"public-constructor",
188-
"protected-constructor",
189-
"private-constructor",
190-
// Methods
191-
"public-method",
192-
"protected-method",
193-
"private-method",
194-
],
195-
},
196-
],
197-
"@typescript-eslint/naming-convention": [
198-
"error",
199-
// {
200-
// format: ["camelCase", "PascalCase", "UPPER_CASE"],
201-
// leadingUnderscore: "allow",
202-
// selector: "variableLike",
203-
// trailingUnderscore: "allow",
204-
// },
205-
{
206-
format: ["camelCase", "PascalCase", "UPPER_CASE"],
207-
selector: "enumMember",
208-
},
209-
],
210-
"@typescript-eslint/no-empty-object-type": ["error"],
211-
"@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true, ignoreRestArgs: false }],
212-
"@typescript-eslint/no-extraneous-class": ["error"],
171+
"@typescript-eslint/member-ordering": ["error"],
172+
"@typescript-eslint/no-empty-object-type": ["error"], // stricter than love
173+
"@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true, ignoreRestArgs: false }], // stricter than love
174+
"@typescript-eslint/no-extraneous-class": ["error"], // stricter than love
213175
"@typescript-eslint/no-magic-numbers": ["off"],
214176
"@typescript-eslint/no-shadow": ["error"],
215177
"@typescript-eslint/no-unused-expressions": [
@@ -220,7 +182,7 @@ export default tseslint.config(
220182
allowTernary: false,
221183
enforceForJSX: false,
222184
},
223-
],
185+
], // stricter than love
224186
"@typescript-eslint/no-unused-vars": [
225187
"error",
226188
{
@@ -230,42 +192,24 @@ export default tseslint.config(
230192
ignoreRestSiblings: false,
231193
vars: "all",
232194
},
233-
],
195+
], // different than love
234196
"@typescript-eslint/parameter-properties": ["error"],
235-
"@typescript-eslint/prefer-for-of": ["error"],
236-
237-
"@typescript-eslint/prefer-regexp-exec": ["warn"],
238-
"@typescript-eslint/prefer-string-starts-ends-with": ["error"],
239197
"@typescript-eslint/promise-function-async": ["off"],
240-
"@typescript-eslint/require-await": ["error"],
241198

242-
"@typescript-eslint/unified-signatures": ["error"],
199+
"@typescript-eslint/return-await": ["error", "in-try-catch"],
243200

244-
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
201+
"@typescript-eslint/require-await": ["error"],
245202

246-
"n/handle-callback-err": ["error", "^(err|error)$"],
247-
"n/no-callback-literal": ["error"],
248-
"n/no-deprecated-api": ["error"],
249-
"n/no-exports-assign": ["error"],
250-
"n/no-new-require": ["error"],
251-
"n/no-path-concat": ["error"],
252-
"n/process-exit-as-throw": ["error"],
203+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
253204

254205
"perfectionist/sort-intersection-types": ["error"],
255206
"perfectionist/sort-union-types": ["error"],
256-
257-
"promise/param-names": ["error"],
258207
},
259208
},
260209

261210
{
262211
extends: [tseslint.configs.disableTypeChecked],
263-
files: ["*.js", "*.mjs"],
264-
languageOptions: {
265-
globals: {
266-
...globals.node,
267-
},
268-
},
212+
files: ["*.mjs"],
269213
rules: {},
270214
},
271215
prettier,

src/output-parser.ts

+38-39
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,44 @@ export class OutputParser {
3636
return [...this._uniqueAnnotations.values()];
3737
}
3838

39+
public static parseCargoJson(line: string): Message | null {
40+
try {
41+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- I am not checking each property manually
42+
return JSON.parse(line) as Message;
43+
} catch {
44+
return null;
45+
}
46+
}
47+
48+
public static validateMessageIsCargoMessage(contents: CargoMessage): contents is CompilerMessage {
49+
if (contents.reason !== "compiler-message") {
50+
core.debug(`Unexpected reason field, ignoring it: ${contents.reason}`);
51+
return false;
52+
}
53+
54+
if (contents.message?.code === undefined || contents.message.code === null) {
55+
core.debug("Message code is missing, ignoring it");
56+
return false;
57+
}
58+
59+
return true;
60+
}
61+
62+
private static parseLevel(level: string): AnnotationLevel {
63+
switch (level) {
64+
case "help":
65+
case "note": {
66+
return AnnotationLevel.Notice;
67+
}
68+
case "warning": {
69+
return AnnotationLevel.Warning;
70+
}
71+
default: {
72+
return AnnotationLevel.Error;
73+
}
74+
}
75+
}
76+
3977
public tryParseClippyLine(line: string): void {
4078
const message = OutputParser.parseCargoJson(line);
4179

@@ -84,45 +122,6 @@ export class OutputParser {
84122

85123
this._uniqueAnnotations.set(key, parsedAnnotation);
86124
}
87-
88-
public static parseCargoJson(line: string): Message | null {
89-
try {
90-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- I am not checking each property manually
91-
return JSON.parse(line) as Message;
92-
} catch {
93-
return null;
94-
}
95-
}
96-
97-
public static validateMessageIsCargoMessage(contents: CargoMessage): contents is CompilerMessage {
98-
if (contents.reason !== "compiler-message") {
99-
core.debug(`Unexpected reason field, ignoring it: ${contents.reason}`);
100-
return false;
101-
}
102-
103-
if (contents.message?.code === undefined || contents.message.code === null) {
104-
core.debug("Message code is missing, ignoring it");
105-
return false;
106-
}
107-
108-
return true;
109-
}
110-
111-
private static parseLevel(level: string): AnnotationLevel {
112-
switch (level) {
113-
case "help":
114-
case "note": {
115-
return AnnotationLevel.Notice;
116-
}
117-
case "warning": {
118-
return AnnotationLevel.Warning;
119-
}
120-
default: {
121-
return AnnotationLevel.Error;
122-
}
123-
}
124-
}
125-
126125
/// Convert parsed JSON line into the GH annotation object
127126
///
128127
/// https://developer.github.com/v3/checks/runs/#annotations-object

0 commit comments

Comments
 (0)