Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update to eslint9 #207

Merged
merged 6 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .eslintrc.json

This file was deleted.

23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { addExtensions, browserConfig, setDirectoryConfigs, testingConfig } from 'eslint-config-brightspace';

export default [
...addExtensions(setDirectoryConfigs(
browserConfig,
{
'test': testingConfig
}
), ['js']),
{
files: ['helpers/getLocalizeResources.js'],

rules: {
'no-console': 0,
},
},
{
files: ['lang/*.js'],
rules: {
'quotes': 0
}
}
];
2 changes: 1 addition & 1 deletion helpers/getLocalizeResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async function shouldUseBatchFetch() {
// subsequent page navigation.

return Boolean(documentLocaleSettings.oslo.batch) && 'CacheStorage' in window;
} catch (err) {
} catch {
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/PluralRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ class PluralRules extends Intl.PluralRules {
this.#localeData = localeData[this.#locale];
}
}

resolvedOptions() {
return { ...super.resolvedOptions(), ...this.#localeData?.options[this.#type] };
}

select(n) {
if (this.#localeData) {
return this.#localeData.select(n, this.#type === 'ordinal');
Expand Down
2 changes: 1 addition & 1 deletion lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class DocumentLocaleSettings {
if (this._htmlElem.hasAttribute(attrName)) {
try {
return JSON.parse(this._htmlElem.getAttribute(attrName));
} catch (e) {
} catch {
// swallow exception
}
}
Expand Down
7 changes: 0 additions & 7 deletions lib/localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const noAllowedTagsRegex = getDisallowedTagsRegex([]);
export const getLocalizeClass = (superclass = class {}) => class LocalizeClass extends superclass {

static documentLocaleSettings = getDocumentLocaleSettings();

static setLocalizeMarkup(localizeMarkup) {
this.#localizeMarkup ??= localizeMarkup;
}
Expand All @@ -48,12 +47,10 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
this.#connected = true;
this.#localeChangeCallback();
}

disconnect() {
LocalizeClass.documentLocaleSettings.removeChangeListener(this.#localeChangeCallback);
this.#connected = false;
}

localize(name, replacements) {

const { language, value } = this.localize.resources?.[name] ?? {};
Expand Down Expand Up @@ -132,7 +129,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
#resourcesPromise;

__resourcesLoadedPromise = new Promise(r => this.#resolveResourcesLoaded = r);

static _generatePossibleLanguages(config) {

if (config?.useBrowserLangs) return navigator.languages.map(e => e.toLowerCase()).concat('en');
Expand All @@ -145,7 +141,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e

return Array.from(new Set([ ...langs, 'en-us', 'en' ]));
}

static _getAllLocalizeResources(config = this.localizeConfig) {
const resourcesLoadedPromises = [];
const superCtor = Object.getPrototypeOf(this);
Expand All @@ -172,7 +167,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
}
return Promise.all(resourcesLoadedPromises);
}

static async _getLocalizeResources(langs, { importFunc, osloCollection, useBrowserLangs }) {

if (importFunc === undefined) return;
Expand Down Expand Up @@ -203,7 +197,6 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
}
}
}

_hasResources() {
if (this.constructor.localizeConfig) {
return this.constructor.localizeConfig !== undefined ||
Expand Down
Loading