Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract Linting: add lint:types and use @typescript/eslint-parser #35

Closed
0xpatrickdev opened this issue Jan 3, 2024 · 1 comment · Fixed by #103
Closed

Contract Linting: add lint:types and use @typescript/eslint-parser #35

0xpatrickdev opened this issue Jan 3, 2024 · 1 comment · Fixed by #103
Assignees

Comments

@0xpatrickdev
Copy link
Member

Building off of #33, update the eslint configuration to use @typescript/eslint-parser. With this in place, we can use typescript to audit jsdoc typedefs and enable better code navigation (go to definition).

@0xpatrickdev
Copy link
Member Author

See this comments for more details on a suggested eslint configuration: #26 (comment)

Here would be the updated directions from the current answer:

  1. Run:
yarn add -D \
 eslint \
 @agoric/eslint-config@dev \
 @endo/eslint-plugin \
 @jessie.js/eslint-plugin \
  eslint-config-airbnb-base \
 eslint-plugin-jsdoc \
 eslint-config-prettier \
 eslint-plugin-import \
- eslint-plugin-github 
+ eslint-plugin-github \
+ @typescript-eslint/eslint-plugin
+ @typescript-eslint/parser
+ typescript
  1. Add the following to your package.json
 "eslintConfig" : {
+  "env": {
+    "node": true
+  },
+  "parser": "@typescript-eslint/parser",
   "parserOptions": {
-      "sourceType": "module",
-      "ecmaVersion": 6
+    "project": "./tsconfig.json",
+    "sourceType": "module",
+    "ecmaVersion": 2020
   },
   "extends": [
+    "plugin:@typescript-eslint/recommended",
     "@agoric"
   ],
+  "plugins": [
+    "@typescript-eslint",
+    "prettier"
+  ],
+  "rules": {
+    "@typescript-eslint/no-floating-promises": "warn",
+    "no-void": [
+      "error",
+      {
+        "allowAsStatement": true
+      }
+    ],
+    "prettier/prettier": "warn",
+    "@typescript-eslint/no-unused-vars": [
+      "error",
+      {
+        "vars": "all",
+        "args": "all",
+        "argsIgnorePattern": "^_",
+        "varsIgnorePattern": "^_"
+      }
+    ]
+  },
 }
  1. Add a tsconfig.json file (new)
+{
+  "compilerOptions": {
+    "noEmit": true,
+    "target": "esnext",
+    "module": "esnext",
+    "moduleResolution": "node",
+    "skipLibCheck": true,
+    "checkJs": false,
+    "allowJs": true,
+    "allowSyntheticDefaultImports": true,
+    "maxNodeModuleJsDepth": 2,
+    "strict": true
+  },
+  "include": ["**/*.js", "**/*.ts"],
+  "exclude": ["bundles"]
+}
  1. Run yarn eslint '**/*.{js,ts}' (or specify other files/directory globs). Run yarn tsc to lint types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants