chore: apply amnesty on existing not fixable issues (#32215)

* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* chore: apply amnesty on all existing issues

* fix: failing xss-lint issues

* refactor: apply amnesty on remaining issues

* refactor: apply amnesty on new issues

* fix: remove file level suppressions

* refactor: apply amnesty on new issues
This commit is contained in:
Syed Ali Abbas Zaidi
2023-08-07 19:13:19 +05:00
committed by GitHub
parent e94af3c2d3
commit 8480dbc228
305 changed files with 1043 additions and 202 deletions

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line max-classes-per-file
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
@@ -23,11 +24,13 @@ class AnnouncementSkipLink extends React.Component {
}
}
// eslint-disable-next-line react/prefer-stateless-function
class Announcement extends React.Component {
render() {
return (
<div
className="announcement"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{__html: this.props.content}}
/>
);
@@ -44,6 +47,7 @@ class AnnouncementList extends React.Component {
this.state = {
page: 1,
announcements: [],
// eslint-disable-next-line react/no-unused-state
num_pages: 0,
has_prev: false,
has_next: false,
@@ -59,6 +63,7 @@ class AnnouncementList extends React.Component {
announcements: data.announcements,
has_next: data.next,
has_prev: data.prev,
// eslint-disable-next-line react/no-unused-state
num_pages: data.num_pages,
count: data.count,
start_index: data.start_index,
@@ -76,12 +81,14 @@ class AnnouncementList extends React.Component {
this.retrievePage(this.state.page + 1);
}
// eslint-disable-next-line react/no-deprecated, react/sort-comp
componentWillMount() {
this.retrievePage(this.state.page);
}
render() {
var children = this.state.announcements.map(
// eslint-disable-next-line react/no-array-index-key
(announcement, index) => <Announcement key={index} content={announcement.content} />
);
if (this.state.has_prev) {

View File

@@ -2,9 +2,13 @@
export class CourseSock { // eslint-disable-line import/prefer-default-export
constructor() {
// eslint-disable-next-line no-undef
const $toggleActionButton = $('.action-toggle-verification-sock');
// eslint-disable-next-line no-undef
const $verificationSock = $('.verification-sock .verification-main-panel');
// eslint-disable-next-line no-undef
const $upgradeToVerifiedButton = $('.verification-sock .action-upgrade-certificate');
// eslint-disable-next-line no-undef
const $miniCert = $('.mini-cert');
const pageLocation = window.location.href.indexOf('courseware') > -1
? 'Course Content Page' : 'Home Page';
@@ -14,6 +18,7 @@ export class CourseSock { // eslint-disable-line import/prefer-default-export
if (!$upgradeToVerifiedButton.is(':visible')) { return; }
// Grab the current scroll location
// eslint-disable-next-line no-undef
const documentBottom = $(window).scrollTop() + $(window).height();
// Establish a sliding window in which the button is fixed
@@ -25,6 +30,7 @@ export class CourseSock { // eslint-disable-line import/prefer-default-export
// Update positioning when scrolling is in fixed window and screen width is sufficient
if ((documentBottom > startFixed && documentBottom < endFixed
// eslint-disable-next-line no-undef
&& $(window).width() > 960)) {
$upgradeToVerifiedButton.addClass('attached');
$upgradeToVerifiedButton.css('right', `${distRight}px`);
@@ -46,6 +52,7 @@ export class CourseSock { // eslint-disable-line import/prefer-default-export
// Fix the sock to the screen on scroll and resize events
if ($upgradeToVerifiedButton.length) {
// eslint-disable-next-line no-undef
$(window).scroll(fixUpgradeButton).resize(fixUpgradeButton);
}

View File

@@ -33,7 +33,9 @@ export class Currency { // eslint-disable-line import/prefer-default-export
if (e instanceof SyntaxError) {
// If cookie isn't proper JSON, log but continue. This will show the purchase experience
// in a non-local currency but will not prevent the user from interacting with the page.
// eslint-disable-next-line no-console
console.error(e);
// eslint-disable-next-line no-console
console.error("Ignoring malformed 'edx-price-l10n' cookie.");
} else {
throw e;

View File

@@ -1,14 +1,20 @@
/* globals loadFixtures */
import $ from 'jquery'; // eslint-disable-line import/extensions
// eslint-disable-next-line object-curly-spacing
import { Currency } from '../currency';
describe('Currency factory', () => {
// eslint-disable-next-line no-unused-vars
let currency;
// eslint-disable-next-line no-unused-vars
let canadaPosition;
// eslint-disable-next-line no-unused-vars
let usaPosition;
// eslint-disable-next-line no-unused-vars
let japanPosition;
// eslint-disable-next-line no-undef
window.analytics = jasmine.createSpyObj('analytics', ['page', 'track', 'trackLink']);
beforeEach(() => {
@@ -31,26 +37,31 @@ describe('Currency factory', () => {
longitude: 137.737495,
},
};
// eslint-disable-next-line object-curly-spacing
$.cookie('edx-price-l10n', null, { path: '/' });
});
describe('converts price to local currency', () => {
it('when location is the default (US)', () => {
// eslint-disable-next-line object-curly-spacing
$.cookie('edx-price-l10n', '{"rate":1,"code":"USD","symbol":"$","countryCode":"US"}', { path: '/' });
currency = new Currency();
expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($100 USD)');
});
it('when cookie is set to a different country', () => {
// eslint-disable-next-line object-curly-spacing
$.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 });
currency = new Currency();
expect($('[name="verified_mode"].no-discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($220 CAD)');
});
it('when cookie is set to a different country with a discount', () => {
// eslint-disable-next-line object-curly-spacing
$.cookie('edx-price-l10n', '{"rate":2.2,"code":"CAD","symbol":"$","countryCode":"CAN"}', { expires: 1 });
currency = new Currency();
expect($('[name="verified_mode"].discount').filter(':visible').text()).toEqual('Pursue a Verified Certificate($198 CAD $220 CAD)');
});
it('should send event on initial load', () => {
// eslint-disable-next-line object-curly-spacing
$.cookie('edx-price-l10n', '{"rate":1,"code":"USD","symbol":"$","countryCode":"US"}', { path: '/' });
currency = new Currency();
expect(window.analytics.track).toHaveBeenCalledWith('edx.bi.user.track_selection.local_currency_cookie_set');