Skip to content
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

chore: use @tsconfig/node14 and stricter TS config #1242

Merged
merged 2 commits into from Sep 10, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -108,6 +108,7 @@
"@schemastore/package": "^0.0.6",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/git": "^10.0.0",
"@tsconfig/node14": "^1.0.3",
"@types/dedent": "^0.7.0",
"@types/jest": "^29.0.0",
"@types/node": "^14.18.26",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
@@ -1,6 +1,6 @@
import { readdirSync } from 'fs';
import { join, parse } from 'path';
import { TSESLint } from '@typescript-eslint/utils';
import type { TSESLint } from '@typescript-eslint/utils';
import globals from './globals.json';
import * as snapshotProcessor from './processors/snapshot-processor';

Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-commented-out-tests.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { createRule } from './utils';

function hasTests(node: TSESTree.Comment) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-conditional-in-test.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { createRule, isTypeOfJestFnCall } from './utils';

export default createRule({
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-mocks-import.ts
@@ -1,5 +1,5 @@
import { posix } from 'path';
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { createRule, getStringValue, isStringNode } from './utils';

const mocksDirName = '__mocks__';
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-each.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { JestFnType, createRule, parseJestFnCall } from './utils';

export default createRule({
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-lowercase-title.ts
@@ -1,4 +1,4 @@
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import {
CallExpressionWithSingleArgument,
DescribeAlias,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/require-top-level-describe.ts
@@ -1,4 +1,4 @@
import { TSESTree } from '@typescript-eslint/utils';
import type { TSESTree } from '@typescript-eslint/utils';
import { createRule, isTypeOfJestFnCall, parseJestFnCall } from './utils';

const messages = {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/utils/__tests__/detectJestVersion.test.ts
Expand Up @@ -2,7 +2,7 @@ import { spawnSync } from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import type { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import { create } from 'ts-node';
import { detectJestVersion } from '../detectJestVersion';

Expand Down
4 changes: 2 additions & 2 deletions src/rules/utils/__tests__/parseJestFnCall.test.ts
@@ -1,4 +1,4 @@
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import type { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
import dedent from 'dedent';
import { espreeParser } from '../../__tests__/test-utils';
Expand Down Expand Up @@ -76,7 +76,7 @@ const rule = createRule({
messageId: 'details',
node,
data: {
data: JSON.stringify(sorted, (key, value) => {
data: JSON.stringify(sorted, (_key, value) => {
if (isNode(value)) {
if (isSupportedAccessor(value)) {
return getAccessorValue(value);
Expand Down
2 changes: 1 addition & 1 deletion src/rules/utils/detectJestVersion.ts
@@ -1,4 +1,4 @@
import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';
import type { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package';

export type JestVersion =
| 14
Expand Down
2 changes: 1 addition & 1 deletion tools/regenerate-docs.ts
Expand Up @@ -2,7 +2,7 @@

import * as fs from 'fs';
import * as path from 'path';
import { TSESLint } from '@typescript-eslint/utils';
import type { TSESLint } from '@typescript-eslint/utils';
import prettier, { Options } from 'prettier';
import { prettier as prettierRC } from '../package.json';
import config from '../src/index';
Expand Down
18 changes: 14 additions & 4 deletions tsconfig.json
@@ -1,15 +1,25 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es2018"],
"noEmit": true,
"importsNotUsedAsValues": "error",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this? I can live with it, but my understanding is that its "maybe" needed in some rare cases (e.g. using something that isn't smart enough to automatically figure it out like tsc and Babel can), and it means extra noise in diffs when you need to switch between imports.

I'm pretty sure it doesn't help us as I've looked at our compiled outside in the past and feel this is the sort of thing I'd have done already if I found it was adding unneeded imports

"stripInternal": true,

/* Additional Checks */
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,

"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"skipLibCheck": false,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*", "tools/**/*"]
"include": ["src/**/*", "tools/**/*"],
"exclude": ["src/rules/__tests__/fixtures/**/*"]
}
3 changes: 2 additions & 1 deletion yarn.lock
Expand Up @@ -2506,7 +2506,7 @@ __metadata:
languageName: node
linkType: hard

"@tsconfig/node14@npm:^1.0.0":
"@tsconfig/node14@npm:^1.0.0, @tsconfig/node14@npm:^1.0.3":
version: 1.0.3
resolution: "@tsconfig/node14@npm:1.0.3"
checksum: 19275fe80c4c8d0ad0abed6a96dbf00642e88b220b090418609c4376e1cef81bf16237bf170ad1b341452feddb8115d8dd2e5acdfdea1b27422071163dc9ba9d
Expand Down Expand Up @@ -4570,6 +4570,7 @@ __metadata:
"@schemastore/package": ^0.0.6
"@semantic-release/changelog": ^6.0.0
"@semantic-release/git": ^10.0.0
"@tsconfig/node14": ^1.0.3
"@types/dedent": ^0.7.0
"@types/jest": ^29.0.0
"@types/node": ^14.18.26
Expand Down