Skip to content

chore: Adopt no-unused-vars-experimental for eslint to prevent incorrect linting errors #981

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

Merged
merged 6 commits into from
Aug 6, 2020
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
10 changes: 9 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
// Disabled checks
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-unused-vars': 0,

// Required checks
'indent': ['error', 2],
Expand All @@ -46,5 +47,12 @@ module.exports = {
'allowHigherOrderFunctions': true
}
],
}
'@typescript-eslint/no-unused-vars-experimental': 2,
},
// Required by the @typescript-eslint/no-unused-vars-experimental rule.
// We use a separate tsconfig file for linting to reduce the time complexity of the operation.
// See github.com/typescript-eslint/typescript-eslint/issues/1320
parserOptions: {
project: './tsconfig.eslint.json',
},
};
2 changes: 0 additions & 2 deletions src/database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,11 +1631,9 @@ export namespace admin.database {
*/
interface ThenableReference extends admin.database.Reference, Promise<admin.database.Reference> { }

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
function enableLogging(logger?: boolean | ((message: string) => any), persistent?: boolean): any;
}

/* eslint-disable @typescript-eslint/no-unused-vars */
export namespace admin.database.ServerValue {

/**
Expand Down
1 change: 0 additions & 1 deletion src/instance-id.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as _admin from './index.d';

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export namespace admin.instanceId {
/**
* Gets the {@link InstanceId `InstanceId`} service for the
Expand Down
3 changes: 1 addition & 2 deletions src/machine-learning/machine-learning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ export class Model {
return false;
}

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
public waitForUnlocked(maxTimeSeconds?: number): Promise<void> {
public waitForUnlocked(_maxTimeSeconds?: number): Promise<void> {
// Backend does not currently return locked models.
// This will likely change in future.
return Promise.resolve();
Expand Down
1 change: 0 additions & 1 deletion src/remote-config.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as _admin from './index.d';

/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export namespace admin.remoteConfig {

/**
Expand Down
2 changes: 0 additions & 2 deletions test/integration/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ describe('admin.database', () => {
// Check for type compilation. This method is not invoked by any tests. But it
// will trigger a TS compilation failure if the RTDB typings were not loaded
// correctly. (Marked as export to avoid compilation warning.)
//
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function addValueEventListener(
db: admin.database.Database,
callback: (s: admin.database.DataSnapshot | null) => any): void {
Expand Down
2 changes: 1 addition & 1 deletion test/resources/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export function generateSessionCookie(overrides?: object, expiresIn?: number): s

export function firebaseServiceFactory(
firebaseApp: FirebaseApp,
extendApp?: (props: object) => void, // eslint-disable-line @typescript-eslint/no-unused-vars
_extendApp?: (props: object) => void,
): FirebaseServiceInterface {
const result = {
app: firebaseApp,
Expand Down
12 changes: 12 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Used for @typescript-eslint/no-unused-vars-experimental to glob the entire
// source. An alternative is createDefaultProgram: true but it has exponential
// complexity. See: github.com/typescript-eslint/typescript-eslint/issues/967
{
"compilerOptions": {
"strict": true,
},
"include": [
"src/**/*.ts",
"test/**/*.ts",
],
}