Skip to content

Commit

Permalink
chore: some lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed May 2, 2024
1 parent 3983d44 commit 3676ed3
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 18 deletions.
11 changes: 2 additions & 9 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,8 @@ export default tseslint.config(
project: [
'tsconfig.json',
'packages/*/tsconfig.json',
/**
* We are currently in the process of transitioning to nx's out of the box structure and
* so need to manually specify converted packages' tsconfig.build.json and tsconfig.spec.json
* files here for now in addition to the tsconfig.json glob pattern.
*
* TODO(#4665): Clean this up once all packages have been transitioned.
*/
'packages/scope-manager/tsconfig.build.json',
'packages/scope-manager/tsconfig.spec.json',
'packages/*/tsconfig.build.json',
'packages/*/tsconfig.spec.json',
],
tsconfigRootDir: __dirname,
warnOnUnsupportedTypeScriptVersion: false,
Expand Down
10 changes: 9 additions & 1 deletion packages/eslint-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
"declarationMap": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools", "index.d.ts", "rules.d.ts"],
"include": [
"src",
"typings",
"tests",
"tools",
"index.d.ts",
"rules.d.ts",
"eslint-recommended-raw.d.ts"
],
"references": [
{ "path": "../utils/tsconfig.build.json" },
{ "path": "../parser/tsconfig.build.json" },
Expand Down
3 changes: 1 addition & 2 deletions packages/parser/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type {
ScopeManager,
} from '@typescript-eslint/scope-manager';
import { analyze } from '@typescript-eslint/scope-manager';
import type { Lib, TSESTree } from '@typescript-eslint/types';
import { ParserOptions } from '@typescript-eslint/types';
import type { Lib, ParserOptions, TSESTree } from '@typescript-eslint/types';
import type {
ParserServices,
TSESTreeOptions,
Expand Down
2 changes: 2 additions & 0 deletions packages/rule-tester/tests/RuleTester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const EMPTY_PROGRAM: TSESTree.Program = {
range: [0, 0],
};
// TODO: Fix need for any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
runRuleForItemSpy.mockImplementation((_1, _2, testCase: any) => {
return {
messages:
Expand Down Expand Up @@ -134,6 +135,7 @@ const NOOP_RULE: RuleModule<'error'> = {

function getTestConfigFromCall(): unknown[] {
// TODO: Fix need for any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return runRuleForItemSpy.mock.calls.map((c: any) => {
return { ...c[2], filename: c[2].filename?.replaceAll('\\', '/') };
});
Expand Down
2 changes: 1 addition & 1 deletion packages/scope-manager/src/referencer/Referencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class Referencer extends Visitor {
switch (left.type) {
case AST_NODE_TYPES.TSAsExpression:
// @ts-expect-error Intentional fallthrough
case AST_NODE_TYPES.TSTypeAssertion:
case AST_NODE_TYPES.TSTypeAssertion: // eslint-disable-line no-fallthrough
// explicitly visit the type annotation
this.visitType(left.typeAnnotation);
// intentional fallthrough
Expand Down
3 changes: 2 additions & 1 deletion packages/scope-manager/src/referencer/Visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type {
PatternVisitorOptions,
} from './PatternVisitor';
import { PatternVisitor } from './PatternVisitor';
import { VisitorBase, VisitorOptions } from './VisitorBase';
import type { VisitorOptions } from './VisitorBase';
import { VisitorBase } from './VisitorBase';

interface VisitPatternOptions extends PatternVisitorOptions {
processRightHandNodes?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/scope-manager/src/referencer/VisitorBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types';
import { VisitorKeys, visitorKeys } from '@typescript-eslint/visitor-keys';
import type { VisitorKeys } from '@typescript-eslint/visitor-keys';
import { visitorKeys } from '@typescript-eslint/visitor-keys';

interface VisitorOptions {
childVisitorKeys?: VisitorKeys | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ describe('ES6 destructuring assignments', () => {
expect(scope.references).toHaveLength(0);
expect(scope['implicit'].leftToBeResolved).toHaveLength(2);
expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d');
// TODO: Investigate lint error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
expectToBeForScope(scope['implicit'].leftToBeResolved[0].from);
expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('array');
// TODO: Investigate lint error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
expectToBeForScope(scope['implicit'].leftToBeResolved[1].from);

scope = scopeManager.scopes[2];
Expand Down Expand Up @@ -280,10 +284,16 @@ describe('ES6 destructuring assignments', () => {
expect(scope.references).toHaveLength(0);
expect(scope['implicit'].leftToBeResolved).toHaveLength(3);
expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d');
// TODO: Investigate lint error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
expectToBeForScope(scope['implicit'].leftToBeResolved[0].from);
expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('e');
// TODO: Investigate lint error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
expectToBeForScope(scope['implicit'].leftToBeResolved[1].from);
expect(scope['implicit'].leftToBeResolved[2].identifier.name).toBe('array');
// TODO: Investigate lint error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
expectToBeForScope(scope['implicit'].leftToBeResolved[2].from);

scope = scopeManager.scopes[2];
Expand Down
3 changes: 2 additions & 1 deletion packages/scope-manager/tests/test-utils/parse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as tseslint from '@typescript-eslint/typescript-estree';

import { analyze, AnalyzeOptions } from '../../src/analyze';
import type { AnalyzeOptions } from '../../src/analyze';
import { analyze } from '../../src/analyze';

type SourceType = AnalyzeOptions['sourceType'];

Expand Down
3 changes: 2 additions & 1 deletion packages/types/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"emitDeclarationOnly": false,
"resolveJsonModule": true
},
"include": ["src", "typings"]
"include": ["src"],
"references": []
}

// {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc/types"
},
"include": ["src", "typings", "tests", "tools"],
"include": ["src", "tools"],
"references": [
{
"path": "./tsconfig.build.json"
Expand Down
3 changes: 3 additions & 0 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ export class Converter {
if (colonIndex > 0) {
const range = getRange(node, this.ast);
// TODO: Fix as any usage
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const result = this.createNode<TSESTree.JSXNamespacedName>(node as any, {

Check warning on line 606 in packages/typescript-estree/src/convert.ts

View check run for this annotation

Codecov / codecov/patch

packages/typescript-estree/src/convert.ts#L606

Added line #L606 was not covered by tests
type: AST_NODE_TYPES.JSXNamespacedName,
namespace: this.createNode<TSESTree.JSXIdentifier>(node, {
Expand Down Expand Up @@ -1282,9 +1283,11 @@ export class Converter {
});
}

/* eslint-disable no-fallthrough */
case SyntaxKind.GetAccessor:
// @ts-expect-error Intentionally allowing fallthrough in switch for identical cases
case SyntaxKind.SetAccessor: {
/* eslint-enable no-fallthrough */
if (
node.parent.kind === SyntaxKind.InterfaceDeclaration ||
node.parent.kind === SyntaxKind.TypeLiteral
Expand Down

0 comments on commit 3676ed3

Please sign in to comment.