DEV: enable no-alert & no-console eslint rules
This commit is contained in:
parent
5852fe7975
commit
0f5aeab003
132
.eslintrc
132
.eslintrc
|
@ -1,80 +1,79 @@
|
||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"jasmine": true,
|
|
||||||
"node": true,
|
|
||||||
"mocha": true,
|
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"builtin": true,
|
"builtin": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
|
"jasmine": true,
|
||||||
|
"mocha": true,
|
||||||
|
"node": true,
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 7,
|
"ecmaVersion": 7,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"globals":
|
"globals": {
|
||||||
{"Ember":true,
|
"$": true,
|
||||||
"jQuery":true,
|
"_": true,
|
||||||
"$":true,
|
"andThen": true,
|
||||||
"QUnit":true,
|
"asyncRender": true,
|
||||||
"RSVP":true,
|
"asyncTestDiscourse": true,
|
||||||
"Discourse":true,
|
"Blob": true,
|
||||||
"Em":true,
|
"bootbox": true,
|
||||||
"Handlebars":true,
|
"click": true,
|
||||||
"I18n":true,
|
"collapseSelectKit": true,
|
||||||
"bootbox":true,
|
"controllerFor": true,
|
||||||
"moduleFor":true,
|
"count": true,
|
||||||
"moduleForComponent":true,
|
"currentPath": true,
|
||||||
"Pretender":true,
|
"currentRouteName": true,
|
||||||
"sandbox":true,
|
"currentURL": true,
|
||||||
"controllerFor":true,
|
"define": true,
|
||||||
"test":true,
|
"Discourse": true,
|
||||||
"visit":true,
|
"Em": true,
|
||||||
"andThen":true,
|
"Ember": true,
|
||||||
"click":true,
|
"exists": true,
|
||||||
"currentPath":true,
|
"expandSelectKit": true,
|
||||||
"currentRouteName":true,
|
"File": true,
|
||||||
"currentURL":true,
|
"fillIn": true,
|
||||||
"fillIn":true,
|
"find": true,
|
||||||
"keyEvent":true,
|
"fixture": true,
|
||||||
"triggerEvent":true,
|
"Handlebars": true,
|
||||||
"count":true,
|
"hasModule": true,
|
||||||
"exists":true,
|
"I18n": true,
|
||||||
"visible":true,
|
"invisible": true,
|
||||||
"invisible":true,
|
"jQuery": true,
|
||||||
"asyncRender":true,
|
"keyboardHelper": true,
|
||||||
"selectKit":true,
|
"keyEvent": true,
|
||||||
"expandSelectKit":true,
|
"moduleFor": true,
|
||||||
"collapseSelectKit":true,
|
"moduleForComponent": true,
|
||||||
"selectKitSelectRowByValue":true,
|
"moment": true,
|
||||||
"selectKitSelectRowByName":true,
|
"Pretender": true,
|
||||||
"selectKitSelectRowByIndex":true,
|
"QUnit": true,
|
||||||
"keyboardHelper":true,
|
"require": true,
|
||||||
"selectKitSelectNoneRow":true,
|
"requirejs": true,
|
||||||
"selectKitFillInFilter":true,
|
"RSVP": true,
|
||||||
"asyncTestDiscourse":true,
|
"sandbox": true,
|
||||||
"fixture":true,
|
"selectKit": true,
|
||||||
"find":true,
|
"selectKitFillInFilter": true,
|
||||||
"sinon":true,
|
"selectKitSelectNoneRow": true,
|
||||||
"moment":true,
|
"selectKitSelectRowByIndex": true,
|
||||||
"_":true,
|
"selectKitSelectRowByName": true,
|
||||||
"alert":true,
|
"selectKitSelectRowByValue": true,
|
||||||
"define":true,
|
"sinon": true,
|
||||||
"require":true,
|
"test": true,
|
||||||
"requirejs":true,
|
"triggerEvent": true,
|
||||||
"hasModule":true,
|
"visible": true,
|
||||||
"Blob":true,
|
"visit": true,
|
||||||
"File":true},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"block-scoped-var": 2,
|
"block-scoped-var": 2,
|
||||||
"dot-notation": 0,
|
"dot-notation": 0,
|
||||||
"eqeqeq": [
|
"eqeqeq": [2, "allow-null"],
|
||||||
2,
|
|
||||||
"allow-null"
|
|
||||||
],
|
|
||||||
"guard-for-in": 2,
|
"guard-for-in": 2,
|
||||||
|
"no-alert": 2,
|
||||||
"no-bitwise": 2,
|
"no-bitwise": 2,
|
||||||
"no-caller": 2,
|
"no-caller": 2,
|
||||||
"no-cond-assign": 0,
|
"no-cond-assign": 0,
|
||||||
|
"no-console": 2,
|
||||||
"no-debugger": 2,
|
"no-debugger": 2,
|
||||||
"no-empty": 0,
|
"no-empty": 0,
|
||||||
"no-eval": 2,
|
"no-eval": 2,
|
||||||
|
@ -84,6 +83,7 @@
|
||||||
"no-irregular-whitespace": 2,
|
"no-irregular-whitespace": 2,
|
||||||
"no-iterator": 2,
|
"no-iterator": 2,
|
||||||
"no-loop-func": 2,
|
"no-loop-func": 2,
|
||||||
|
"no-mixed-spaces-and-tabs": 2,
|
||||||
"no-multi-str": 2,
|
"no-multi-str": 2,
|
||||||
"no-new": 2,
|
"no-new": 2,
|
||||||
"no-plusplus": 0,
|
"no-plusplus": 0,
|
||||||
|
@ -91,19 +91,15 @@
|
||||||
"no-script-url": 2,
|
"no-script-url": 2,
|
||||||
"no-sequences": 2,
|
"no-sequences": 2,
|
||||||
"no-shadow": 2,
|
"no-shadow": 2,
|
||||||
|
"no-this-before-super": 2,
|
||||||
|
"no-trailing-spaces": 2,
|
||||||
"no-undef": 2,
|
"no-undef": 2,
|
||||||
"no-unused-vars": 2,
|
"no-unused-vars": 2,
|
||||||
"no-with": 2,
|
"no-with": 2,
|
||||||
"no-this-before-super": 2,
|
|
||||||
"semi": 2,
|
"semi": 2,
|
||||||
"strict": 0,
|
"strict": 0,
|
||||||
"valid-typeof": 2,
|
"valid-typeof": 2,
|
||||||
"wrap-iife": [
|
"wrap-iife": [2, "inside"],
|
||||||
2,
|
|
||||||
"inside"
|
|
||||||
],
|
|
||||||
"no-mixed-spaces-and-tabs": 2,
|
|
||||||
"no-trailing-spaces": 2
|
|
||||||
},
|
},
|
||||||
"parser": "babel-eslint"
|
"parser": "babel-eslint"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ export default Ember.Controller.extend({
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => {
|
||||||
this.set("loadingFlags", false);
|
this.set("loadingFlags", false);
|
||||||
console.log(result);
|
|
||||||
this.set("flaggedPosts", result);
|
this.set("flaggedPosts", result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export default function deprecated(msg) {
|
export default function deprecated(msg) {
|
||||||
console.warn(`DEPRECATION: ${msg}`);
|
console.warn(`DEPRECATION: ${msg}`); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ var define, requirejs;
|
||||||
if (!mod) {
|
if (!mod) {
|
||||||
var moved = MOVED_MODULES[name];
|
var moved = MOVED_MODULES[name];
|
||||||
if (moved) {
|
if (moved) {
|
||||||
console.warn("DEPRECATION: `" + name + "` was moved to `" + moved + "`");
|
console.warn("DEPRECATION: `" + name + "` was moved to `" + moved + "`"); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
mod = registry[moved];
|
mod = registry[moved];
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ export default Ember.Component.extend({
|
||||||
queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
|
queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
|
||||||
|
|
||||||
if (!this._widgetClass) {
|
if (!this._widgetClass) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error(`Error: Could not find widget: ${name}`);
|
console.error(`Error: Could not find widget: ${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +131,7 @@ export default Ember.Component.extend({
|
||||||
this.dirtyKeys.renderedKey("*");
|
this.dirtyKeys.renderedKey("*");
|
||||||
|
|
||||||
if (this.profileWidget) {
|
if (this.profileWidget) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log(new Date().getTime() - t0);
|
console.log(new Date().getTime() - t0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,9 +128,7 @@ export default Ember.Component.extend({
|
||||||
// use native webshare only when the user clicks on the "chain" icon
|
// use native webshare only when the user clicks on the "chain" icon
|
||||||
// navigator.share needs HTTPS, returns undefined on HTTP
|
// navigator.share needs HTTPS, returns undefined on HTTP
|
||||||
if (navigator.share && !$currentTarget.hasClass("post-date")) {
|
if (navigator.share && !$currentTarget.hasClass("post-date")) {
|
||||||
this._webShare(url).catch(error => {
|
this._webShare(url).catch(() => {
|
||||||
console.warn("Error sharing", error);
|
|
||||||
|
|
||||||
// if navigator fails for unexpected reason fallback to popup
|
// if navigator fails for unexpected reason fallback to popup
|
||||||
this._showUrl($currentTarget, url);
|
this._showUrl($currentTarget, url);
|
||||||
});
|
});
|
||||||
|
|
|
@ -703,9 +703,9 @@ export default Ember.Controller.extend({
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
if (!opts.draftKey) {
|
if (!opts.draftKey) {
|
||||||
alert("composer was opened without a draft key");
|
|
||||||
throw new Error("composer opened without a proper draft key");
|
throw new Error("composer opened without a proper draft key");
|
||||||
}
|
}
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
let composerModel = this.get("model");
|
let composerModel = this.get("model");
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ registerUnbound("raw", function(templateName, params) {
|
||||||
const container = Discourse.__container__;
|
const container = Discourse.__container__;
|
||||||
const template = findRawTemplate(templateName);
|
const template = findRawTemplate(templateName);
|
||||||
if (!template) {
|
if (!template) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn("Could not find raw template: " + templateName);
|
console.warn("Could not find raw template: " + templateName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ class PluginApi {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
if (this.container.cache[resolverName]) {
|
if (this.container.cache[resolverName]) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(
|
console.warn(
|
||||||
`"${resolverName}" was already cached in the container. Changes won't be applied.`
|
`"${resolverName}" was already cached in the container. Changes won't be applied.`
|
||||||
);
|
);
|
||||||
|
@ -68,6 +69,7 @@ class PluginApi {
|
||||||
const klass = this.container.factoryFor(resolverName);
|
const klass = this.container.factoryFor(resolverName);
|
||||||
if (!klass) {
|
if (!klass) {
|
||||||
if (!opts.ignoreMissing) {
|
if (!opts.ignoreMissing) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(`"${resolverName}" was not found by modifyClass`);
|
console.warn(`"${resolverName}" was not found by modifyClass`);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -686,6 +688,7 @@ class PluginApi {
|
||||||
*/
|
*/
|
||||||
addNavigationBarItem(item) {
|
addNavigationBarItem(item) {
|
||||||
if (!item["name"]) {
|
if (!item["name"]) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(
|
console.warn(
|
||||||
"A 'name' is required when adding a Navigation Bar Item.",
|
"A 'name' is required when adding a Navigation Bar Item.",
|
||||||
item
|
item
|
||||||
|
@ -806,6 +809,7 @@ function getPluginApi(version) {
|
||||||
}
|
}
|
||||||
return _pluginv01;
|
return _pluginv01;
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(`Plugin API v${version} is not supported`);
|
console.warn(`Plugin API v${version} is not supported`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -843,6 +847,7 @@ export function resetPluginApi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decorateCooked() {
|
export function decorateCooked() {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(
|
console.warn(
|
||||||
"`decorateCooked` has been removed. Use `getPluginApi(version).decorateCooked` instead"
|
"`decorateCooked` has been removed. Use `getPluginApi(version).decorateCooked` instead"
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import deprecated from "discourse-common/lib/deprecated";
|
||||||
const keySelector = "meta[name=discourse_theme_ids]";
|
const keySelector = "meta[name=discourse_theme_ids]";
|
||||||
|
|
||||||
export function currentThemeKey() {
|
export function currentThemeKey() {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
if (console && console.warn && console.trace) {
|
if (console && console.warn && console.trace) {
|
||||||
// TODO: Remove this code Jan 2019
|
// TODO: Remove this code Jan 2019
|
||||||
deprecated(
|
deprecated(
|
||||||
|
|
|
@ -37,8 +37,7 @@ export default RestrictedUserRoute.extend({
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
// model failed to save
|
// model failed to save
|
||||||
controller.set("saving", false);
|
bootbox.alert(I18n.t("generic_error"));
|
||||||
alert(I18n.t("generic_error"));
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ export default Discourse.Route.extend({
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
if (!Ember.testing) {
|
if (!Ember.testing) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log("Could not view topic", e);
|
console.log("Could not view topic", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ export default class WidgetGlue {
|
||||||
this._widgetClass =
|
this._widgetClass =
|
||||||
queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
|
queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
|
||||||
if (!this._widgetClass) {
|
if (!this._widgetClass) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error(`Error: Could not find widget: ${name}`);
|
console.error(`Error: Could not find widget: ${name}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export default function hbs() {
|
export default function hbs() {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.log("Templates should be precompiled server side");
|
console.log("Templates should be precompiled server side");
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ export function createWidget(name, opts) {
|
||||||
export function reopenWidget(name, opts) {
|
export function reopenWidget(name, opts) {
|
||||||
let existing = _registry[name];
|
let existing = _registry[name];
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error(`Could not find widget ${name} in registry`);
|
console.error(`Could not find widget ${name} in registry`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -205,9 +206,7 @@ export default class Widget {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {}
|
||||||
console.log("destroy called");
|
|
||||||
}
|
|
||||||
|
|
||||||
render(prev) {
|
render(prev) {
|
||||||
const { dirtyKeys } = this;
|
const { dirtyKeys } = this;
|
||||||
|
@ -268,6 +267,7 @@ export default class Widget {
|
||||||
|
|
||||||
if (!WidgetClass) {
|
if (!WidgetClass) {
|
||||||
if (!this.register) {
|
if (!this.register) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.error("couldn't find register");
|
console.error("couldn't find register");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -310,6 +310,7 @@ export default class Widget {
|
||||||
if (view) {
|
if (view) {
|
||||||
const method = view.get(name);
|
const method = view.get(name);
|
||||||
if (!method) {
|
if (!method) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
console.warn(`${name} not found`);
|
console.warn(`${name} not found`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Discourse.Environment === "development") {
|
if (Discourse.Environment === "development") {
|
||||||
|
/* eslint-disable no-console */
|
||||||
if (e) {
|
if (e) {
|
||||||
if (e.message || e.stack) {
|
if (e.message || e.stack) {
|
||||||
console.log(e.message);
|
console.log(e.message);
|
||||||
|
@ -57,6 +58,7 @@
|
||||||
} else {
|
} else {
|
||||||
console.log("A promise failed but was not caught.");
|
console.log("A promise failed but was not caught.");
|
||||||
}
|
}
|
||||||
|
/* eslint-enable no-console */
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onerror(e && e.message, null, null, null, e);
|
window.onerror(e && e.message, null, null, null, e);
|
||||||
|
|
Loading…
Reference in New Issue