style: remove eslint with frontend code removal ADR

- Add ADR for frontend code removal
- Drop eslint, as explained in the ADR
This commit is contained in:
Robert Raposa
2025-03-14 02:09:16 -04:00
committed by Feanil Patel
parent e9c52100ef
commit 399be67fc4
21 changed files with 152 additions and 484 deletions

View File

@@ -1,82 +0,0 @@
# Vendor files and generated test artifacts
**/vendor
test_root/staticfiles
# Vendor files living outside the /vendor/ dir
*.min.js
*-min.js
*.nocache.js
**/bootstrap*.js
**/jquery*.js
**/d3*.js
# Translations files
**/static/js/i18n
# Gitignored xmodule stuff
common/static/xmodule
# 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
# Mako templates that generate .js files
cms/djangoapps/pipeline_js/templates
# These are es2015 spec files that used to be in an ignored path.
# Now they live with the rest of the code, but we want to ignore them
# until the surrounding code is es2015 and we have a chance to clean them.
# We need to ignore them here, because es2015 will cause a parse error
# even if we add an eslint-disable line to the file.
cms/static/js/spec/models/course_spec.js
cms/static/js/spec/models/metadata_spec.js
cms/static/js/spec/models/section_spec.js
cms/static/js/spec/models/settings_course_grader_spec.js
cms/static/js/spec/models/settings_grading_spec.js
cms/static/js/spec/models/textbook_spec.js
cms/static/js/spec/models/upload_spec.js
cms/static/js/spec/views/assets_squire_spec.js
cms/static/js/spec/views/course_info_spec.js
cms/static/js/spec/views/metadata_edit_spec.js
cms/static/js/spec/views/textbook_spec.js
cms/static/js/spec/views/upload_spec.js
xmodule/capa/tests/test_files/js/test_problem_display.js
xmodule/capa/tests/test_files/js/test_problem_generator.js
xmodule/capa/tests/test_files/js/test_problem_grader.js
xmodule/capa/tests/test_files/js/xproblem.js
lms/static/js/spec/calculator_spec.js
lms/static/js/spec/courseware_spec.js
lms/static/js/spec/feedback_form_spec.js
lms/static/js/spec/helper.js
lms/static/js/spec/histogram_spec.js
lms/static/js/spec/modules/tab_spec.js
lms/static/js/spec/requirejs_spec.js
xmodule/js/spec/annotatable/display_spec.js
xmodule/js/spec/capa/display_spec.js
xmodule/js/spec/html/edit_spec.js
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

View File

@@ -1,77 +0,0 @@
{
"extends": "@edx/eslint-config",
"globals": { // Try to avoid adding any new globals.
// Old compatibility things and hacks
"edx": true,
"XBlock": true,
// added by Django i18n tools
"gettext": true,
"ngettext": true,
// added by jasmine-jquery
"loadFixtures": true,
"appendLoadFixtures": true,
"readFixtures": true,
"setFixtures": true,
"appendSetFixtures": true,
"spyOnEvent": true,
// used by our requirejs implementation
"RequireJS": true,
// enable jquery
"$": true
},
"rules": {
"func-names": "off",
"indent": ["error", 4],
"react/jsx-indent": ["error", 4],
"react/jsx-indent-props": ["error", 4],
"new-cap": "off",
"no-else-return": "off",
"no-shadow": "error",
"object-curly-spacing": ["error", "never"],
"one-var": "off",
"one-var-declaration-per-line": ["error", "initializations"],
"space-before-function-paren": ["error", "never"],
"strict": "off",
// Temporary Rules (Will be removed one-by-one to minimize file changes)
"block-scoped-var": "off",
"camelcase": "off",
"comma-dangle": "off",
"consistent-return": "off",
"eqeqeq": "off",
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"import/extensions": "off",
"import/no-amd": "off",
"import/no-dynamic-require": "off",
"import/no-unresolved": "off",
"max-len": "off",
"no-console": "off",
"no-lonely-if": "off",
"no-param-reassign": "off",
"no-proto": "off",
"no-prototype-builtins": "off",
"no-redeclare": "off",
"no-restricted-globals": "off",
"no-restricted-syntax": "off",
"no-throw-literal": "off",
"no-undef": "off",
"no-underscore-dangle": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-escape": "off",
"no-var": "off",
"object-shorthand": "off",
"prefer-arrow-callback": "off",
"prefer-destructuring": "off",
"prefer-rest-params": "off",
"prefer-template": "off",
"radix": "off",
"react/prop-types": "off",
"vars-on-top": "off"
}
}

