Skip to content

Commit 3db6532

Browse files
Josh Goldbergbradzacher
andauthored
chore: enabled no-unsafe-member-access internally (typescript-eslint#3483)
* chore: enabled no-unsafe-member-access internally * Update packages/scope-manager/tests/util/serializers/TSESTreeNode.ts Co-authored-by: Brad Zacher <[email protected]> * fix: missing import * fix: one last lint disable * Update convert.ts * Update .eslintrc.js * Update .eslintrc.js Co-authored-by: Brad Zacher <[email protected]>
1 parent ddb11ac commit 3db6532

File tree

13 files changed

+22
-15
lines changed

13 files changed

+22
-15
lines changed

.eslintrc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ module.exports = {
6565
],
6666

6767
// TODO - enable these new recommended rules
68-
'@typescript-eslint/no-unsafe-member-access': 'off',
6968
'@typescript-eslint/restrict-template-expressions': 'off',
7069
// TODO - enable this
7170
'@typescript-eslint/naming-convention': 'off',
@@ -163,15 +162,18 @@ module.exports = {
163162
// all test files
164163
{
165164
files: [
166-
'packages/*/tests/**/*.test.ts',
167165
'packages/*/tests/**/*.spec.ts',
166+
'packages/*/tests/**/*.test.ts',
167+
'packages/*/tests/**/spec.ts',
168+
'packages/*/tests/**/test.ts',
168169
'packages/parser/tests/**/*.ts',
169170
],
170171
env: {
171172
'jest/globals': true,
172173
},
173174
rules: {
174175
'@typescript-eslint/no-unsafe-assignment': 'off',
176+
'@typescript-eslint/no-unsafe-member-access': 'off',
175177
'@typescript-eslint/no-unsafe-return': 'off',
176178
'eslint-plugin/no-identical-tests': 'error',
177179
'jest/no-disabled-tests': 'warn',
@@ -198,6 +200,7 @@ module.exports = {
198200
rules: {
199201
'@typescript-eslint/explicit-function-return-type': 'off',
200202
'@typescript-eslint/no-unsafe-call': 'off',
203+
'@typescript-eslint/no-unsafe-member-access': 'off',
201204
'@typescript-eslint/no-unsafe-return': 'off',
202205
'@typescript-eslint/restrict-plus-operands': 'off',
203206
},

packages/eslint-plugin/src/util/createRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ESLintUtils } from '@typescript-eslint/experimental-utils';
22

33
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
4-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
4+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
55
const version: string = require('../../package.json').version;
66

77
export const createRule = ESLintUtils.RuleCreator(

packages/experimental-utils/src/eslint-utils/RuleTester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class RuleTester extends TSESLint.RuleTester {
3232
try {
3333
// instead of creating a hard dependency, just use a soft require
3434
// a bit weird, but if they're using this tooling, it'll be installed
35-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
35+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
3636
require(parser).clearCaches();
3737
} catch {
3838
// ignored

packages/parser/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export {
66
} from '@typescript-eslint/typescript-estree';
77

88
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
9-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
9+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
1010
export const version: string = require('../package.json').version;

packages/scope-manager/tests/util/serializers/TSESTreeNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AST_NODE_TYPES } from '@typescript-eslint/types';
1+
import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types';
22
import { NewPlugin } from 'pretty-format';
33
import { createIdGenerator } from '../../../src/ID';
44

@@ -24,7 +24,7 @@ const serializer: NewPlugin = {
2424
// make sure it's not one of the classes from the package
2525
Object.getPrototypeOf(val) === Object.prototype &&
2626
'type' in val &&
27-
val.type in AST_NODE_TYPES
27+
(val as TSESTree.Node).type in AST_NODE_TYPES
2828
);
2929
},
3030
serialize(node: Node): string {

packages/typescript-estree/src/convert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// There's lots of funny stuff due to the typing of ts.Node
2-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return */
2+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access */
33
import * as ts from 'typescript';
44
import {
55
canContainDirective,

packages/typescript-estree/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export { createProgramFromConfigFile as createProgram } from './create-program/u
99
export { visitorKeys } from '@typescript-eslint/visitor-keys';
1010

1111
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
12-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
12+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
1313
export const version: string = require('../package.json').version;

packages/typescript-estree/src/node-utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,7 @@ export function nodeHasTokens(n: ts.Node, ast: ts.SourceFile): boolean {
632632
// If we have a token or node that has a non-zero width, it must have tokens.
633633
// Note: getWidth() does not take trivia into account.
634634
return n.kind === SyntaxKind.EndOfFileToken
635-
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
636-
!!(n as any).jsDoc
635+
? !!(n as ts.JSDocContainer).jsDoc
637636
: n.getWidth(ast) !== 0;
638637
}
639638

packages/typescript-estree/src/semantic-or-syntactic-errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function getFirstSemanticOrSyntacticError(
4545
* and log a a warning.
4646
*/
4747
/* istanbul ignore next */
48-
console.warn(`Warning From TSC: "${e.message}`); // eslint-disable-line no-console
48+
console.warn(`Warning From TSC: "${(e as Error).message}`); // eslint-disable-line no-console
4949
/* istanbul ignore next */
5050
return undefined;
5151
}

packages/typescript-estree/src/simple-traverse.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TSESTree } from './ts-estree';
33

44
// eslint-disable-next-line @typescript-eslint/no-explicit-any
55
function isValidNode(x: any): x is TSESTree.Node {
6+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
67
return x !== null && typeof x === 'object' && typeof x.type === 'string';
78
}
89

packages/typescript-estree/tests/ast-alignment/parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
1+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
22

33
import type babelParser from '@babel/parser';
44
import { ParserPlugin } from '@babel/parser';

packages/typescript-estree/tests/ast-alignment/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// babel types are something we don't really care about
2-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/restrict-plus-operands */
2+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-plus-operands */
33
import { AST_NODE_TYPES, TSESTree } from '../../src/ts-estree';
44
import { deeplyCopy, omitDeep } from '../../tools/test-utils';
55
import * as BabelTypes from '@babel/types';
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import 'typescript';
22

3+
// these additions are marked as internal to typescript
34
declare module 'typescript' {
45
interface SourceFile {
5-
// this is marked as internal to typescript
66
externalModuleIndicator?: Node;
77
parseDiagnostics: DiagnosticWithLocation[];
88
}
9+
10+
interface JSDocContainer {
11+
jsDoc?: JSDoc[];
12+
}
913
}

0 commit comments

Comments
 (0)