DEV: Bump eslint, lint-configs, and move to flat config (#29661)
This commit is contained in:
parent
6dfe2fbe16
commit
fb2a688b29
|
@ -1,14 +0,0 @@
|
|||
app/assets/javascripts/ember-addons/
|
||||
lib/javascripts/locale/
|
||||
lib/javascripts/messageformat.js
|
||||
lib/javascripts/messageformat-lookup.js
|
||||
lib/pretty_text/
|
||||
plugins/**/lib/javascripts/locale
|
||||
public/
|
||||
vendor/
|
||||
app/assets/javascripts/discourse/tests/fixtures
|
||||
node_modules/
|
||||
spec/
|
||||
dist/
|
||||
tmp/
|
||||
documentation/
|
|
@ -1,5 +0,0 @@
|
|||
const config = require("@discourse/lint-configs/eslint");
|
||||
|
||||
config.rules["ember/no-classic-classes"] = "error";
|
||||
|
||||
module.exports = config;
|
|
@ -1,10 +1,8 @@
|
|||
/* eslint-disable simple-import-sort/imports */
|
||||
import "./deprecation-workflow";
|
||||
import "decorator-transforms/globals";
|
||||
import "./loader-shims";
|
||||
import "./global-compat";
|
||||
import { registerDiscourseImplicitInjections } from "discourse/lib/implicit-injections";
|
||||
/* eslint-enable simple-import-sort/imports */
|
||||
|
||||
// Register Discourse's standard implicit injections on common framework classes.
|
||||
registerDiscourseImplicitInjections();
|
||||
|
|
|
@ -44,6 +44,6 @@ export default class CopyButton extends Component {
|
|||
this.set("copyTranslatedLabel", this.translatedLabelAfterCopy);
|
||||
|
||||
discourseDebounce(this._restoreButton, 3000);
|
||||
} catch (err) {}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class ChangeOwnerModal extends Component {
|
|||
this.args.model.toggleMultiSelect();
|
||||
}
|
||||
DiscourseURL.routeTo(this.args.model.topic.url);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
this.flash = I18n.t("topic.change_owner.error");
|
||||
this.saving = false;
|
||||
}
|
||||
|
|
|
@ -237,7 +237,6 @@ export default class SpreadsheetEditor extends Component {
|
|||
? `post-${postNumber}-table-export`
|
||||
: `post-table-export`;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
this.spreadsheet = this.jspreadsheet(this.spreadsheet, {
|
||||
data,
|
||||
columns,
|
||||
|
|
|
@ -121,7 +121,7 @@ function prepareSidebarSectionClass(Section, routerService) {
|
|||
return routerService.isActive(link.route, ...models, {
|
||||
queryParams,
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// false if ember throws an exception while checking the routes
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export default class Validator {
|
|||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new URL(value);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return I18n.t("form_kit.errors.invalid_url");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ export default {
|
|||
|
||||
try {
|
||||
return sessionStorage && sessionStorage.getItem("verbose_localization");
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ export function adminRouteValid(router, adminRoute) {
|
|||
router.urlFor(adminRoute.full_location);
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ function parseCookieValue(s) {
|
|||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, " "));
|
||||
return s;
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function cookie(key, value, options) {
|
||||
|
|
|
@ -10,7 +10,7 @@ export default function (text, element) {
|
|||
if (document.queryCommandSupported("copy")) {
|
||||
supported = true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
if (!supported) {
|
||||
|
@ -27,7 +27,7 @@ export default function (text, element) {
|
|||
if (document.execCommand("copy")) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -35,7 +35,7 @@ function init(messageBus) {
|
|||
|
||||
try {
|
||||
keyValueStore.getItem(focusTrackerKey);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
"Discourse desktop notifications are disabled - localStorage denied."
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// eslint-disable-next-line ember/no-classic-components
|
||||
import { EventDispatcher } from "@ember/-internals/views";
|
||||
import Component from "@ember/component";
|
||||
import EmberObject from "@ember/object";
|
||||
|
@ -54,7 +53,6 @@ export function normalizeEmberEventHandling(app) {
|
|||
* runtime overhead.
|
||||
*/
|
||||
function eliminateClassicEventDelegation() {
|
||||
// eslint-disable-next-line no-undef
|
||||
EventDispatcher.reopen({
|
||||
events: {},
|
||||
});
|
||||
|
@ -144,13 +142,11 @@ function rewireClassicComponentEvents(app) {
|
|||
}
|
||||
},
|
||||
|
||||
// eslint-disable-next-line ember/no-component-lifecycle-hooks
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
setupComponentEventListeners(this, allEventMethods);
|
||||
},
|
||||
|
||||
// eslint-disable-next-line ember/no-component-lifecycle-hooks
|
||||
willDestroyElement() {
|
||||
teardownComponentEventListeners(this);
|
||||
this._super(...arguments);
|
||||
|
|
|
@ -13,7 +13,7 @@ try {
|
|||
// makes sure we can write to the local storage
|
||||
safeLocalStorage["safeLocalStorage"] = true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// local storage disabled
|
||||
safeLocalStorage = null;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export default class KeyValueStore {
|
|||
let v = safeLocalStorage[k];
|
||||
try {
|
||||
v = JSON.parse(v);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
if (
|
||||
k.substring(0, this.context.length) === this.context &&
|
||||
|
@ -106,7 +106,7 @@ export default class KeyValueStore {
|
|||
|
||||
try {
|
||||
return JSON.parse(safeLocalStorage[this.context + key]);
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ export async function preloadItemImages(lightboxItem) {
|
|||
fullsizeImage.naturalWidth > window.innerWidth ||
|
||||
fullsizeImage.naturalHeight > window.innerHeight,
|
||||
};
|
||||
} catch (error) {
|
||||
} catch {
|
||||
lightboxItem.hasLoadingError = true;
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
|
|
|
@ -33,7 +33,7 @@ const Mobile = {
|
|||
this.reloadPage(savedValue);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// localStorage may be disabled, just skip this
|
||||
// you get security errors if it is disabled
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ const Mobile = {
|
|||
if (localStorage) {
|
||||
localStorage.mobileView = !this.mobileView;
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// localStorage may be disabled, skip
|
||||
}
|
||||
this.reloadPage(!this.mobileView);
|
||||
|
|
|
@ -2535,7 +2535,6 @@ class PluginApi {
|
|||
pluginId: `${mountedComponent}/${widgetKey}/${appEvent}`,
|
||||
|
||||
didInsertElement() {
|
||||
// eslint-disable-next-line ember/no-ember-super-in-es-classes
|
||||
this._super();
|
||||
this.dispatch(appEvent, widgetKey);
|
||||
},
|
||||
|
|
|
@ -88,7 +88,7 @@ export function subscribe(callback, applicationServerKey) {
|
|||
return serviceWorkerRegistration.pushManager
|
||||
.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: new Uint8Array(applicationServerKey.split("|")), // eslint-disable-line no-undef
|
||||
applicationServerKey: new Uint8Array(applicationServerKey.split("|")),
|
||||
})
|
||||
.then((subscription) => {
|
||||
sendSubscriptionToServer(subscription, true);
|
||||
|
|
|
@ -905,7 +905,7 @@ export default function toMarkdown(html) {
|
|||
.replace(/\n{3,}/g, "\n\n")
|
||||
.replace(/\t/g, " ");
|
||||
return replacePlaceholders(markdown, placeholders);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -343,7 +343,6 @@ export function applyValueTransformer(
|
|||
try {
|
||||
const value = valueCallback({ value: newValue, context });
|
||||
if (mutable && typeof value !== "undefined") {
|
||||
// eslint-disable-next-line no-console
|
||||
throw new Error(
|
||||
`${prefix}: transformer "${transformerName}" expects the value to be mutated instead of returned. Remove the return value in your transformer.`
|
||||
);
|
||||
|
|
|
@ -347,7 +347,7 @@ export function displayErrorForUpload(data, siteSettings, fileName) {
|
|||
if (typeof parsedBody === "string") {
|
||||
try {
|
||||
parsedBody = JSON.parse(parsedBody);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ export function unicodeSlugify(string) {
|
|||
.replace(/--+/g, "-") // replace multiple dashes with a single dash
|
||||
.replace(/^-+/, "") // Remove leading dashes
|
||||
.replace(/-+$/, ""); // Remove trailing dashes
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// in case the regex construct \p{Letter} is not supported by the browser
|
||||
// fall back to the basic slugify function
|
||||
return slugify(string);
|
||||
|
@ -425,7 +425,7 @@ export function areCookiesEnabled() {
|
|||
let ret = document.cookie.includes("cookietest=");
|
||||
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
|
||||
return ret;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* global PublicKeyCredential */
|
||||
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import I18n from "discourse-i18n";
|
||||
|
||||
|
@ -77,7 +75,6 @@ export function getWebauthnCredential(
|
|||
})
|
||||
.then((credential) => {
|
||||
// 3. If credential.response is not an instance of AuthenticatorAssertionResponse, abort the ceremony.
|
||||
// eslint-disable-next-line no-undef
|
||||
if (!(credential.response instanceof AuthenticatorAssertionResponse)) {
|
||||
return errorCallback(
|
||||
I18n.t("login.security_key_invalid_response_error")
|
||||
|
|
|
@ -16,7 +16,6 @@ export default function () {
|
|||
{ path: "/t/:slug/:id", resetNamespace: true },
|
||||
function () {
|
||||
this.route("fromParams", { path: "/" });
|
||||
// eslint-disable-next-line ember/routes-segments-snake-case
|
||||
this.route("fromParamsNear", { path: "/:nearPost" });
|
||||
}
|
||||
);
|
||||
|
|
|
@ -55,7 +55,7 @@ async function loadDraft(store, opts = {}) {
|
|||
if (draft && typeof draft === "string") {
|
||||
draft = JSON.parse(draft);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
draft = null;
|
||||
Draft.clear(draftKey, draftSequence);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// eslint-disable-next-line simple-import-sort/imports
|
||||
export * from "ace-builds/src-noconflict/ace";
|
||||
|
||||
import "ace-builds/src-noconflict/mode-scss";
|
||||
|
|
|
@ -72,7 +72,7 @@ export default RouteTemplate(
|
|||
} else {
|
||||
setTimeout(this.loadHomepage, 3000);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
this.errorMessage = i18n("user.activate_account.already_done");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export default class WidgetGlue {
|
|||
if (isTesting()) {
|
||||
try {
|
||||
this.register.lookup("service:store");
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class SiteSettingsPlugin extends Plugin {
|
|||
let yaml;
|
||||
try {
|
||||
yaml = fs.readFileSync(file, { encoding: "UTF-8" });
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// the plugin does not have a config file, go to the next file
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
// checks for `null` and `undefined`).
|
||||
try {
|
||||
new WeakMap().has(0);
|
||||
// eslint-disable-next-line no-unused-vars -- old browsers require binding this variable, even if unused
|
||||
} catch (err) {
|
||||
window.unsupportedBrowser = true;
|
||||
}
|
||||
|
|
|
@ -68,9 +68,11 @@
|
|||
try {
|
||||
sheet.innerText = style;
|
||||
sheet.innerHTML = style;
|
||||
// eslint-disable-next-line no-unused-vars -- old browsers require binding this variable, even if unused
|
||||
} catch (e) {
|
||||
try {
|
||||
sheet.styleSheet.cssText = style;
|
||||
// eslint-disable-next-line no-unused-vars -- old browser require binding this variable, even if unused
|
||||
} catch (ex) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { deepFreeze } from "discourse-common/lib/object";
|
||||
import { AUTO_GROUPS } from "discourse/lib/constants";
|
||||
import { deepFreeze } from "discourse-common/lib/object";
|
||||
|
||||
export default {
|
||||
"/session/current.json": deepFreeze({
|
||||
|
|
|
@ -146,4 +146,4 @@ export default {
|
|||
avatar_template: "/letter_avatar_proxy/v4/letter/o/f05b48/{size}.png"
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/* eslint-disable ember/require-tagless-components */
|
||||
/* eslint-disable ember/no-classic-classes */
|
||||
/* eslint-disable ember/no-classic-components */
|
||||
|
||||
import GlimmerComponent from "@glimmer/component";
|
||||
import ClassicComponent from "@ember/component";
|
||||
|
|
|
@ -212,7 +212,7 @@ module("Unit | Utility | transformers", function (hooks) {
|
|||
try {
|
||||
testCallback();
|
||||
return true;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
@ -781,7 +781,7 @@ module("Unit | Utility | transformers", function (hooks) {
|
|||
try {
|
||||
testCallback();
|
||||
return true;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -61,7 +61,7 @@ module("Unit | Utils | multi-cache", function (hooks) {
|
|||
|
||||
try {
|
||||
await response1;
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
|
||||
const response2 = cache.fetch([10]);
|
||||
assert.strictEqual(requests.length, 1);
|
||||
|
|
|
@ -1,5 +1 @@
|
|||
/* eslint-disable */
|
||||
|
||||
// Polyfills for old browsers can be added here
|
||||
|
||||
/* eslint-enable */
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import DiscourseRecommended from "@discourse/lint-configs/eslint";
|
||||
|
||||
export default [
|
||||
...DiscourseRecommended,
|
||||
{
|
||||
rules: {
|
||||
"ember/no-classic-classes": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: [
|
||||
"app/assets/javascripts/ember-addons/",
|
||||
"lib/javascripts/locale/*",
|
||||
"lib/javascripts/messageformat.js",
|
||||
"lib/javascripts/messageformat-lookup.js",
|
||||
"plugins/**/lib/javascripts/locale",
|
||||
"public/",
|
||||
"vendor/",
|
||||
"app/assets/javascripts/discourse/tests/fixtures",
|
||||
"**/node_modules/",
|
||||
"spec/",
|
||||
"app/assets/javascripts/discourse/dist/",
|
||||
"tmp/",
|
||||
],
|
||||
},
|
||||
];
|
|
@ -25,7 +25,7 @@ pre-commit:
|
|||
eslint:
|
||||
glob: "*.js"
|
||||
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
|
||||
run: pnpm eslint -f compact --quiet {staged_files}
|
||||
run: pnpm eslint --quiet {staged_files}
|
||||
ember-template-lint:
|
||||
glob: "*.hbs"
|
||||
include: "app/assets/javascripts|plugins/.+?/assets/javascripts"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"license": "GPL-2.0-only",
|
||||
"devDependencies": {
|
||||
"@babel/plugin-proposal-decorators": "^7.25.9",
|
||||
"@discourse/lint-configs": "^1.4.2",
|
||||
"@discourse/lint-configs": "^2.0.1",
|
||||
"@discourse/moment-timezone-names-translations": "^1.0.0",
|
||||
"@fortawesome/fontawesome-free": "6.6.0",
|
||||
"@glint/core": "^1.5.0",
|
||||
|
@ -22,7 +22,7 @@
|
|||
"concurrently": "^9.1.0",
|
||||
"ember-template-lint": "^6.0.0",
|
||||
"esbuild": "^0.24.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint": "^9.14.0",
|
||||
"jsdoc": "^4.0.4",
|
||||
"lefthook": "^1.8.2",
|
||||
"licensee": "^11.1.0",
|
||||
|
@ -73,8 +73,6 @@
|
|||
},
|
||||
"peerDependencyRules": {
|
||||
"allowedVersions": {
|
||||
"@discourse/lint-configs>eslint": "*",
|
||||
"@discourse/lint-configs>prettier": "*",
|
||||
"lint-to-the-future-eslint>eslint": "*",
|
||||
"@mixer/parallel-prettier>prettier": "*",
|
||||
"lint-to-the-future-ember-template>ember-template-lint": "*",
|
||||
|
|
|
@ -31,7 +31,7 @@ export default class ChatAudioManager extends Service {
|
|||
const audio = new Audio(src);
|
||||
try {
|
||||
await audio.play();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (!isTesting()) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
|
|
|
@ -42,7 +42,7 @@ export default class ChatDraftsManager extends Service {
|
|||
threadId,
|
||||
});
|
||||
message.draftSaved = true;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// We don't want to throw an error if the draft fails to save
|
||||
}
|
||||
}
|
||||
|
|
1321
pnpm-lock.yaml
1321
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue