diff --git a/bin/lint-staged.js b/bin/lint-staged.js index 115ce1a96..ca18bdf74 100755 --- a/bin/lint-staged.js +++ b/bin/lint-staged.js @@ -1,8 +1,8 @@ #!/usr/bin/env node -import fs from 'fs' -import path from 'path' -import { fileURLToPath } from 'url' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import { Option, program } from 'commander' import debug from 'debug' diff --git a/lib/chunkFiles.js b/lib/chunkFiles.js index f04c25a65..64761a046 100644 --- a/lib/chunkFiles.js +++ b/lib/chunkFiles.js @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import debug from 'debug' import normalize from 'normalize-path' diff --git a/lib/dynamicImport.js b/lib/dynamicImport.js index 75e228fc2..fba6409cd 100644 --- a/lib/dynamicImport.js +++ b/lib/dynamicImport.js @@ -1,3 +1,3 @@ -import { pathToFileURL } from 'url' +import { pathToFileURL } from 'node:url' export const dynamicImport = (path) => import(pathToFileURL(path)).then((module) => module.default) diff --git a/lib/file.js b/lib/file.js index 3f88414e8..2d871fa43 100644 --- a/lib/file.js +++ b/lib/file.js @@ -1,4 +1,4 @@ -import { promises as fs } from 'fs' +import fs from 'node:fs/promises' import debug from 'debug' diff --git a/lib/generateTasks.js b/lib/generateTasks.js index 99e3e91cf..b05d625f3 100644 --- a/lib/generateTasks.js +++ b/lib/generateTasks.js @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import debug from 'debug' import micromatch from 'micromatch' diff --git a/lib/getStagedFiles.js b/lib/getStagedFiles.js index 08f7723fd..b301d4225 100644 --- a/lib/getStagedFiles.js +++ b/lib/getStagedFiles.js @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import normalize from 'normalize-path' diff --git a/lib/gitWorkflow.js b/lib/gitWorkflow.js index a2f842355..8ae95e7e1 100644 --- a/lib/gitWorkflow.js +++ b/lib/gitWorkflow.js @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import debug from 'debug' diff --git a/lib/groupFilesByConfig.js b/lib/groupFilesByConfig.js index ee5c67a97..e6e90e7a8 100644 --- a/lib/groupFilesByConfig.js +++ b/lib/groupFilesByConfig.js @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import debug from 'debug' diff --git a/lib/resolveConfig.js b/lib/resolveConfig.js index 0b9f357c1..cb4ab0bde 100644 --- a/lib/resolveConfig.js +++ b/lib/resolveConfig.js @@ -1,4 +1,4 @@ -import { createRequire } from 'module' +import { createRequire } from 'node:module' /** * require() does not exist for ESM, so we must create it to use require.resolve(). diff --git a/lib/resolveGitRepo.js b/lib/resolveGitRepo.js index 3e7460369..f01570590 100644 --- a/lib/resolveGitRepo.js +++ b/lib/resolveGitRepo.js @@ -1,5 +1,5 @@ -import { promises as fs } from 'fs' -import path from 'path' +import fs from 'node:fs/promises' +import path from 'node:path' import debug from 'debug' import normalize from 'normalize-path' diff --git a/lib/runAll.js b/lib/runAll.js index 08f06d190..63b68a159 100644 --- a/lib/runAll.js +++ b/lib/runAll.js @@ -1,6 +1,6 @@ /** @typedef {import('./index').Logger} Logger */ -import path from 'path' +import path from 'node:path' import { dim } from 'colorette' import debug from 'debug' diff --git a/lib/searchConfigs.js b/lib/searchConfigs.js index 02fc3a56f..dce5b0dbc 100644 --- a/lib/searchConfigs.js +++ b/lib/searchConfigs.js @@ -1,6 +1,6 @@ /** @typedef {import('./index').Logger} Logger */ -import { basename, join } from 'path' +import path from 'node:path' import debug from 'debug' import normalize from 'normalize-path' @@ -15,7 +15,7 @@ const debugLog = debug('lint-staged:searchConfigs') const EXEC_GIT = ['ls-files', '-z', '--full-name'] const filterPossibleConfigFiles = (files) => - files.filter((file) => searchPlaces.includes(basename(file))) + files.filter((file) => searchPlaces.includes(path.basename(file))) const numberOfLevels = (file) => file.split('/').length @@ -68,7 +68,7 @@ export const searchConfigs = async ( /** Sort possible config files so that deepest is first */ const possibleConfigFiles = [...cachedFiles, ...otherFiles] - .map((file) => normalize(join(gitDir, file))) + .map((file) => normalize(path.join(gitDir, file))) .filter(isInsideDirectory(cwd)) .sort(sortDeepestParth) diff --git a/lib/validateOptions.js b/lib/validateOptions.js index 78b4c01e1..a97e60c1d 100644 --- a/lib/validateOptions.js +++ b/lib/validateOptions.js @@ -1,5 +1,6 @@ -import { constants, promises as fs } from 'fs' -import path from 'path' +import { constants } from 'node:fs' +import fs from 'node:fs/promises' +import path from 'node:path' import debug from 'debug' diff --git a/test/loadConfig.spec.js b/test/loadConfig.spec.js index 2a533a19c..44888364f 100644 --- a/test/loadConfig.spec.js +++ b/test/loadConfig.spec.js @@ -21,7 +21,7 @@ jest.unmock('execa') * This converts paths into `file://` urls, but this doesn't * work with `import()` when using babel + jest. */ -jest.mock('url', () => ({ +jest.mock('node:url', () => ({ pathToFileURL: (path) => path, }))