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

[Chore, Docs] (How to) Lint tests #171

Open
axmmisaka opened this issue Jun 29, 2023 · 0 comments
Open

[Chore, Docs] (How to) Lint tests #171

axmmisaka opened this issue Jun 29, 2023 · 0 comments

Comments

@axmmisaka
Copy link
Collaborator

axmmisaka commented Jun 29, 2023

Tests are written in a way that eslint is really mad (and sometimes it's necessary). Fixing them simply require too many effort which I believe is not worth it currently, as long as the tests have good coverage.

Also, I am using tsconfig.json as eslint's parserOptions, and tests are not included in the config (which is valid). Nevertheless this will cause some config issue and the best way to fix it is by ignoring the test folder.

Nevertheless that might be an issue in the future and we might want to lint tests. Therefore I am creating this issue for reference and to document how to make eslint lint tests:

  1. Create a file tsconfig.remaining.json that contains the following code:
/**
  * This json is included solely for eslint, as it does not lint files not included in tsconfig.json. 
  * This file includes all remaining ts files not included in tsconfig, such as those in __tests__.
  */
  {
    "include": [
        "./**/*.ts"
    ],
    "exclude": [
        "src/**/*",
    ],
    "extends": "./tsconfig.json",
}
  1. Modify .eslintrc.js to contain such:
  parserOptions: {
-    project: ['./tsconfig.json', ]
+    project: ['./tsconfig.json', './tsconfig.remaining.json']
  },
-  ignorePatterns: ['.eslintrc.js', '__tests__/**/*'],
+  ignorePatterns: ['.eslintrc.js',],
  1. Run npx eslint './__tests__/**/*'
@axmmisaka axmmisaka changed the title [Chore, Docs] Lint tests [Chore, Docs] (How to) Lint tests Jun 29, 2023
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

No branches or pull requests

1 participant