Skip to content

Commit

Permalink
chore: enable no-unsafe-call locally (#3281)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Goldberg committed Apr 19, 2021
1 parent 26d71b5 commit b4cf0da
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -64,7 +64,6 @@ module.exports = {

// TODO - enable these new recommended rules
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
Expand Down Expand Up @@ -191,6 +190,8 @@ module.exports = {
{
files: ['tests/**/*.js'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
},
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -84,6 +84,7 @@
"@types/lodash": "^4.14.149",
"@types/marked": "^2.0.0",
"@types/node": "^14.14.27",
"@types/node-fetch": "^2.5.10",
"@types/prettier": "^2.2.1",
"@types/rimraf": "^3.0.0",
"@types/semver": "^7.3.4",
Expand All @@ -99,13 +100,13 @@
"eslint-plugin-jest": "^24.1.3",
"glob": "^7.1.6",
"husky": "^5.0.9",
"isomorphic-fetch": "^3.0.0",
"jest": "^26.6.3",
"jest-specific-snapshot": "^4.0.0",
"lerna": "^3.22.1",
"lint-staged": "^10.2.13",
"make-dir": "^3.1.0",
"markdownlint-cli": "^0.27.1",
"node-fetch": "^2.6.1",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.1",
Expand Down
7 changes: 2 additions & 5 deletions packages/eslint-plugin-tslint/src/custom-linter.ts
@@ -1,11 +1,8 @@
import { ILinterOptions, Linter, LintResult } from 'tslint';
import { Program, SourceFile } from 'typescript';

// We need to access the program, but Linter has private program already
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const TSLintLinter = Linter as any;

export class CustomLinter extends TSLintLinter {
// @ts-expect-error - We need to access the program, but Linter has private program already
export class CustomLinter extends Linter {
constructor(options: ILinterOptions, private readonly program: Program) {
super(options, program);
}
Expand Down
1 change: 1 addition & 0 deletions packages/experimental-utils/src/eslint-utils/RuleTester.ts
Expand Up @@ -32,6 +32,7 @@ class RuleTester extends TSESLint.RuleTester {
try {
// instead of creating a hard dependency, just use a soft require
// a bit weird, but if they're using this tooling, it'll be installed
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
require(parser).clearCaches();
} catch {
// ignored
Expand Down
6 changes: 3 additions & 3 deletions packages/parser/tests/tools/test-utils.ts
Expand Up @@ -53,13 +53,13 @@ export function createSnapshotTestBlock(
try {
const result = parse();
expect(result).toMatchSnapshot();
} catch (e) {
} catch (error) {
/**
* If we are deliberately throwing because of encountering an unknown
* AST_NODE_TYPE, we rethrow to cause the test to fail
*/
if (e.message.match('Unknown AST_NODE_TYPE')) {
throw new Error(e);
if (/Unknown AST_NODE_TYPE/.exec((error as Error).message)) {
throw new Error(error);
}
expect(parse).toThrowErrorMatchingSnapshot();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/convert.ts
@@ -1,5 +1,5 @@
// There's lots of funny stuff due to the typing of ts.Node
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-call */
import * as ts from 'typescript';
import {
canContainDirective,
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/tests/lib/convert.test.ts
@@ -1,5 +1,5 @@
// deeplyCopy is private internal
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-call */
import { Converter } from '../../src/convert';
import * as ts from 'typescript';

Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/tests/lib/parse.test.ts
Expand Up @@ -506,7 +506,7 @@ describe('parseAndGenerateServices', () => {
/**
* Aligns paths between environments, node for windows uses `\`, for linux and mac uses `/`
*/
error.message = error.message.replace(/\\(?!["])/gm, '/');
error.message = (error as Error).message.replace(/\\(?!["])/gm, '/');
throw error;
}
};
Expand Down
6 changes: 3 additions & 3 deletions packages/typescript-estree/tools/test-utils.ts
Expand Up @@ -35,13 +35,13 @@ export function createSnapshotTestBlock(
try {
const result = parse();
expect(result).toMatchSnapshot();
} catch (e) {
} catch (error) {
/**
* If we are deliberately throwing because of encountering an unknown
* AST_NODE_TYPE, we rethrow to cause the test to fail
*/
if (e.message.match('Unknown AST_NODE_TYPE')) {
throw new Error(e);
if (/Unknown AST_NODE_TYPE/.exec((error as Error).message)) {
throw new Error(error);
}
expect(parse).toThrowErrorMatchingSnapshot();
}
Expand Down
1 change: 0 additions & 1 deletion tests/integration/utils/jest-snapshot-resolver.js
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/**
* Use a jest snapshotResolver to map the test snapshot output back to the
* linked volume. This means that even though we are running our tests inside
Expand Down
2 changes: 1 addition & 1 deletion tools/generate-contributors.ts
Expand Up @@ -3,7 +3,7 @@
// this endpoint returns a list of contributors sorted by number of contributions

import * as fs from 'fs';
import 'isomorphic-fetch';
import fetch from 'node-fetch';
import * as path from 'path';

const IGNORED_USERS = new Set([
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.eslint.json
@@ -1,4 +1,7 @@
{
"compilerOptions": {
"types": ["@types/node"]
},
"extends": "./tsconfig.base.json",
"include": ["tests/**/*.ts", "tools/**/*.ts", ".eslintrc.js"]
}
32 changes: 18 additions & 14 deletions yarn.lock
Expand Up @@ -1932,6 +1932,14 @@
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=

"@types/node-fetch@^2.5.10":
version "2.5.10"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"
integrity sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==
dependencies:
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*", "@types/node@>= 8", "@types/node@^14.14.27":
version "14.14.37"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.37.tgz#a3dd8da4eb84a996c36e331df98d82abd76b516e"
Expand Down Expand Up @@ -2861,7 +2869,7 @@ columnify@^1.5.4:
strip-ansi "^3.0.0"
wcwidth "^1.0.0"

combined-stream@^1.0.6, combined-stream@~1.0.6:
combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
Expand Down Expand Up @@ -4179,6 +4187,15 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=

form-data@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f"
integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6"
Expand Down Expand Up @@ -5169,14 +5186,6 @@ isobject@^3.0.0, isobject@^3.0.1:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=

isomorphic-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz#0267b005049046d2421207215d45d6a262b8b8b4"
integrity sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==
dependencies:
node-fetch "^2.6.1"
whatwg-fetch "^3.4.1"

isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
Expand Down Expand Up @@ -8898,11 +8907,6 @@ whatwg-encoding@^1.0.5:
dependencies:
iconv-lite "0.4.24"

whatwg-fetch@^3.4.1:
version "3.5.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.5.0.tgz#605a2cd0a7146e5db141e29d1c62ab84c0c4c868"
integrity sha512-jXkLtsR42xhXg7akoDKvKWE40eJeI+2KZqcp2h3NsOrRnDvtWX36KcKl30dy+hxECivdk2BVUHVNrPtoMBUx6A==

whatwg-mimetype@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"
Expand Down

0 comments on commit b4cf0da

Please sign in to comment.