8000 chore: enable `unicorn/prefer-node-protocol` (#9742) · jakebailey/typescript-eslint@382e87b · GitHub
[go: up one dir, main page]

Skip to content

Commit 382e87b

Browse files
chore: enable unicorn/prefer-node-protocol (typescript-eslint#9742)
* prefer-node-protocol * revert unrelated fixes --------- Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
1 parent 7be87cd commit 382e87b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+100
-64
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ export default tseslint.config(
323323
'jsdoc/informative-docs': 'error',
324324
'unicorn/no-typeof-undefined': 'error',
325325
'unicorn/no-useless-spread': 'error',
326+
'unicorn/prefer-node-protocol': 'error',
326327
'unicorn/prefer-regexp-test': 'error',
327328
},
328329
},

packages/ast-spec/tests/fixtures.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import fs from 'fs';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
24
import * as glob from 'glob';
35
import makeDir from 'make-dir';
4-
import path from 'path';
56

67
import { parseBabel } from './util/parsers/babel';
78
import type {

packages/eslint-plugin-internal/src/rules/no-relative-paths-to-internal-packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import { createRule } from '../util';
44

packages/eslint-plugin-internal/tests/RuleTester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
function getFixturesRootDir(): string {
44
return path.join(__dirname, 'fixtures');

packages/eslint-plugin-internal/tests/rules/no-relative-paths-to-internal-packages.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import path from 'node:path';
2+
13
import { RuleTester } from '@typescript-eslint/rule-tester';
2-
import path from 'path';
34

45
import rule, {
56
PACKAGES_DIR,

packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { extname } from 'node:path';
2+
13
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
24
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
3-
import { extname } from 'path';
45
import * as ts from 'typescript';
56

67
import type { MakeRequired } from '../util';

packages/eslint-plugin/tests/RuleTester.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import * as path from 'node:path';
2+
13
import type {
24
InvalidTestCase,
35
ValidTestCase,
46
} from '@typescript-eslint/rule-tester';
5-
import * as path from 'path';
67

78
export function getFixturesRootDir(): string {
89
return path.join(__dirname, 'fixtures');

packages/eslint-plugin/tests/docs.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import 'jest-specific-snapshot';
22

33
import assert from 'node:assert/strict';
4+
import fs from 'node:fs';
5+
import path from 'node:path';
46

57
import { parseForESLint } from '@typescript-eslint/parser';
68
import * as tseslintParser from '@typescript-eslint/parser';
79
import { Linter } from '@typescript-eslint/utils/ts-eslint';
8-
import fs from 'fs';
910
import { marked } from 'marked';
1011
import type * as mdast from 'mdast';
1112
import type { fromMarkdown as FromMarkdown } from 'mdast-util-from-markdown' with { 'resolution-mode': 'import' };
1213
import type { mdxFromMarkdown as MdxFromMarkdown } from 'mdast-util-mdx' with { 'resolution-mode': 'import' };
1314
import type { mdxjs as Mdxjs } from 'micromark-extension-mdxjs' with { 'resolution-mode': 'import' };
14-
import path from 'path';
1515
import { titleCase } from 'title-case';
1616
import type * as UnistUtilVisit from 'unist-util-visit' with { 'resolution-mode': 'import' };
1717

packages/eslint-plugin/tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
33

44
import eslintPlugin from '../src';
55
import rules from '../src/rules';

packages/eslint-plugin/tests/rules/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from 'fs';
1+
import fs from 'node:fs';
22

33
import rules from '../../src/rules';
44

packages/eslint-plugin/tests/rules/no-unnecessary-condition.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import * as path from 'node:path';
2+
13
import type {
24
InvalidTestCase,
35
TestCaseError,
46
} from '@typescript-eslint/rule-tester';
57
import { noFormat, RuleTester } from '@typescript-eslint/rule-tester';
6-
import * as path from 'path';
78

89
import type {
910
MessageId,

packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import path from 'node:path';
2+
13
import { noFormat, RuleTester } from '@typescript-eslint/rule-tester';
2-
import path from 'path';
34

45
import rule from '../../src/rules/no-unnecessary-type-assertion';
56

packages/eslint-plugin/tests/rules/prefer-nullish-coalescing.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import * as path from 'node:path';
2+
13
import type {
24
InvalidTestCase,
35
ValidTestCase,
46
} from '@typescript-eslint/rule-tester';
57
import { RuleTester } from '@typescript-eslint/rule-tester';
6-
import * as path from 'path';
78

89
import type {
910
MessageIds,

packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable deprecation/deprecation -- TODO - migrate this test away from `batchedSingleLineTests` */
22

3+
import * as path from 'node:path';
4+
35
import { noFormat, RuleTester } from '@typescript-eslint/rule-tester';
4-
import * as path from 'path';
56

67
import type {
78
MessageId,

packages/eslint-plugin/tests/rules/switch-exhaustiveness-check.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import path from 'node:path';
2+
13
import { noFormat, RuleTester } from '@typescript-eslint/rule-tester';
2-
import path from 'path';
34

45
import switchExhaustivenessCheck from '../../src/rules/switch-exhaustiveness-check';
56

packages/integration-tests/tools/pack-packages.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* against the exact same version of the package.
88
*/
99

10-
import { spawnSync } from 'child_process';
11-
import fs from 'fs';
12-
import path from 'path';
10+
import { spawnSync } from 'node:child_process';
11+
import fs from 'node:fs';
12+
import path from 'node:path';
13+
1314
import tmp from 'tmp';
1415

1516
interface PackageJSON {

packages/parser/tests/lib/pars 10000 er.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import path from 'node:path';
2+
13
import * as scopeManager from '@typescript-eslint/scope-manager';
24
import type { ParserOptions } from '@typescript-eslint/types';
35
import * as typescriptESTree from '@typescript-eslint/typescript-estree';
4-
import path from 'path';
56
import { ScriptTarget } from 'typescript';
67

78
import { parse, parseForESLint } from '../../src/parser';

packages/parser/tests/lib/services.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
14
import { createProgram } from '@typescript-eslint/typescript-estree';
2-
import fs from 'fs';
35
import * as glob from 'glob';
4-
import path from 'path';
56

67
import type { ParserOptions } from '../../src/parser';
78
import {

packages/scope-manager/tests/fixtures.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import fs from 'fs';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
24
import * as glob from 'glob';
35
import makeDir from 'make-dir';
4-
import path from 'path';
56

67
import type { AnalyzeOptions } from './test-utils';
78
import { parseAndAnalyze } from './test-utils';

packages/type-utils/src/typeOrValueSpecifiers/typeDeclaredInFile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import path from 'node:path';
2+
13
import { getCanonicalFileName } from '@typescript-eslint/typescript-estree';
2-
import path from 'path';
34
import type * as ts from 'typescript';
45

56
export function typeDeclaredInFile(

packages/type-utils/tests/TypeOrValueSpecifier.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/utils';
35
import Ajv from 'ajv';
4-
import path from 'path';
56

67
import type { TypeOrValueSpecifier } from '../src/TypeOrValueSpecifier';
78
import {

packages/type-utils/tests/getTypeName.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/typescript-estree';
3-
import path from 'path';
45
import type * as ts from 'typescript';
56

67
import { getTypeName } from '../src';

packages/type-utils/tests/isSymbolFromDefaultLibrary.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/typescript-estree';
3-
import path from 'path';
45
import type * as ts from 'typescript';
56

67
import { isSymbolFromDefaultLibrary } from '../src';

packages/type-utils/tests/isTypeReadonly.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/utils';
3-
import path from 'path';
45
import type * as ts from 'typescript';
56

67
import type { ReadonlynessOptions } from '../src/isTypeReadonly';

packages/type-utils/tests/isUnsafeAssignment.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/utils';
3-
import path from 'path';
45
import type * as ts from 'typescript';
56

67
import { isUnsafeAssignment } from '../src/isUnsafeAssignment';

packages/type-utils/tests/typeFlagUtils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import path from 'node:path';
2+
13
import { parseForESLint } from '@typescript-eslint/parser';
24
import type { TSESTree } from '@typescript-eslint/typescript-estree';
3-
import path from 'path';
45
import * as ts from 'typescript';
56

67
import { getTypeFlags, isTypeFlagSet } from '../src';

packages/types/tools/copy-ast-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import childProcess from 'child_process';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import { promisify } from 'util';
1+
import childProcess from 'node:child_process';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import { promisify } from 'node:util';
55

66
const readFile = promisify(fs.readFile);
77
const writeFile = promisify(fs.writeFile);

packages/typescript-estree/src/create-program/createProjectProgram.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import path from 'node:path';
2+
13
import debug from 'debug';
2-
import path from 'path';
34
import * as ts from 'typescript';
45

56
import { firstDefined } from '../node-utils';

packages/typescript-estree/src/create-program/describeFilePath.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
export function describeFilePath(
44
filePath: string,

packages/typescript-estree/src/create-program/getParsedConfigFile.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import * as fs from 'fs';
2-
import * as path from 'path';
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
34
import type * as ts from 'typescript/lib/tsserverlibrary';
45

56
import { CORE_COMPILER_OPTIONS } from './shared';

packages/typescript-estree/src/create-program/getScriptKind.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import path from 'path';
1+
import path from 'node:path';
2+
23
import * as ts from 'typescript';
34

45
function getScriptKind(filePath: string, jsx: boolean): ts.ScriptKind {

packages/typescript-estree/src/create-program/getWatchProgramsForProjects.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import fs from 'node:fs';
2+
13
import debug from 'debug';
2-
import fs from 'fs';
34
import * as ts from 'typescript';
45

56
import type { ParseSettings } from '../parseSettings';

packages/typescript-estree/src/create-program/shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import path from 'path';
1+
import path from 'node:path';
2+
23
import type { Program } from 'typescript';
34
import * as ts from 'typescript';
45

packages/typescript-estree/src/create-program/useProvidedPrograms.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import * as path from 'node:path';
2+
13
import debug from 'debug';
2-
import * as path from 'path';
34
import * as ts from 'typescript';
45

56
import type { ParseSettings } from '../parseSettings';

packages/typescript-estree/src/parseSettings/getProjectConfigFiles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
14
import debug from 'debug';
2-
import * as fs from 'fs';
3-
import * as path from 'path';
45

56
import type { TSESTreeOptions } from '../parser-options';
67
import type { ParseSettings } from './index';

packages/typescript-estree/src/parseSettings/inferSingleRun.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import type { TSESTreeOptions } from '../parser-options';
44

packages/typescript-estree/tests/lib/getProjectConfigFiles.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import { ExpiringCache } from '../../src/parseSettings/ExpiringCache';
44
import { getProjectConfigFiles } from '../../src/parseSettings/getProjectConfigFiles';

packages/typescript-estree/tests/lib/inferSingleRun.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import { inferSingleRun } from '../../src/parseSettings/inferSingleRun';
44

packages/typescript-estree/tests/lib/parse.project-true.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'path';
1+
import { join } from 'node:path';
22

33
import * as parser from '../../src';
44

packages/typescript-estree/tests/lib/parse.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { join, resolve } from 'node:path';
2+
13
import type { CacheDurationSeconds } from '@typescript-eslint/types';
24
import debug from 'debug';
35
import * as globbyModule from 'globby';
4-
import { join, resolve } from 'path';
56
import type * as typescriptModule from 'typescript';
67

78
import * as parser from '../../src';

packages/typescript-estree/tests/lib/persistentParse.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
34
import tmp from 'tmp';
45

56
import { clearCaches } from '../../src/clear-caches';

packages/typescript-estree/tests/lib/semanticInfo-singleRun.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import * as path from 'node:path';
2+
13
import * as glob from 'glob';
2-
import * as path from 'path';
34

45
import { createProgramFromConfigFile as createProgramFromConfigFileOriginal } from '../../src/create-program/useProvidedPrograms';
56
import {

packages/typescript-estree/tests/lib/semanticInfo.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as fs from 'fs';
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
24
import * as glob from 'glob';
3-
import * as path from 'path';
45
import * as ts from 'typescript';
56

67
import { clearCaches } from '../../src';

packages/typescript-estree/tests/lib/useProgramFromProjectService.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @typescript-eslint/explicit-function-return-type -- Fancy mocks */
2-
import path from 'path';
2+
import path from 'node:path';
3+
34
import * as ts from 'typescript';
45

56
import type {

0 commit comments

Comments
 (0)
0