diff --git a/.eslintrc.js b/.eslintrc.js index 8dba4cb1bb..35eb360126 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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': [ @@ -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', diff --git a/extensions/src/hello-world/src/checks.ts b/extensions/src/hello-world/src/checks.ts index 7ac219f46d..0a427e3cc6 100644 --- a/extensions/src/hello-world/src/checks.ts +++ b/extensions/src/hello-world/src/checks.ts @@ -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; } diff --git a/extensions/src/hello-world/src/main.ts b/extensions/src/hello-world/src/main.ts index 6e08958066..e1a38fb52e 100644 --- a/extensions/src/hello-world/src/main.ts +++ b/extensions/src/hello-world/src/main.ts @@ -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 { @@ -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 { diff --git a/extensions/src/hello-world/src/models/hello-world-project-data-provider-engine.model.ts b/extensions/src/hello-world/src/models/hello-world-project-data-provider-engine.model.ts index e32ca9ad8f..e03cfa411c 100644 --- a/extensions/src/hello-world/src/models/hello-world-project-data-provider-engine.model.ts +++ b/extensions/src/hello-world/src/models/hello-world-project-data-provider-engine.model.ts @@ -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 > { diff --git a/extensions/src/paratext-registration/src/paratext-registration.web-view-provider.ts b/extensions/src/paratext-registration/src/paratext-registration.web-view-provider.ts index 5ed1c89b85..39be71c4fa 100644 --- a/extensions/src/paratext-registration/src/paratext-registration.web-view-provider.ts +++ b/extensions/src/paratext-registration/src/paratext-registration.web-view-provider.ts @@ -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 { if (savedWebView.webViewType !== paratextRegistrationWebViewType) throw new Error( diff --git a/extensions/src/platform-scripture/src/checks/check-aggregator.service.ts b/extensions/src/platform-scripture/src/checks/check-aggregator.service.ts index f7d6abfc68..89b105f60e 100644 --- a/extensions/src/platform-scripture/src/checks/check-aggregator.service.ts +++ b/extensions/src/platform-scripture/src/checks/check-aggregator.service.ts @@ -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> { throw new Error('setAvailableChecks disabled'); } @@ -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> { throw new Error('setCheckResults disabled'); } diff --git a/extensions/src/platform-scripture/src/checks/extension-host-check-runner.service.ts b/extensions/src/platform-scripture/src/checks/extension-host-check-runner.service.ts index e8f1c14f52..3d5569ea02 100644 --- a/extensions/src/platform-scripture/src/checks/extension-host-check-runner.service.ts +++ b/extensions/src/platform-scripture/src/checks/extension-host-check-runner.service.ts @@ -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> { throw new Error('setAvailableChecks disabled - use enableCheck and disableCheck'); } @@ -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> { throw new Error('setCheckResults disabled'); } diff --git a/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpe.model.ts b/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpe.model.ts index ab12187a84..5ff0cf24f5 100644 --- a/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpe.model.ts +++ b/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpe.model.ts @@ -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> { throw new Error('Cannot call setVerseUSJ, use setChapterUSJ or setBookUSJ instead'); } diff --git a/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpef.model.ts b/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpef.model.ts index c5b6ebd44b..17988917c2 100644 --- a/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpef.model.ts +++ b/extensions/src/platform-scripture/src/project-data-provider/platform-scripture-extender-pdpef.model.ts @@ -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> { diff --git a/extensions/src/quick-verse/src/main.ts b/extensions/src/quick-verse/src/main.ts index daa5fa4359..0a677ae1ce 100644 --- a/extensions/src/quick-verse/src/main.ts +++ b/extensions/src/quick-verse/src/main.ts @@ -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; diff --git a/src/extension-host/services/localization.service-host.ts b/src/extension-host/services/localization.service-host.ts index f53f2a22d3..fbd66d9ae7 100644 --- a/src/extension-host/services/localization.service-host.ts +++ b/src/extension-host/services/localization.service-host.ts @@ -243,7 +243,7 @@ class LocalizationDataProviderEngine implements IDataProviderEngine { // 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(); @@ -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> { 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> { throw new Error('setLocalizedStrings disabled'); } diff --git a/src/extension-host/services/menu-data.service-host.ts b/src/extension-host/services/menu-data.service-host.ts index 2d75ca40da..49efd9933f 100644 --- a/src/extension-host/services/menu-data.service-host.ts +++ b/src/extension-host/services/menu-data.service-host.ts @@ -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> { throw new Error('setMainMenu disabled'); } @@ -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> { throw new Error('setWebViewMenu disabled'); } diff --git a/src/extension-host/services/settings.service-host.ts b/src/extension-host/services/settings.service-host.ts index 273bde005c..7de212a07e 100644 --- a/src/extension-host/services/settings.service-host.ts +++ b/src/extension-host/services/settings.service-host.ts @@ -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(); @@ -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( key: SettingName, newValue: SettingTypes[SettingName], diff --git a/src/shared/models/data-provider-engine.model.ts b/src/shared/models/data-provider-engine.model.ts index 4325ccac21..24b964c754 100644 --- a/src/shared/models/data-provider-engine.model.ts +++ b/src/shared/models/data-provider-engine.model.ts @@ -161,6 +161,6 @@ export abstract class DataProviderEngine): void {} } diff --git a/src/shared/utils/localized-strings-document-combiner.ts b/src/shared/utils/localized-strings-document-combiner.ts index 9bd8e60601..72294879b0 100644 --- a/src/shared/utils/localized-strings-document-combiner.ts +++ b/src/shared/utils/localized-strings-document-combiner.ts @@ -87,14 +87,10 @@ export default class LocalizedStringsDocumentCombiner extends DocumentCombiner { ) as T extends string ? LanguageStrings | undefined : LocalizedStringDataContribution; } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateBaseDocument(baseDocument: JsonDocumentLike): void { performSchemaValidation(baseDocument, PLATFORM_NAMESPACE); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override transformBaseDocumentAfterValidation( baseDocument: JsonDocumentLike, ): JsonDocumentLike { @@ -105,14 +101,10 @@ export default class LocalizedStringsDocumentCombiner extends DocumentCombiner { ); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateContribution(_documentName: string, document: JsonDocumentLike): void { performSchemaValidation(document, PLATFORM_NAMESPACE); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override transformContributionAfterValidation( _documentName: string, document: JsonDocumentLike, @@ -124,8 +116,6 @@ export default class LocalizedStringsDocumentCombiner extends DocumentCombiner { ); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateOutput(output: JsonDocumentLike): void { performSchemaValidation(output, 'output'); } diff --git a/src/shared/utils/menu-document-combiner.ts b/src/shared/utils/menu-document-combiner.ts index 32b22465f0..3112aafc59 100644 --- a/src/shared/utils/menu-document-combiner.ts +++ b/src/shared/utils/menu-document-combiner.ts @@ -276,8 +276,6 @@ export default class MenuDocumentCombiner extends DocumentCombiner { return retVal; } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateBaseDocument(baseDocument: JsonDocumentLike): void { // The starting document has to validate against the output schema, too performSchemaValidation(baseDocument, 'starting'); @@ -343,8 +341,6 @@ export default class MenuDocumentCombiner extends DocumentCombiner { // TODO: Validate that extensions only add to objects that are marked as extensible } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateOutput(output: JsonDocumentLike): void { performSchemaValidation(output, 'output'); // Once the schema has been validated, we know the type should match @@ -371,8 +367,6 @@ export default class MenuDocumentCombiner extends DocumentCombiner { } // Combine the webview menu defaults for any web views that indicate that is desired - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override transformFinalOutputBeforeValidation( finalOutput: JsonDocumentLike, ): JsonDocumentLike { diff --git a/src/shared/utils/project-settings-document-combiner.ts b/src/shared/utils/project-settings-document-combiner.ts index 1573d1ab88..652700a955 100644 --- a/src/shared/utils/project-settings-document-combiner.ts +++ b/src/shared/utils/project-settings-document-combiner.ts @@ -93,8 +93,6 @@ export default class ProjectSettingsDocumentCombiner extends SettingsDocumentCom >; } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override performSchemaValidation(document: JsonDocumentLike, docType: string): void { performSchemaValidation(document, docType); } diff --git a/src/shared/utils/settings-document-combiner-base.ts b/src/shared/utils/settings-document-combiner-base.ts index b00dc49a4e..fd8aa0d620 100644 --- a/src/shared/utils/settings-document-combiner-base.ts +++ b/src/shared/utils/settings-document-combiner-base.ts @@ -189,14 +189,10 @@ export default abstract class SettingsDocumentCombinerBase extends DocumentCombi return this.localizedOutputPromise; } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateBaseDocument(baseDocument: JsonDocumentLike): void { this.performSchemaValidation(baseDocument, PLATFORM_NAMESPACE); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override transformBaseDocumentAfterValidation( baseDocument: JsonDocumentLike, ): JsonDocumentLike { @@ -208,8 +204,6 @@ export default abstract class SettingsDocumentCombinerBase extends DocumentCombi ); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateContribution(documentName: string, document: JsonDocumentLike): void { // Make sure it is a SettingsContribution this.performSchemaValidation(document, documentName); @@ -241,8 +235,6 @@ export default abstract class SettingsDocumentCombinerBase extends DocumentCombi ); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override transformContributionAfterValidation( documentName: string, document: JsonDocumentLike, @@ -255,8 +247,6 @@ export default abstract class SettingsDocumentCombinerBase extends DocumentCombi ); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override validateOutput(): void { // We already validated input documents and built the output ourselves, so we don't have any more // validating to do. Unless someday we want to double check we have a properly formatted diff --git a/src/shared/utils/settings-document-combiner.ts b/src/shared/utils/settings-document-combiner.ts index 4ba892bf84..5cf8e56c87 100644 --- a/src/shared/utils/settings-document-combiner.ts +++ b/src/shared/utils/settings-document-combiner.ts @@ -54,8 +54,6 @@ export default class SettingsDocumentCombiner extends SettingsDocumentCombinerBa return this.getLocalizedOutput(); } - // We don't need `this` on this override method - // eslint-disable-next-line class-methods-use-this protected override performSchemaValidation(document: JsonDocumentLike, docType: string): void { performSchemaValidation(document, docType); }