Skip to content

Don't lint ee_component import paths

Mark Florian requested to merge ignore-ee-component-no-unresolved into master

What does this MR do and why?

Don't lint ee_component import paths

In !85948 (comment 956238056) it was discovered that we don't actually successfully lint these paths anyway.

The reason is that it's not a simple resolve alias, which the import/no-unresolved ESLint rule relies upon to look up paths. We instead use NormalModuleReplacementPlugin to rewrite the path when in FOSS, which that rule does not take into account.

This means that, with FOSS_ONLY=1, the resolved path of app/assets/javascripts/vue_shared/components/empty_component.js is not actually checked.

Since webpack will throw at build time if the path doesn't resolve, we're protected from typos, so this edge case isn't that important.

Another interesting finding that doesn't quite make sense: eslint-module-utils, which import/no-unresolved relies on, only added support for import() calls in v2.6.1 (see https://github.com/import-js/eslint-plugin-import/pull/2026 and https://github.com/import-js/eslint-plugin-import/blob/main/utils/CHANGELOG.md#v261---2021-05-13). See !85948 (merged) for more discussion about this.

Screenshots or screen recordings

n/a

How to set up and validate locally

  1. Run FOSS_ONLY=1 yarn lint:eslint --no-cache app/assets/javascripts/jobs/components/job_app.vue
  2. Observe it passes
  3. Change the import('ee_component/...') call to some invalid path
  4. Run the ESLint command again
  5. Observe it passes
  6. Remove the app/assets/javascripts/vue_shared/components/empty_component.js file
  7. Run the ESLint command again
  8. Observe it passes

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mark Florian

Merge request reports