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