Skip to content

Commit 42fac27

Browse files
authored
chore: Adopt no-unused-vars-experimental for eslint to prevent incorrect linting errors (#981)
1 parent 69c268f commit 42fac27

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

.eslintrc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
// Disabled checks
3434
'@typescript-eslint/no-explicit-any': 0,
3535
'@typescript-eslint/no-use-before-define': 0,
36+
'@typescript-eslint/no-unused-vars': 0,
3637

3738
// Required checks
3839
'indent': ['error', 2],
@@ -46,5 +47,12 @@ module.exports = {
4647
'allowHigherOrderFunctions': true
4748
}
4849
],
49-
}
50+
'@typescript-eslint/no-unused-vars-experimental': 2,
51+
},
52+
// Required by the @typescript-eslint/no-unused-vars-experimental rule.
53+
// We use a separate tsconfig file for linting to reduce the time complexity of the operation.
54+
// See github.com/typescript-eslint/typescript-eslint/issues/1320
55+
parserOptions: {
56+
project: './tsconfig.eslint.json',
57+
},
5058
};

src/database.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,11 +1631,9 @@ export namespace admin.database {
16311631
*/
16321632
interface ThenableReference extends admin.database.Reference, Promise<admin.database.Reference> { }
16331633

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

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

16411639
/**

src/instance-id.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as _admin from './index.d';
22

3-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
43
export namespace admin.instanceId {
54
/**
65
* Gets the {@link InstanceId `InstanceId`} service for the

src/machine-learning/machine-learning.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ export class Model {
285285
return false;
286286
}
287287

288-
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
289-
public waitForUnlocked(maxTimeSeconds?: number): Promise<void> {
288+
public waitForUnlocked(_maxTimeSeconds?: number): Promise<void> {
290289
// Backend does not currently return locked models.
291290
// This will likely change in future.
292291
return Promise.resolve();

src/remote-config.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as _admin from './index.d';
22

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

65
/**

test/integration/database.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ describe('admin.database', () => {
173173
// Check for type compilation. This method is not invoked by any tests. But it
174174
// will trigger a TS compilation failure if the RTDB typings were not loaded
175175
// correctly. (Marked as export to avoid compilation warning.)
176-
//
177-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
178176
export function addValueEventListener(
179177
db: admin.database.Database,
180178
callback: (s: admin.database.DataSnapshot | null) => any): void {

test/resources/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export function generateSessionCookie(overrides?: object, expiresIn?: number): s
221221

222222
export function firebaseServiceFactory(
223223
firebaseApp: FirebaseApp,
224-
extendApp?: (props: object) => void, // eslint-disable-line @typescript-eslint/no-unused-vars
224+
_extendApp?: (props: object) => void,
225225
): FirebaseServiceInterface {
226226
const result = {
227227
app: firebaseApp,

tsconfig.eslint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Used for @typescript-eslint/no-unused-vars-experimental to glob the entire
2+
// source. An alternative is createDefaultProgram: true but it has exponential
3+
// complexity. See: github.com/typescript-eslint/typescript-eslint/issues/967
4+
{
5+
"compilerOptions": {
6+
"strict": true,
7+
},
8+
"include": [
9+
"src/**/*.ts",
10+
"test/**/*.ts",
11+
],
12+
}

0 commit comments

Comments
 (0)