From 75d02939387e38e468c69c83ec5ed3be8f814373 Mon Sep 17 00:00:00 2001 From: "Kyle D. McCormick" Date: Wed, 11 Dec 2024 11:23:09 -0500 Subject: [PATCH] build(eslint): Ignore Symlinks and Reduce Violation Limit Background: We have a large number of standing eslint violations in our legacy frontends. Rather than fixing or amnesty-ing all of them, we've opted to use a simple integer limit of violations. Exceeding this limit causes the quality check to fail. Before we moved eslint off of Paver [1], the limit was unreasonably high (probably due to deprecations that removed violation-rich frontend code). This was good, except for the fact that we essentially weren't catching when new violations creeped into the JS code. So, in [1], we lowered the limit down to the lowest possible value, which we thought was 1285. However, we've found that this made the check flaky-- turned out, we have been unintentionally double-counting various violations due to the symlinks in edx-platform. Some of those symlinks' existence is dependent on whether and how `npm ci` and `npm run build` have been run. As a result, 1285 would pass in some contexts, and fail in other contexts. The fix is to simply add all the relevant edx-platform symlinks to .eslintignore. This allows us to lower the violations limit to 734. [1] https://github.com/openedx/edx-platform/pull/35159 --- .eslintignore | 17 ++++++++++++++--- scripts/eslint.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9044a0cc711f..5462574563b4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -20,9 +20,22 @@ test_root/staticfiles common/static/xmodule -# Symlinks into xmodule/js +# Various intra-repo symlinks that we've added over the years to duct-tape the JS build together. +# Ignore them so that we're not double-counting these violations. +cms/static/edx-ui-toolkit cms/static/xmodule_js +lms/static/common +lms/static/course_bookmarks +lms/static/course_experience +lms/static/course_search +lms/static/discussion +lms/static/edx-ui-toolkit +lms/static/learner_profile +lms/static/support +lms/static/teams lms/static/xmodule_js +xmodule/js/common_static +xmodule/js/public/js # Mako templates that generate .js files @@ -64,7 +77,5 @@ xmodule/js/spec/problem/edit_spec_hint.js xmodule/js/spec/problem/edit_spec.js xmodule/js/spec/tabs/edit.js -xmodule/js/public/js -xmodule/assets/*/public/js !**/.eslintrc.js diff --git a/scripts/eslint.py b/scripts/eslint.py index 17179a8ea3ac..3723ada6e219 100644 --- a/scripts/eslint.py +++ b/scripts/eslint.py @@ -25,7 +25,7 @@ def run_eslint(): Runs eslint on static asset directories. If limit option is passed, fails build if more violations than the limit are found. """ - violations_limit = 1285 + violations_limit = 734 command = [ "node",