Skip to content

Commit

Permalink
fix: migrate remaining eslint-config-edx (openedx#31760)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Syed-Ali-Abbas-Zaidi authored Mar 2, 2023
1 parent 9cdbe72 commit 5549db4
Show file tree
Hide file tree
Showing 495 changed files with 74,221 additions and 44,149 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ 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
68 changes: 67 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,72 @@
"spyOnEvent": true,

// used by our requirejs implementation
"RequireJS": true
"RequireJS": true,

// enable jquery
"$": true
},
"rules": {
"func-names": "off",
"indent": ["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",
"curly": "off",
"eqeqeq": "off",
"function-call-argument-newline": "off",
"function-paren-newline": "off",
"implicit-arrow-linebreak": "off",
"import/extensions": "off",
"import/no-amd": "off",
"import/no-dynamic-require": "off",
"import/no-unresolved": "off",
"linebreak-style": "off",
"lines-around-directive": "off",
"max-len": "off",
"newline-per-chained-call": "off",
"no-console": "off",
"no-lonely-if": "off",
"no-multi-spaces": "off",
"no-multiple-empty-lines": "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-curly-newline": "off",
"object-shorthand": "off",
"operator-linebreak": "off",
"prefer-arrow-callback": "off",
"prefer-destructuring": "off",
"prefer-rest-params": "off",
"prefer-template": "off",
"quotes": "off",
"radix": "off",
"react/jsx-indent": "off",
"react/jsx-indent-props": "off",
"react/jsx-wrap-multilines": "off",
"react/prop-types": "off",
"semi": "off",
"vars-on-top": "off"
}
}
140 changes: 70 additions & 70 deletions cms/static/cms/js/spec/main_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,80 @@
(function(sandbox) {
'use strict';
require(['jquery', 'backbone', 'cms/js/main', 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', 'jquery.cookie'],
function($, Backbone, main, AjaxHelpers) {
describe('CMS', function() {
it('should initialize URL', function() {
expect(window.CMS.URL).toBeDefined();
});
function($, Backbone, main, AjaxHelpers) {
describe('CMS', function() {
it('should initialize URL', function() {
expect(window.CMS.URL).toBeDefined();
});
describe('main helper', function() {
beforeEach(function() {
this.previousAjaxSettings = $.extend(true, {}, $.ajaxSettings);
spyOn($, 'cookie').and.callFake(function(param) {
if (param === 'csrftoken') {
return 'stubCSRFToken';
}
});
return main();
});
afterEach(function() {
$.ajaxSettings = this.previousAjaxSettings;
return $.ajaxSettings;
});
it('turn on Backbone emulateHTTP', function() {
expect(Backbone.emulateHTTP).toBeTruthy();
});
it('setup AJAX CSRF token', function() {
expect($.ajaxSettings.headers['X-CSRFToken']).toEqual('stubCSRFToken');
});
describe('main helper', function() {
beforeEach(function() {
this.previousAjaxSettings = $.extend(true, {}, $.ajaxSettings);
spyOn($, 'cookie').and.callFake(function(param) {
if (param === 'csrftoken') {
return 'stubCSRFToken';
}
});
return main();
});
describe('AJAX Errors', function() {
var server;
server = null;
beforeEach(function() {
appendSetFixtures(sandbox({
id: 'page-notification'
}));
});
afterEach(function() {
return server && server.restore();
});
it('successful AJAX request does not pop an error notification', function() {
server = AjaxHelpers.server([
200, {
'Content-Type': 'application/json'
}, '{}'
]);
expect($('#page-notification')).toBeEmpty();
$.ajax('/test');
expect($('#page-notification')).toBeEmpty();
server.respond();
expect($('#page-notification')).toBeEmpty();
});
it('AJAX request with error should pop an error notification', function() {
server = AjaxHelpers.server([
500, {
'Content-Type': 'application/json'
}, '{}'
]);
$.ajax('/test');
server.respond();
expect($('#page-notification')).not.toBeEmpty();
expect($('#page-notification')).toContainElement('div.wrapper-notification-error');
});
it('can override AJAX request with error so it does not pop an error notification', function() {
server = AjaxHelpers.server([
500, {
'Content-Type': 'application/json'
}, '{}'
]);
$.ajax({
url: '/test',
notifyOnError: false
});
server.respond();
expect($('#page-notification')).toBeEmpty();
afterEach(function() {
$.ajaxSettings = this.previousAjaxSettings;
return $.ajaxSettings;
});
it('turn on Backbone emulateHTTP', function() {
expect(Backbone.emulateHTTP).toBeTruthy();
});
it('setup AJAX CSRF token', function() {
expect($.ajaxSettings.headers['X-CSRFToken']).toEqual('stubCSRFToken');
});
});
describe('AJAX Errors', function() {
var server;
server = null;
beforeEach(function() {
appendSetFixtures(sandbox({
id: 'page-notification'
}));
});
afterEach(function() {
return server && server.restore();
});
it('successful AJAX request does not pop an error notification', function() {
server = AjaxHelpers.server([
200, {
'Content-Type': 'application/json'
}, '{}'
]);
expect($('#page-notification')).toBeEmpty();
$.ajax('/test');
expect($('#page-notification')).toBeEmpty();
server.respond();
expect($('#page-notification')).toBeEmpty();
});
it('AJAX request with error should pop an error notification', function() {
server = AjaxHelpers.server([
500, {
'Content-Type': 'application/json'
}, '{}'
]);
$.ajax('/test');
server.respond();
expect($('#page-notification')).not.toBeEmpty();
expect($('#page-notification')).toContainElement('div.wrapper-notification-error');
});
it('can override AJAX request with error so it does not pop an error notification', function() {
server = AjaxHelpers.server([
500, {
'Content-Type': 'application/json'
}, '{}'
]);
$.ajax({
url: '/test',
notifyOnError: false
});
server.respond();
expect($('#page-notification')).toBeEmpty();
});
});
});
}).call(this, sandbox);
Loading

0 comments on commit 5549db4

Please sign in to comment.