View File

@@ -60,29 +60,28 @@ jobs:
PIP_SRC: ${{ runner.temp }}
run: |
make test-requirements
- name: Install npm
env:
PIP_SRC: ${{ runner.temp }}
run: npm ci
run: npm ci
- name: Install python packages
env:
PIP_SRC: ${{ runner.temp }}
run: |
pip install -e .
- name: Run Quality Tests
env:
PIP_SRC: ${{ runner.temp }}
TARGET_BRANCH: ${{ github.base_ref }}
run: |
make pycodestyle
npm run lint
make xsslint
make pii_check
make check_keywords
- name: Save Job Artifacts
if: always()
uses: actions/upload-artifact@v4

View File

@@ -1,14 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': 'webpack',
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,18 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,10 +1,16 @@
JavaScript in edx-platform
==========================
All frontend code (JavaScript) has been deprecated in edx-platform, in favor of
MFEs. See ADR 0023-frontend-code-and-eslint-removal.rst for details.
This documentation is being left in place until all of the JavaScript code
has been removed.
ES2015
------
All new JavaScript code in edx-platform should be written in ES2015.
All JavaScript code in edx-platform should be written in ES2015.
ES2015 is not a framework or library -- rather, it is the latest and
greatest revision of the JavaScript language itself, natively supported
in all modern browsers and engines. Think of it as JavaScript's
@@ -34,13 +40,7 @@ Adding a New ES2015 Module
~~~~~~~~~~~~~~~~~~~~~~~~~~
Don't mix ES2015 and ES5 modules within directories. If necessary,
create a new directory just for your new file. If you create a new
directory, run the following from edx-platform root to copy over an
appropriate eslint config:
::
cp cms/static/js/features_jsx/.eslintrc.js path/to/your/directory
create a new directory just for your new file.
Give your new file an UpperCamelCase filename, such as
``MyAwesomeModule.js``. If it is a React module, use the ``.jsx``

View File

@@ -303,8 +303,6 @@ We use several tools to analyze code quality. The full set of them is::
make xsslint
make pii_check
make check_keywords
npm run lint
Where ``$PATHS...`` is a list of folders and files to analyze, or nothing if
you would like to analyze the entire codebase (which can take a while).

View File

@@ -0,0 +1,48 @@
Frontend code and ESLint removal
################################
Status
******
Accepted
Context
*******
Over many years work has been underway to extract frontend code from
edx-platform, to be replaced by MFEs.
Additionally, as of March 2025, edx-platform had more than 700 violations in
ESLint.
For more details on the MFE replacement, see:
- Top-level issue for edx-platform: https://github.com/openedx/edx-platform/issues/31620
- The parent issue of the above issue, which includes IDA frontends: https://github.com/openedx/wg-frontend/issues/156
- Details of the replacement MFEs are noted in the `MFE Rewrite Tracker`_.
.. _MFE Rewrite Tracker: https://openedx.atlassian.net/wiki/spaces/COMM/pages/4262363137/MFE+Rewrite+Tracker
Decision
********
Over these years of work, it was decided that all frontend code should
ultimately be removed from edx-platform. Until this time, there has not yet
been a single ADR or DEPR to capture this decision.
This decision record is to document this past decision. It is ok to add
additional links or details over time to clarify how this extraction will be
accomplished, or to one day celebrate its completion.
Additionally, it has been decided to preemptively remove ESLint. This will
ensure that engineers can stay focused on higher priority work, rather than
spending time fixing linting issues in JavaScript that will simply be removed.
This removal is important because github has started posting these violations
in github comments that make this work seem like a priority. At the very least,
these are annoying messages that clutter up PRs.
Consequences
************
We will continue to replace all frontend code in edx-platform with an
appropriate set of MFEs.

View File

@@ -1,19 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
'import/prefer-default-export': 'off',
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,19 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
'import/prefer-default-export': 'off',
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,7 +0,0 @@
{
"rules": {
"comma-dangle": "off",
"object-curly-spacing": "off",
"no-underscore-dangle": "off"
}
}

View File

@@ -1,14 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': 'webpack',
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,18 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,18 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

View File

@@ -1,18 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': {
webpack: {
config: 'webpack.dev.config.js',
},
},
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};

154
package-lock.json generated
View File

