Skip to content

Commit

Permalink
feat: enable react/jsx-no-useless-fragment and `@typescript-eslint/…
Browse files Browse the repository at this point in the history
…no-non-null-assertion` warnings (#541)

* Enable @typescript-eslint/no-non-null-assertion

* Enable react/jsx-no-useless-fragment

* Add tests
  • Loading branch information
sosukesuzuki committed Jan 19, 2022
1 parent dffb83d commit 5dd5077
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module.exports = {
},
],
"react/jsx-wrap-multilines": "warn",
"react/jsx-no-useless-fragment": "warn",

// =======
// None
Expand Down
2 changes: 0 additions & 2 deletions lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module.exports = {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-inferrable-types": "off",
// FIXME use NonNullable<T> instead
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-triple-slash-reference": "off",
"@typescript-eslint/no-unused-vars": "off",
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/react/warning.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const foo = 3;
<>{foo}</>;
3 changes: 3 additions & 0 deletions test/presets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ describe("presets", () => {
await runLintWithFixtures("react", "presets/react.js"),
{
"ok.jsx": {},
"warning.jsx": {
warnings: ["react/jsx-no-useless-fragment", "react/jsx-indent"],
},
}
);
assert.deepStrictEqual(
Expand Down
3 changes: 3 additions & 0 deletions test/react-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ describe("react", () => {
const result = await runLintWithFixtures("react", "presets/react.js");
assert.deepStrictEqual(result, {
"ok.jsx": {},
"warning.jsx": {
warnings: ["react/jsx-no-useless-fragment", "react/jsx-indent"],
},
});
});
});
5 changes: 4 additions & 1 deletion test/react-typescript-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ describe("react-typescript", () => {
errors: ["@typescript-eslint/array-type"],
},
"warning.tsx": {
warnings: ["@typescript-eslint/no-useless-constructor"],
warnings: [
"@typescript-eslint/no-useless-constructor",
"@typescript-eslint/no-non-null-assertion",
],
},
});
});
Expand Down
5 changes: 4 additions & 1 deletion test/typescript-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ describe("typescript", () => {
errors: ["@typescript-eslint/array-type"],
},
"warning.ts": {
warnings: ["@typescript-eslint/no-useless-constructor"],
warnings: [
"@typescript-eslint/no-useless-constructor",
"@typescript-eslint/no-non-null-assertion",
],
},
});
});
Expand Down

0 comments on commit 5dd5077

Please sign in to comment.