Enable TypeScript in eslint-plugin-react-forget
Lauren Tan committed
Jun 6, 2023 at 10:56 UTC
359df9e85ccb52357cf35c776a6583513484a8a3
6 files changed
+31
-6
compiler/forget/packages/eslint-plugin-react-forget/__tests__/ReactForgetDiagnostics-test.ts
renamed
compiler/forget/packages/eslint-plugin-react-forget/babel.config.js
+1
-1
@@ -5,4 +5,4 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-module.exports = { presets: ["@babel/preset-env"] };
8
+module.exports = { presets: ["@babel/preset-env", "@babel/preset-typescript"] };
compiler/forget/packages/eslint-plugin-react-forget/package.json
+3
-2
@@ -10,17 +10,18 @@
10
"main": "./lib/index.js",
11
"exports": "./lib/index.js",
12
"scripts": {
13
- "build": ":",
13
+ "build": "tsc",
14
"lint": "npm-run-all \"lint:*\"",
15
"lint:eslint-docs": "npm-run-all \"update:eslint-docs -- --check\"",
16
"lint:js": "eslint .",
17
- "test": "jest",
17
+ "test": "tsc && jest",
18
"update:eslint-docs": "eslint-doc-generator"
19
},
20
"dependencies": {},
21
"devDependencies": {
22
"@babel/preset-env": "^7.22.4",
23
"@babel/preset-typescript": "^7.18.6",
24
+ "@types/node": "^20.2.5",
25
"babel-jest": "^29.0.3",
26
"eslint": "^8.19.0",
27
"eslint-doc-generator": "^1.0.0",
compiler/forget/packages/eslint-plugin-react-forget/src/index.ts
renamed
+1
-1
@@ -9,6 +9,6 @@ import ReactForgetDiagnostics from "./rules/ReactForgetDiagnostics";
9
10
module.exports = {
11
rules: {
12
- "react-forget-diagnoatics": ReactForgetDiagnostics,
12
+ "react-forget-diagnostics": ReactForgetDiagnostics,
13
},
14
};
compiler/forget/packages/eslint-plugin-react-forget/src/rules/ReactForgetDiagnostics.ts
renamed
+6
-2
@@ -5,7 +5,9 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-export default {
8
+import type { Rule } from "eslint";
9
+
10
+const rule: Rule.RuleModule = {
11
meta: {
12
type: "problem",
13
docs: {
@@ -13,7 +15,9 @@ export default {
15
recommended: true,
16
},
17
},
16
- create(context) {
18
+ create(_context: Rule.RuleContext) {
19
return {};
20
},
21
};
22
+
23
+export default rule;
compiler/forget/packages/eslint-plugin-react-forget/tsconfig.json
new
+20
@@ -0,0 +1,20 @@
1
+{
2
+ "extends": "@tsconfig/node16-strictest/tsconfig.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "outDir": "dist",
6
+ "jsx": "react-jsxdev",
7
+
8
+ // weaken strictness from preset
9
+ "importsNotUsedAsValues": "remove",
10
+ "noUncheckedIndexedAccess": false,
11
+ "noUnusedParameters": false,
12
+ "useUnknownInCatchVariables": false,
13
+ "target": "ES2015",
14
+ // ideally turn off only during dev, or on a per-file basis
15
+ "noUnusedLocals": false,
16
+ "sourceMap": true
17
+ },
18
+ "exclude": ["node_modules"],
19
+ "include": ["src/**/*.ts"]
20
+}