@@ -74,13 +74,11 @@
"which-country": "1.0.0"
},
"devDependencies": {
"@edx/eslint-config": "^4.0.0",
"@edx/mockprock": "github:openedx/mockprock#d70b05231bd46b0122616c24e209c890ef2633c0",
"@edx/stylelint-config-edx": "2.3.3",
"babel-jest": "29.7.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.8",
"eslint-import-resolver-webpack": "0.13.10",
"jasmine-core": "2.6.4",
"jasmine-jquery": "git+https://git@github.com/velesin/jasmine-jquery.git#ebad463d592d3fea00c69f26ea18a930e09c7b58",
"jest": "29.7.0",
@@ -4040,7 +4038,6 @@
"version": "0.3.6",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz",
"integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==",
"license": "MIT",
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.25"
@@ -8695,12 +8692,27 @@
"urijs": "1.19.11"
}
},
"node_modules/edx-ui-toolkit/node_modules/formatio": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz",
"integrity": "sha512-cPh7is6k3d8tIUh+pnXXuAbD/uhSXGgqLPw0UrYpv5lfdJ+MMMSjx40JNpqP7Top9Nt25YomWEiRmkHbOvkCaA==",
"deprecated": "This package is unmaintained. Use @sinonjs/formatio instead",
"dependencies": {
"samsam": "~1.1"
}
},
"node_modules/edx-ui-toolkit/node_modules/jquery": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz",
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
"license": "MIT"
},
"node_modules/edx-ui-toolkit/node_modules/lolex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz",
"integrity": "sha512-YYp8cqz7/8eruZ15L1mzcPkvLYxipfdsWIDESvNdNmQP9o7TsDitRhNuV2xb7aFu2ofZngao1jiVrVZ842x4BQ==",
"license": "BSD-3-Clause"
},
"node_modules/edx-ui-toolkit/node_modules/moment-timezone": {
"version": "0.5.46",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.46.tgz",
@@ -8724,6 +8736,12 @@
"node": ">=0.4.0"
}
},
"node_modules/edx-ui-toolkit/node_modules/samsam": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz",
"integrity": "sha512-iVL7LibpM3tl4rQPweOXXrmjGegxx27flTOjQEZD3PXe4oZNFzuz6Si4mgleK/JWU/hyCvtV01RUovjvBEpDmw==",
"deprecated": "This package has been deprecated in favour of @sinonjs/samsam"
},
"node_modules/edx-ui-toolkit/node_modules/sinon": {
"version": "1.17.7",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz",
@@ -10893,15 +10911,6 @@
"node": ">= 0.12"
}
},
"node_modules/formatio": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz",
"integrity": "sha512-cPh7is6k3d8tIUh+pnXXuAbD/uhSXGgqLPw0UrYpv5lfdJ+MMMSjx40JNpqP7Top9Nt25YomWEiRmkHbOvkCaA==",
"deprecated": "This package is unmaintained. Use @sinonjs/formatio instead",
"dependencies": {
"samsam": "~1.1"
}
},
"node_modules/fragment-cache": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
@@ -17083,12 +17092,6 @@
"semver": "bin/semver"
}
},
"node_modules/lolex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz",
"integrity": "sha512-YYp8cqz7/8eruZ15L1mzcPkvLYxipfdsWIDESvNdNmQP9o7TsDitRhNuV2xb7aFu2ofZngao1jiVrVZ842x4BQ==",
"license": "BSD-3-Clause"
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -21405,12 +21408,6 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/samsam": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz",
"integrity": "sha512-iVL7LibpM3tl4rQPweOXXrmjGegxx27flTOjQEZD3PXe4oZNFzuz6Si4mgleK/JWU/hyCvtV01RUovjvBEpDmw==",
"deprecated": "This package has been deprecated in favour of @sinonjs/samsam"
},
"node_modules/sane": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/sane/-/sane-4.1.0.tgz",
@@ -21965,9 +21962,9 @@
}
},
"node_modules/sass": {
"version": "1.85.1",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.85.1.tgz",
"integrity": "sha512-Uk8WpxM5v+0cMR0XjX9KfRIacmSG86RH4DCCZjLU2rFh5tyutt9siAXJ7G+YfxQ99Q6wrRMbMlVl6KqUms71ag==",
"version": "1.82.0",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.82.0.tgz",
"integrity": "sha512-j4GMCTa8elGyN9A7x7bEglx0VgSpNUG4W4wNedQ33wSMdnkqQCT8HTwOaVSV4e6yQovcu/3Oc4coJP/l0xhL2Q==",
"license": "MIT",
"dependencies": {
"chokidar": "^4.0.0",
@@ -21985,9 +21982,9 @@
}
},
"node_modules/sass-loader": {
"version": "16.0.5",
"resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.5.tgz",
"integrity": "sha512-oL+CMBXrj6BZ/zOq4os+UECPL+bWqt6OAC6DWS8Ln8GZRcMDjlJ4JC3FBDuHJdYaFWIdKNIBYmtZtK2MaMkNIw==",
"version": "16.0.4",
"resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-16.0.4.tgz",
"integrity": "sha512-LavLbgbBGUt3wCiYzhuLLu65+fWXaXLmq7YxivLhEqmiupCFZ5sKUAipK3do6V80YSU0jvSxNhEdT13IXNr3rg==",
"license": "MIT",
"dependencies": {
"neo-async": "^2.6.2"
@@ -22025,9 +22022,9 @@
}
},
"node_modules/sass/node_modules/chokidar": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.1.tgz",
"integrity": "sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==",
"license": "MIT",
"dependencies": {
"readdirp": "^4.0.1"
@@ -22040,12 +22037,12 @@
}
},
"node_modules/sass/node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.0.2.tgz",
"integrity": "sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==",
"license": "MIT",
"engines": {
"node": ">= 14.18.0"
"node": ">= 14.16.0"
},
"funding": {
"type": "individual",
@@ -22080,10 +22077,9 @@
}
},
"node_modules/schema-utils": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.0.tgz",
"integrity": "sha512-Gf9qqc58SpCA/xdziiHz35F4GNIWYWZrEshUc/G/r5BnLph6xpKuLeoJoQuj5WfBIx/eQLf+hmVPYHaxJu7V2g==",
"license": "MIT",
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz",
"integrity": "sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==",
"dependencies": {
"@types/json-schema": "^7.0.9",
"ajv": "^8.9.0",
@@ -22091,7 +22087,7 @@
"ajv-keywords": "^5.1.0"
},
"engines": {
"node": ">= 10.13.0"
"node": ">= 12.13.0"
},
"funding": {
"type": "opencollective",
@@ -22824,7 +22820,6 @@
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
@@ -23958,10 +23953,9 @@
}
},
"node_modules/terser": {
"version": "5.39.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.39.0.tgz",
"integrity": "sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw==",
"license": "BSD-2-Clause",
"version": "5.30.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.30.0.tgz",
"integrity": "sha512-Y/SblUl5kEyEFzhMAQdsxVHh+utAxd4IuRNJzKywY/4uzSogh3G219jqbDDxYu4MXO9CzY3tSEqmZvW6AoEDJw==",
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
"acorn": "^8.8.2",
@@ -23976,16 +23970,15 @@
}
},
"node_modules/terser-webpack-plugin": {
"version": "5.3.14",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.14.tgz",
"integrity": "sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw==",
"license": "MIT",
"version": "5.3.10",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz",
"integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==",
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.25",
"@jridgewell/trace-mapping": "^0.3.20",
"jest-worker": "^27.4.5",
"schema-utils": "^4.3.0",
"serialize-javascript": "^6.0.2",
"terser": "^5.31.1"
"schema-utils": "^3.1.1",
"serialize-javascript": "^6.0.1",
"terser": "^5.26.0"
},
"engines": {
"node": ">= 10.13.0"
@@ -24030,6 +24023,23 @@
"node": ">= 10.13.0"
}
},
"node_modules/terser-webpack-plugin/node_modules/schema-utils": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
"integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==",
"dependencies": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
}
},
"node_modules/terser-webpack-plugin/node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
@@ -25115,9 +25125,9 @@
}
},
"node_modules/webpack": {
"version": "5.98.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz",
"integrity": "sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA==",
"version": "5.97.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.97.1.tgz",
"integrity": "sha512-EksG6gFY3L1eFMROS/7Wzgrii5mBAFe4rIr3r2BTfo7bcc+DWwFZ4OJ/miOuHJO/A85HwyI4eQ0F6IKXesO7Fg==",
"license": "MIT",
"dependencies": {
"@types/eslint-scope": "^3.7.7",
@@ -25138,9 +25148,9 @@
"loader-runner": "^4.2.0",
"mime-types": "^2.1.27",
"neo-async": "^2.6.2",
"schema-utils": "^4.3.0",
"schema-utils": "^3.2.0",
"tapable": "^2.1.1",
"terser-webpack-plugin": "^5.3.11",
"terser-webpack-plugin": "^5.3.10",
"watchpack": "^2.4.1",
"webpack-sources": "^3.2.3"
},
@@ -25284,9 +25294,9 @@
}
},
"node_modules/webpack/node_modules/enhanced-resolve": {
"version": "5.18.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.1.tgz",
"integrity": "sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==",
"version": "5.17.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
"integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==",
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.4",
@@ -25318,6 +25328,24 @@
"node": ">=4.0"
}
},
"node_modules/webpack/node_modules/schema-utils": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
"integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==",
"license": "MIT",
"dependencies": {
"@types/json-schema": "^7.0.8",
"ajv": "^6.12.5",
"ajv-keywords": "^3.5.2"
},
"engines": {
"node": ">= 10.13.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
}
},
"node_modules/webpack/node_modules/tapable": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",

