Skip to content

Commit

Permalink
improve linting (#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
irahopkinson authored Nov 14, 2024
2 parents 033d973 + 3ea429c commit 71bcb05
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 63 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -75,6 +79,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
7 changes: 6 additions & 1 deletion extensions/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/hello-someone/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/hello-world/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/hello-world/src/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HelloCheck implements Check {
return true;
}

// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
getCheckDetails(): CheckDetails {
return checkDetails;
}
Expand Down
8 changes: 2 additions & 6 deletions extensions/src/hello-world/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ class HelloWorldProjectWebViewFactory extends WebViewFactory<
super(HELLO_WORLD_PROJECT_WEB_VIEW_TYPE);
}

// No need to use `this` and implementing an abstract method so can't be static
// eslint-disable-next-line class-methods-use-this
async getWebViewDefinition(
override async getWebViewDefinition(
savedWebView: SavedWebViewDefinition,
getWebViewOptions: HelloWorldProjectOptions,
): Promise<WebViewDefinition | undefined> {
Expand All @@ -130,9 +128,7 @@ class HelloWorldProjectWebViewFactory extends WebViewFactory<
};
}

// No need to use `this` and implementing an abstract method so can't be static
// eslint-disable-next-line class-methods-use-this
async createWebViewController(
override async createWebViewController(
webViewDefinition: WebViewDefinition,
webViewNonce: string,
): Promise<HelloWorldProjectWebViewController> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class HelloWorldProjectDataProviderEngine
return newNumber;
}

// eslint-disable-next-line class-methods-use-this
// Required method since this is a data provider engine
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setNames(): Promise<
DataProviderUpdateInstructions<ProjectInterfaceDataTypes['helloWorld']>
> {
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/legacy-comment-manager/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/paratext-registration/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const tooltipKey = '%paratextRegistration_webView_tooltip%';

export default class ParatextRegistrationWebViewProvider implements IWebViewProvider {
// needs to be a class method, not static method
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async getWebView(savedWebView: SavedWebViewDefinition): Promise<WebViewDefinition | undefined> {
if (savedWebView.webViewType !== paratextRegistrationWebViewType)
throw new Error(
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/platform-scripture-editor/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/platform-scripture/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CheckDataProviderEngine
lastRangesSet: CheckInputRange[] = [];

// Required method since this is a data provider engine
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setAvailableChecks(): Promise<DataProviderUpdateInstructions<CheckRunnerDataTypes>> {
throw new Error('setAvailableChecks disabled');
}
Expand All @@ -46,7 +46,7 @@ class CheckDataProviderEngine
}

// Required method since this is a data provider engine
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setCheckResults(): Promise<DataProviderUpdateInstructions<CheckRunnerDataTypes>> {
throw new Error('setCheckResults disabled');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CheckRunnerEngine
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setAvailableChecks(): Promise<DataProviderUpdateInstructions<CheckRunnerDataTypes>> {
throw new Error('setAvailableChecks disabled - use enableCheck and disableCheck');
}
Expand Down Expand Up @@ -221,7 +221,7 @@ class CheckRunnerEngine
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setCheckResults(): Promise<DataProviderUpdateInstructions<CheckRunnerDataTypes>> {
throw new Error('setCheckResults disabled');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class ScriptureExtenderProjectDataProviderEngine
return false;
}

// eslint-disable-next-line class-methods-use-this
// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setVerseUSJ(): Promise<DataProviderUpdateInstructions<USJVerseProjectInterfaceDataTypes>> {
throw new Error('Cannot call setVerseUSJ, use setChapterUSJ or setBookUSJ instead');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ScriptureExtenderProjectDataProviderEngineFactory
providedProjectInterfaces = SCRIPTURE_EXTENDER_PROJECT_INTERFACES;

// Implementing an interface method, so can't be static
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async createProjectDataProviderEngine(
projectId: string,
): Promise<IProjectDataProviderEngine<typeof SCRIPTURE_EXTENDER_PROJECT_INTERFACES>> {
Expand Down
7 changes: 6 additions & 1 deletion extensions/src/quick-verse/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ module.exports = {
// Rules in each section are generally in alphabetical order. However, several
// `@typescript-eslint` rules require disabling the equivalent ESLint rule. So in these cases
// each ESLint rule is turned off immediately above the corresponding `@typescript-eslint` rule.
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': [
'error',
{ ignoreOverrideMethods: true, ignoreClassesThatImplementAnInterface: false },
],
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': [
Expand Down Expand Up @@ -76,6 +80,7 @@ module.exports = {
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'comma-dangle': ['error', 'always-multiline'],
'import/no-anonymous-default-export': ['error', { allowCallExpression: false }],
indent: 'off',
'jsx-a11y/label-has-associated-control': [
'error',
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/quick-verse/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class QuickVerseDataProviderEngine
* @returns False meaning do not update anything
*/
// Does nothing, so we don't need to use `this`
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setChapter() {
// We are not supporting setting chapters now, so don't update anything
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/extension-host/services/localization.service-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class LocalizationDataProviderEngine
implements IDataProviderEngine<LocalizationDataDataTypes>
{
// This method legitimately does not need to call anything else in this class as of now
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async getLocalizedString({ localizeKey, locales = [] }: LocalizationSelector) {
const languages = locales.length > 0 ? [...locales] : await getDefaultLanguages();

Expand Down Expand Up @@ -300,13 +300,13 @@ class LocalizationDataProviderEngine
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setLocalizedString(): Promise<DataProviderUpdateInstructions<LocalizationDataDataTypes>> {
throw new Error('setLocalizedString disabled');
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setLocalizedStrings(): Promise<DataProviderUpdateInstructions<LocalizationDataDataTypes>> {
throw new Error('setLocalizedStrings disabled');
}
Expand Down
4 changes: 2 additions & 2 deletions src/extension-host/services/menu-data.service-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MenuDataDataProviderEngine
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setMainMenu(): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>> {
throw new Error('setMainMenu disabled');
}
Expand All @@ -68,7 +68,7 @@ class MenuDataDataProviderEngine
}

// Because this is a data provider, we have to provide this method even though it always throws
// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async setWebViewMenu(): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>> {
throw new Error('setWebViewMenu disabled');
}
Expand Down
5 changes: 3 additions & 2 deletions src/extension-host/services/settings.service-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ class SettingDataProviderEngine
);
}

// eslint-disable-next-line class-methods-use-this
/* eslint-disable @typescript-eslint/class-methods-use-this */
@dataProviders.decorators.ignore
async getLocalizedSettingsContributionInfo(): Promise<
/* eslint-enable */
LocalizedSettingsContributionInfo | undefined
> {
return settingsDocumentCombiner.getLocalizedSettingsContributionInfo();
Expand Down Expand Up @@ -174,7 +175,7 @@ class SettingDataProviderEngine
return true;
}

// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
async validateSetting<SettingName extends SettingNames>(
key: SettingName,
newValue: SettingTypes[SettingName],
Expand Down
2 changes: 1 addition & 1 deletion src/shared/models/data-provider-engine.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,6 @@ export abstract class DataProviderEngine<TDataTypes extends DataProviderDataType
// @ts-expect-error ts(6133) `updateInstructions` is not used in this method, but we don't care
// because we want inheriting classes to be able to get this method with Intellisense without
// an underscore that indicates to TypeScript that we aren't using the parameter
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/class-methods-use-this, @typescript-eslint/no-unused-vars
notifyUpdate(updateInstructions?: DataProviderUpdateInstructions<TDataTypes>): void {}
}
Loading

0 comments on commit 71bcb05

Please sign in to comment.