Skip to content

Commit b0fe6c2

Browse files
committed
Extra error with Invalid operand for a '+' operation
1 parent 480ac33 commit b0fe6c2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

eslint.config.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import eslintPluginAstro from 'eslint-plugin-astro';
22
import tseslint from "typescript-eslint";
3-
3+
/** @type {import("@typescript-eslint/utils").TSESLint.FlatConfig.ConfigArray} */
44
export default [
5-
...tseslint.configs.recommended,
5+
{ignores: ["*.config.*"]},
6+
...tseslint.configs.strictTypeChecked,
7+
...tseslint.configs.stylisticTypeChecked,
68
// First issue, eslintPluginAstro MUST be defined after, since it overrides the typescript parser
7-
...eslintPluginAstro.configs['flat/all'],
9+
...eslintPluginAstro.configs["flat/all"],
810
{
911
rules: {
1012
'@typescript-eslint/await-thenable': "error",

src/pages/index.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ const b = 0;
2424
const c = null!;
2525
const d: any = 1;
2626

27-
const element = document.getElementById("my-root")!;
28-
element.offsetLeft += 4;
27+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28+
const element = document.getElementById("myroot")!;
29+
// no error
30+
console.log(element.offsetLeft + 4);
31+
// error Invalid operand for a '+' operation. Operands must each be a number or string. Got `any` @typescript-eslint/restrict-plus-operands
32+
console.log(element.offsetLeft += 4);
2933
console.log(d);
3034
console.log("c");
3135
const container = document.querySelector(".container")!;

0 commit comments

Comments
 (0)