Skip to content
New issue

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

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

Already on GitHub? # to your account

ESlint: Allow some unused variables and don't enforce import resolution #2475

Closed
robyngit opened this issue Jul 2, 2024 · 0 comments · Fixed by #2476
Closed

ESlint: Allow some unused variables and don't enforce import resolution #2475

robyngit opened this issue Jul 2, 2024 · 0 comments · Fixed by #2476
Assignees
Labels
enhancement linting & formatting Issues related to eslint and prettier config
Milestone

Comments

@robyngit
Copy link
Member

robyngit commented Jul 2, 2024

Manually fixing linting errors has highlighted a few rules we're currently enforcing that are not suitable for MetacatUI currently:

  • The import/no-unresolved rule needs to be disabled because our project uses RequireJS for module loading, which very challenging to configure with the import resolution checks enforced by this rule. For example, we would need to write something custom to resolve paths configured in the RequireJS configuration.

  • There are cases where it's useful to include unused variables in functions, such as when a function is a callback that doesn't use all of the arguments passed to it. We want to allow unused variables in these cases but still check for unused variables in the rest of the codebase. We can achieve this by allowing unused variables prefixed with an underscore (_). This way, we can indicate that the variable is intentionally unused and avoid linting errors.

Rule overrides to add:

  • "import/no-unresolved": "off"
  • "variables/no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": true, "varsIgnorePattern": "^_" }]
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement linting & formatting Issues related to eslint and prettier config
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant