fix: migrate remaining eslint-config-edx (#31760)

* fix: migrate remaining eslint-config-edx

* refactor: updated eslint rules according to eslint-config-edx-es5

* refactor: add custom rules to suppress unnecessary eslint issues

* refactor: add custom rules to internal eslint configs

* fix: fix all indentation issues

* chore: update lock file
This commit is contained in:
Syed Ali Abbas Zaidi
2023-03-02 16:16:50 +05:00
committed by GitHub
parent 9cdbe72b82
commit 5549db4d80
495 changed files with 74392 additions and 44320 deletions

View File

@@ -2,9 +2,9 @@
// supported in older browsers
var pointerEventsNone = function(selector, supportedStyles) {
// Check to see if the browser supports 'pointer-events' css rule.
// If it doesn't, use javascript to stop the link from working
// when clicked.
// Check to see if the browser supports 'pointer-events' css rule.
// If it doesn't, use javascript to stop the link from working
// when clicked.
$(selector).click(function(event) {
if (!('pointerEvents' in supportedStyles)) {
event.preventDefault();

View File

@@ -2,65 +2,65 @@ import React from 'react';
import ReactDOM from 'react-dom';
class ReactRendererException extends Error {
constructor(message) {
super(`ReactRendererException: ${message}`);
Error.captureStackTrace(this, ReactRendererException);
}
constructor(message) {
super(`ReactRendererException: ${message}`);
Error.captureStackTrace(this, ReactRendererException);
}
}
export class ReactRenderer {
constructor({ component, selector, componentName, props = {} }) {
Object.assign(this, {
component,
selector,
componentName,
props,
});
this.handleArgumentErrors();
this.targetElement = this.getTargetElement();
this.renderComponent();
}
constructor({ component, selector, componentName, props = {} }) {
Object.assign(this, {
component,
selector,
componentName,
props,
});
this.handleArgumentErrors();
this.targetElement = this.getTargetElement();
this.renderComponent();
}
handleArgumentErrors() {
if (this.component === null) {
throw new ReactRendererException(
`Component ${this.componentName} is not defined. Make sure you're ` +
handleArgumentErrors() {
if (this.component === null) {
throw new ReactRendererException(
`Component ${this.componentName} is not defined. Make sure you're ` +
`using a non-default export statement for the ${this.componentName} ` +
`class, that ${this.componentName} has an entry point defined ` +
'within the \'entry\' section of webpack.common.config.js, and that the ' +
'entry point is pointing at the correct file path.',
);
}
if (!(this.props instanceof Object && this.props.constructor === Object)) {
let propsType = typeof this.props;
if (Array.isArray(this.props)) {
propsType = 'array';
} else if (this.props === null) {
propsType = 'null';
}
throw new ReactRendererException(
`Invalid props passed to component ${this.componentName}. Expected ` +
);
}
if (!(this.props instanceof Object && this.props.constructor === Object)) {
let propsType = typeof this.props;
if (Array.isArray(this.props)) {
propsType = 'array';
} else if (this.props === null) {
propsType = 'null';
}
throw new ReactRendererException(
`Invalid props passed to component ${this.componentName}. Expected ` +
`an object, but received a ${propsType}.`,
);
);
}
}
}
getTargetElement() {
const elementList = document.querySelectorAll(this.selector);
if (elementList.length !== 1) {
throw new ReactRendererException(
`Expected 1 element match for selector "${this.selector}" ` +
getTargetElement() {
const elementList = document.querySelectorAll(this.selector);
if (elementList.length !== 1) {
throw new ReactRendererException(
`Expected 1 element match for selector "${this.selector}" ` +
`but received ${elementList.length} matches.`,
);
} else {
return elementList[0];
);
} else {
return elementList[0];
}
}
}
renderComponent() {
ReactDOM.render(
React.createElement(this.component, this.props, null),
this.targetElement,
);
}
renderComponent() {
ReactDOM.render(
React.createElement(this.component, this.props, null),
this.targetElement,
);
}
}

View File

@@ -128,10 +128,10 @@ var trapFocusForAccessibleModal = function(
// to ensure that the correct elements are accessible.
var focusableItems, $last;
focusableItems = reassignTabIndexesAndAriaHidden(
focusableElementsFilterString,
closeButtonId,
modalId,
mainPageId
focusableElementsFilterString,
closeButtonId,
modalId,
mainPageId
);
$last = trapTabFocus(focusableItems, closeButtonId);
trapShiftTabFocus($last, closeButtonId);
@@ -140,17 +140,17 @@ var trapFocusForAccessibleModal = function(
};
var accessible_modal = function(trigger, closeButtonId, modalId, mainPageId) {
// Modifies a lean modal to optimize focus management.
// "trigger" is the selector for the link element that triggers the modal.
// "closeButtonId" is the selector for the button that closes out the modal.
// "modalId" is the selector for the modal being managed
// "mainPageId" is the selector for the main part of the page
//
// based on http://accessibility.oit.ncsu.edu/training/aria/modal-window/modal-window.js
//
// see http://accessibility.oit.ncsu.edu/blog/2013/09/13/the-incredible-accessible-modal-dialog/
// for more information on managing modals
//
// Modifies a lean modal to optimize focus management.
// "trigger" is the selector for the link element that triggers the modal.
// "closeButtonId" is the selector for the button that closes out the modal.
// "modalId" is the selector for the modal being managed
// "mainPageId" is the selector for the main part of the page
//
// based on http://accessibility.oit.ncsu.edu/training/aria/modal-window/modal-window.js
//
// see http://accessibility.oit.ncsu.edu/blog/2013/09/13/the-incredible-accessible-modal-dialog/
// for more information on managing modals
//
var initialFocus
$(trigger).click(function() {
$focusedElementBeforeModal = $(trigger);

View File

@@ -9,7 +9,7 @@ var Language = (function() {
this.listenForLanguagePreferenceChange();
},
/**
/**
* Listener on changing language from selector.
* Send an ajax request to save user language preferences.
*/
@@ -21,8 +21,8 @@ var Language = (function() {
event.preventDefault();
self.submitAjaxRequest(language, url, function() {
if (is_user_authenticated) {
// User language preference has been set successfully
// Now submit the form in success callback.
// User language preference has been set successfully
// Now submit the form in success callback.
$('#language-settings-form').submit();
} else {
self.refresh();
@@ -31,7 +31,7 @@ var Language = (function() {
});
},
/**
/**
* Send an ajax request to set user language preferences.
*/
submitAjaxRequest: function(language, url, callback) {
@@ -52,11 +52,11 @@ var Language = (function() {
});
},
/**
/**
* refresh the page.
*/
refresh: function() {
// reloading the page so we can get the latest state of released languages from model
// reloading the page so we can get the latest state of released languages from model
location.reload();
}