View File

@@ -13,7 +13,6 @@
"watch": "{ npm run watch-webpack& npm run watch-sass& } && sleep infinity",
"watch-webpack": "npm run webpack-dev -- --watch",
"watch-sass": "scripts/watch_sass.sh",
"lint": "python scripts/eslint.py",
"test": "npm run test-jest && npm run test-karma",
"test-jest": "jest",
"test-karma": "npm run test-karma-vanilla && npm run test-karma-require && echo 'WARNING: Skipped broken webpack tests. For details, see: https://github.com/openedx/edx-platform/issues/35956'",
@@ -100,13 +99,11 @@
"which-country": "1.0.0"
},
"devDependencies": {
"@edx/eslint-config": "^4.0.0",
"@edx/mockprock": "github:openedx/mockprock#d70b05231bd46b0122616c24e209c890ef2633c0",
"@edx/stylelint-config-edx": "2.3.3",
"babel-jest": "29.7.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.8",
"eslint-import-resolver-webpack": "0.13.10",
"jasmine-core": "2.6.4",
"jasmine-jquery": "git+https://git@github.com/velesin/jasmine-jquery.git#ebad463d592d3fea00c69f26ea18a930e09c7b58",
"jest": "29.7.0",

View File

@@ -11,8 +11,6 @@ set -e
###############################################################################
# Violations thresholds for failing the build
source scripts/thresholds.sh
XSSLINT_THRESHOLDS=$(cat scripts/xsslint_thresholds.json)
export XSSLINT_THRESHOLDS=${XSSLINT_THRESHOLDS//[[:space:]]/}

View File

@@ -1,78 +0,0 @@
""" # pylint: disable=django-not-configured
Check code quality using eslint.
"""
import re
import subprocess
import shlex
import sys
class BuildFailure(Exception):
pass
def fail_quality(message):
"""
Fail the specified quality check.
"""
raise BuildFailure(message)
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 = 625
command = [
"node",
"--max_old_space_size=4096",
"node_modules/.bin/eslint",
"--ext", ".js",
"--ext", ".jsx",
"--format=compact",
"lms",
"cms",
"common",
"openedx",
"xmodule",
]
print("Running command:", shlex.join(command))
result = subprocess.run(
command,
text=True,
check=False,
capture_output=True
)
print(result.stdout)
if result.returncode == 0:
fail_quality("No eslint violations found. This is unexpected... are you sure eslint is running correctly?")
elif result.returncode == 1:
last_line = result.stdout.strip().splitlines()[-1] if result.stdout.strip().splitlines() else ""
regex = r'^\d+'
try:
num_violations = int(re.search(regex, last_line).group(0)) if last_line else 0
# Fail if number of violations is greater than the limit
if num_violations > violations_limit:
fail_quality("FAILURE: Too many eslint violations ({count}).\nThe limit is {violations_limit}.".format(count=num_violations, violations_limit=violations_limit))
else:
print(f"successfully run eslint with '{num_violations}' violations")
# An AttributeError will occur if the regex finds no matches.
except (AttributeError, ValueError):
fail_quality(f"FAILURE: Number of eslint violations could not be found in '{last_line}'")
else:
print(f"Unexpected ESLint failure with exit code {result.returncode}.")
fail_quality(f"Unexpected error: {result.stderr.strip()}")
if __name__ == "__main__":
try:
run_eslint()
except BuildFailure as e:
print(e)
sys.exit(1)

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -e
export ESLINT_THRESHOLD=4950

View File

@@ -1,14 +0,0 @@
module.exports = {
extends: '@edx/eslint-config',
root: true,
settings: {
'import/resolver': 'webpack',
},
rules: {
indent: ['error', 4],
'react/jsx-indent': ['error', 4],
'react/jsx-indent-props': ['error', 4],
'import/extensions': 'off',
'import/no-unresolved': 'off',
},
};