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

fix(deps): bump lint-staged from 13.2.3 to 14.0.0 #1590

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Aug 14, 2023

Bumps lint-staged from 13.2.3 to 14.0.0.

Release notes

Sourced from lint-staged's releases.

v14.0.0

14.0.0 (2023-08-13)

Features

BREAKING CHANGES

  • Please upgrade your Node.js version to at least 16.14.0.

v13.3.0

13.3.0 (2023-08-13)

Bug Fixes

  • dependencies: update most dependencies (7443870)
  • detect duplicate redundant braces in pattern (d895aa8)

Features

  • dependencies: update listr2@6.6.0 (09844ca)
Commits
  • 9da8777 feat: drop support for Node.js 14 (#1312)
  • f895e97 Merge pull request #1289 from okonet/updates-2023-04-20
  • 217c404 test: move mock to avoid name collision warning from jest-haste-map
  • d895aa8 fix: detect duplicate redundant braces in pattern
  • a7f8f29 test: skip test failing on Windows Node.js ~20.4.0
  • aa65846 refactor: replace "object-inspect" with built-in util
  • 977c15d refactor: use built-in truncation of Listr2
  • 44a4f6c refactor: reimplement "normalize-path"
  • bc2d267 test: add debug
  • f5ea0a2 refactor: use top-level await in bin
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Aug 14, 2023
@github-actions
Copy link
Contributor

Diff between lint-staged 13.2.3 and 14.0.0
diff --git a/lib/chunkFiles.js b/lib/chunkFiles.js
index v13.2.3..v14.0.0 100644
--- a/lib/chunkFiles.js
+++ b/lib/chunkFiles.js
@@ -2,6 +2,7 @@
 
 import debug from 'debug'
-import normalize from 'normalize-path'
 
+import { normalizePath } from './normalizePath.js'
+
 const debugLog = debug('lint-staged:chunkFiles')
 
@@ -36,5 +37,5 @@
 export const chunkFiles = ({ files, baseDir, maxArgLength = null, relative = false }) => {
   const normalizedFiles = files.map((file) =>
-    normalize(relative || !baseDir ? file : path.resolve(baseDir, file))
+    normalizePath(relative || !baseDir ? file : path.resolve(baseDir, file))
   )
 
diff --git a/lib/generateTasks.js b/lib/generateTasks.js
index v13.2.3..v14.0.0 100644
--- a/lib/generateTasks.js
+++ b/lib/generateTasks.js
@@ -3,6 +3,7 @@
 import debug from 'debug'
 import micromatch from 'micromatch'
-import normalize from 'normalize-path'
 
+import { normalizePath } from './normalizePath.js'
+
 const debugLog = debug('lint-staged:generateTasks')
 
@@ -20,5 +21,5 @@
   debugLog('Generating linter tasks')
 
-  const relativeFiles = files.map((file) => normalize(path.relative(cwd, file)))
+  const relativeFiles = files.map((file) => normalizePath(path.relative(cwd, file)))
 
   return Object.entries(config).map(([pattern, commands]) => {
@@ -43,5 +44,5 @@
     })
 
-    const fileList = matches.map((file) => normalize(relative ? file : path.resolve(cwd, file)))
+    const fileList = matches.map((file) => normalizePath(relative ? file : path.resolve(cwd, file)))
 
     const task = { pattern, commands, fileList }
diff --git a/lib/getRenderer.js b/lib/getRenderer.js
index v13.2.3..v14.0.0 100644
--- a/lib/getRenderer.js
+++ b/lib/getRenderer.js
@@ -1,17 +1,52 @@
-const getMainRendererOptions = ({ debug, quiet }, env) => {
-  if (quiet) return { renderer: 'silent' }
+import { EOL } from 'node:os'
+import { Writable } from 'node:stream'
+
+import { ListrLogger, ProcessOutput } from 'listr2'
+
+const EOLRegex = new RegExp(EOL + '$')
+
+const bindLogger = (consoleLogMethod) =>
+  new Writable({
+    write: function (chunk, encoding, next) {
+      consoleLogMethod(chunk.toString().replace(EOLRegex, ''))
+      next()
+    },
+  })
+
+const getMainRendererOptions = ({ debug, quiet }, logger, env) => {
+  if (quiet) {
+    return {
+      renderer: 'silent',
+    }
+  }
+
+  if (env.NODE_ENV === 'test') {
+    return {
+      renderer: 'test',
+      rendererOptions: {
+        logger: new ListrLogger({
+          processOutput: new ProcessOutput(bindLogger(logger.log), bindLogger(logger.error)),
+        }),
+      },
+    }
+  }
+
   // Better support for dumb terminals: https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals
-  const isDumbTerminal = env.TERM === 'dumb'
-  if (debug || isDumbTerminal || env.NODE_ENV === 'test') return { renderer: 'verbose' }
-  return { renderer: 'update', rendererOptions: { dateFormat: false } }
+  if (debug || env.TERM === 'dumb') {
+    return {
+      renderer: 'verbose',
+    }
+  }
+
+  return {
+    renderer: 'update',
+    rendererOptions: {
+      formatOutput: 'truncate',
+    },
+  }
 }
 
 const getFallbackRenderer = ({ renderer }, { FORCE_COLOR }) => {
-  if (renderer === 'silent') {
-    return 'silent'
-  }
-
-  // If colors are being forced, then also force non-fallback rendering
-  if (Number(FORCE_COLOR) > 0) {
+  if (renderer === 'silent' || renderer === 'test' || Number(FORCE_COLOR) > 0) {
     return renderer
   }
@@ -20,9 +55,10 @@
 }
 
-export const getRenderer = (options, env = process.env) => {
-  const mainRendererOptions = getMainRendererOptions(options, env)
+export const getRenderer = (options, logger, env = process.env) => {
+  const mainRendererOptions = getMainRendererOptions(options, logger, env)
+
   return {
     ...mainRendererOptions,
-    nonTTYRenderer: getFallbackRenderer(mainRendererOptions, env),
+    fallbackRenderer: getFallbackRenderer(mainRendererOptions, env),
   }
 }
diff --git a/lib/getStagedFiles.js b/lib/getStagedFiles.js
index v13.2.3..v14.0.0 100644
--- a/lib/getStagedFiles.js
+++ b/lib/getStagedFiles.js
@@ -1,8 +1,7 @@
 import path from 'node:path'
 
-import normalize from 'normalize-path'
-
 import { execGit } from './execGit.js'
 import { getDiffCommand } from './getDiffCommand.js'
+import { normalizePath } from './normalizePath.js'
 import { parseGitZOutput } from './parseGitZOutput.js'
 
@@ -12,5 +11,5 @@
     if (!lines) return []
 
-    return parseGitZOutput(lines).map((file) => normalize(path.resolve(cwd, file)))
+    return parseGitZOutput(lines).map((file) => normalizePath(path.resolve(cwd, file)))
   } catch {
     return null
diff --git a/bin/lint-staged.js b/bin/lint-staged.js
index v13.2.3..v14.0.0 100755
--- a/bin/lint-staged.js
+++ b/bin/lint-staged.js
@@ -1,7 +1,5 @@
 #!/usr/bin/env node
 
-import fs from 'node:fs'
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
+import fs from 'node:fs/promises'
 
 import { supportsColor } from 'chalk'
@@ -20,6 +18,5 @@
 process.on('SIGINT', () => {})
 
-const packageJsonPath = path.join(fileURLToPath(import.meta.url), '../../package.json')
-const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))
+const packageJson = JSON.parse(await fs.readFile(new URL('../package.json', import.meta.url)))
 const version = packageJson.version
 
@@ -114,5 +111,5 @@
   delete options.configPath
   try {
-    options.config = fs.readFileSync(process.stdin.fd, 'utf8').toString().trim()
+    options.config = await fs.readFile(process.stdin.fd, 'utf8').toString().trim()
   } catch {
     console.error(CONFIG_STDIN_ERROR)
@@ -127,9 +124,8 @@
 }
 
-lintStaged(options)
-  .then((passed) => {
-    process.exitCode = passed ? 0 : 1
-  })
-  .catch(() => {
-    process.exitCode = 1
-  })
+try {
+  const passed = await lintStaged(options)
+  process.exitCode = passed ? 0 : 1
+} catch {
+  process.exitCode = 1
+}
diff --git a/lib/makeCmdTasks.js b/lib/makeCmdTasks.js
index v13.2.3..v14.0.0 100644
--- a/lib/makeCmdTasks.js
+++ b/lib/makeCmdTasks.js
@@ -1,3 +1,2 @@
-import cliTruncate from 'cli-truncate'
 import debug from 'debug'
 
@@ -7,22 +6,5 @@
 const debugLog = debug('lint-staged:makeCmdTasks')
 
-const STDOUT_COLUMNS_DEFAULT = 80
-
-const listrPrefixLength = {
-  update: `    X `.length, // indented task title where X is a checkmark or a cross (failure)
-  verbose: `[STARTED] `.length, // verbose renderer uses 7-letter STARTED/SUCCESS prefixes
-}
-
 /**
- * Get length of title based on the number of available columns prefix length
- * @param {string} renderer The name of the Listr renderer
- * @returns {number}
- */
-const getTitleLength = (renderer, columns = process.stdout.columns) => {
-  const prefixLength = listrPrefixLength[renderer] || 0
-  return (columns || STDOUT_COLUMNS_DEFAULT) - prefixLength
-}
-
-/**
  * Creates and returns an array of listr tasks which map to the given commands.
  *
@@ -32,9 +14,8 @@
  * @param {Array<string>} options.files
  * @param {string} options.gitDir
- * @param {string} options.renderer
  * @param {Boolean} shell
  * @param {Boolean} verbose
  */
-export const makeCmdTasks = async ({ commands, cwd, files, gitDir, renderer, shell, verbose }) => {
+export const makeCmdTasks = async ({ commands, cwd, files, gitDir, shell, verbose }) => {
   debugLog('Creating listr tasks for commands %o', commands)
   const commandArray = Array.isArray(commands) ? commands : [commands]
@@ -61,8 +42,6 @@
       }
 
-      // Truncate title to single line based on renderer
-      const title = cliTruncate(command, getTitleLength(renderer))
       const task = resolveTaskFn({ command, cwd, files, gitDir, isFn, shell, verbose })
-      cmdTasks.push({ title, command, task })
+      cmdTasks.push({ title: command, command, task })
     }
   }
diff --git a/lib/messages.js b/lib/messages.js
index v13.2.3..v14.0.0 100644
--- a/lib/messages.js
+++ b/lib/messages.js
@@ -1,4 +1,5 @@
+import { inspect } from 'node:util'
+
 import chalk from 'chalk'
-import inspect from 'object-inspect'
 
 import { error, info, warning } from './figures.js'
@@ -7,7 +8,5 @@
   `${chalk.redBright(`${error} Validation Error:`)}
 
-  Invalid value for '${chalk.bold(opt)}': ${chalk.bold(
-    inspect(value, { inlineCharacterLimit: Number.POSITIVE_INFINITY })
-  )}
+  Invalid value for '${chalk.bold(opt)}': ${chalk.bold(inspect(value))}
 
   ${helpMsg}`
diff --git a/lib/resolveGitRepo.js b/lib/resolveGitRepo.js
index v13.2.3..v14.0.0 100644
--- a/lib/resolveGitRepo.js
+++ b/lib/resolveGitRepo.js
@@ -3,8 +3,8 @@
 
 import debug from 'debug'
-import normalize from 'normalize-path'
 
 import { execGit } from './execGit.js'
 import { readFile } from './file.js'
+import { normalizePath } from './normalizePath.js'
 
 const debugLog = debug('lint-staged:resolveGitRepo')
@@ -16,5 +16,5 @@
 const resolveGitConfigDir = async (gitDir) => {
   // Get the real path in case it's a symlink
-  const defaultDir = normalize(await fs.realpath(path.join(gitDir, '.git')))
+  const defaultDir = normalizePath(await fs.realpath(path.join(gitDir, '.git')))
   const stats = await fs.lstat(defaultDir)
   // If .git is a directory, use it
@@ -34,8 +34,8 @@
   if (relativeDir) {
     // the current working dir is inside the git top-level directory
-    return normalize(cwd.substring(0, cwd.lastIndexOf(relativeDir)))
+    return normalizePath(cwd.substring(0, cwd.lastIndexOf(relativeDir)))
   } else {
     // the current working dir is the top-level git directory
-    return normalize(cwd)
+    return normalizePath(cwd)
   }
 }
@@ -56,7 +56,7 @@
     // read the path of the current directory relative to the top-level directory
     // don't read the toplevel directly, it will lead to an posix conform path on non posix systems (cygwin)
-    const gitRel = normalize(await execGit(['rev-parse', '--show-prefix'], { cwd }))
-    const gitDir = determineGitDir(normalize(cwd), gitRel)
-    const gitConfigDir = normalize(await resolveGitConfigDir(gitDir))
+    const gitRel = normalizePath(await execGit(['rev-parse', '--show-prefix'], { cwd }))
+    const gitDir = determineGitDir(normalizePath(cwd), gitRel)
+    const gitConfigDir = normalizePath(await resolveGitConfigDir(gitDir))
 
     debugLog('Resolved git directory to be `%s`', gitDir)
diff --git a/lib/runAll.js b/lib/runAll.js
index v13.2.3..v14.0.0 100644
--- a/lib/runAll.js
+++ b/lib/runAll.js
@@ -6,5 +6,4 @@
 import debug from 'debug'
 import { Listr } from 'listr2'
-import normalize from 'normalize-path'
 
 import { chunkFiles } from './chunkFiles.js'
@@ -25,4 +24,5 @@
   skippingBackup,
 } from './messages.js'
+import { normalizePath } from './normalizePath.js'
 import { resolveGitRepo } from './resolveGitRepo.js'
 import {
@@ -152,5 +152,5 @@
     exitOnError: false,
     registerSignalListeners: false,
-    ...getRenderer({ debug, quiet }),
+    ...getRenderer({ debug, quiet }, logger),
   }
 
@@ -161,5 +161,5 @@
 
   for (const [configPath, { config, files }] of Object.entries(filesByConfig)) {
-    const configName = configPath ? normalize(path.relative(cwd, configPath)) : 'Config object'
+    const configName = configPath ? normalizePath(path.relative(cwd, configPath)) : 'Config object'
 
     const stagedFileChunks = chunkFiles({ baseDir: gitDir, files, maxArgLength, relative })
@@ -183,5 +183,4 @@
             files: task.fileList,
             gitDir,
-            renderer: listrOptions.renderer,
             shell,
             verbose,
@@ -194,5 +193,5 @@
               const normalizedFile = path.isAbsolute(file)
                 ? file
-                : normalize(path.join(groupCwd, file))
+                : normalizePath(path.join(groupCwd, file))
 
               matchedFiles.add(normalizedFile)
diff --git a/lib/searchConfigs.js b/lib/searchConfigs.js
index v13.2.3..v14.0.0 100644
--- a/lib/searchConfigs.js
+++ b/lib/searchConfigs.js
@@ -4,8 +4,8 @@
 
 import debug from 'debug'
-import normalize from 'normalize-path'
 
 import { execGit } from './execGit.js'
 import { loadConfig, searchPlaces } from './loadConfig.js'
+import { normalizePath } from './normalizePath.js'
 import { parseGitZOutput } from './parseGitZOutput.js'
 import { validateConfig } from './validateConfig.js'
@@ -22,5 +22,5 @@
 const sortDeepestParth = (a, b) => (numberOfLevels(a) > numberOfLevels(b) ? -1 : 1)
 
-const isInsideDirectory = (dir) => (file) => file.startsWith(normalize(dir))
+const isInsideDirectory = (dir) => (file) => file.startsWith(normalizePath(dir))
 
 /**
@@ -69,5 +69,5 @@
   /** Sort possible config files so that deepest is first */
   const possibleConfigFiles = [...cachedFiles, ...otherFiles]
-    .map((file) => normalize(path.join(gitDir, file)))
+    .map((file) => normalizePath(path.join(gitDir, file)))
     .filter(isInsideDirectory(cwd))
     .sort(sortDeepestParth)
diff --git a/lib/validateBraces.js b/lib/validateBraces.js
index v13.2.3..v14.0.0 100644
--- a/lib/validateBraces.js
+++ b/lib/validateBraces.js
@@ -18,6 +18,6 @@
  *
  * @example <caption>Globs with brace expansions</caption>
- * - *.{js,tx}         // expanded as *.js, *.ts
- * - *.{{j,t}s,css}    // expanded as *.js, *.ts, *.css
+ * - *.{js,tx}        // expanded as *.js, *.ts
+ * - *.{{j,t}s,css}   // expanded as *.js, *.ts, *.css
  * - file_{1..10}.css  // expanded as file_1.css, file_2.css, …, file_10.css
  *
@@ -29,5 +29,5 @@
  * - *.{js\,ts}   // the comma is escaped, so treated literally
  */
-export const BRACES_REGEXP = /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g
+export const INCORRECT_BRACES_REGEXP = /(?<![\\$])({)(?:(?!(?<!\\),|\.\.|\{|\}).)*?(?<!\\)(})/g
 
 /**
@@ -35,9 +35,9 @@
  * @returns {string}
  */
-const withoutIncorrectBraces = (pattern) => {
+const stripIncorrectBraces = (pattern) => {
   let output = `${pattern}`
   let match = null
 
-  while ((match = BRACES_REGEXP.exec(pattern))) {
+  while ((match = INCORRECT_BRACES_REGEXP.exec(pattern))) {
     const fullMatch = match[0]
     const withoutBraces = fullMatch.replace(/{/, '').replace(/}/, '')
@@ -49,4 +49,28 @@
 
 /**
+ * This RegExp matches "duplicate" opening and closing braces, without any other braces
+ * in between, where the duplication is redundant and should be removed.
+ *
+ * @example *.{{js,ts}}  // should just be *.{js,ts}
+ */
+export const DOUBLE_BRACES_REGEXP = /{{[^}{]*}}/
+
+/**
+ * @param {string} pattern
+ * @returns {string}
+ */
+const stripDoubleBraces = (pattern) => {
+  let output = `${pattern}`
+  const match = DOUBLE_BRACES_REGEXP.exec(pattern)?.[0]
+
+  if (match) {
+    const withoutBraces = match.replace('{{', '{').replace('}}', '}')
+    output = output.replace(match, withoutBraces)
+  }
+
+  return output
+}
+
+/**
  * Validate and remove incorrect brace expansions from glob pattern.
  * For example `*.{js}` is incorrect because it doesn't contain a `,` or `..`,
@@ -58,5 +82,5 @@
  */
 export const validateBraces = (pattern, logger) => {
-  const fixedPattern = withoutIncorrectBraces(pattern)
+  const fixedPattern = stripDoubleBraces(stripIncorrectBraces(pattern))
 
   if (fixedPattern !== pattern) {
diff --git a/lib/validateConfig.js b/lib/validateConfig.js
index v13.2.3..v14.0.0 100644
--- a/lib/validateConfig.js
+++ b/lib/validateConfig.js
@@ -1,6 +1,7 @@
 /** @typedef {import('./index').Logger} Logger */
 
+import { inspect } from 'node:util'
+
 import debug from 'debug'
-import inspect from 'object-inspect'
 
 import { configurationError } from './messages.js'
@@ -110,5 +111,5 @@
 
   debugLog('Validated config from `%s`:', configPath)
-  debugLog(inspect(config, { indent: 2 }))
+  debugLog(inspect(config, { compact: false }))
 
   return validatedConfig
diff --git a/package.json b/package.json
index v13.2.3..v14.0.0 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
   "name": "lint-staged",
-  "version": "13.2.3",
+  "version": "14.0.0",
   "description": "Lint files staged by git",
   "license": "MIT",
@@ -15,5 +15,5 @@
   },
   "engines": {
-    "node": "^14.13.1 || >=16.0.0"
+    "node": "^16.14.0 || >=18.0.0"
   },
   "type": "module",
@@ -34,35 +34,31 @@
   },
   "dependencies": {
-    "chalk": "5.2.0",
-    "cli-truncate": "^3.1.0",
-    "commander": "^10.0.0",
-    "debug": "^4.3.4",
-    "execa": "^7.0.0",
+    "chalk": "5.3.0",
+    "commander": "11.0.0",
+    "debug": "4.3.4",
+    "execa": "7.2.0",
     "lilconfig": "2.1.0",
-    "listr2": "^5.0.7",
-    "micromatch": "^4.0.5",
-    "normalize-path": "^3.0.0",
-    "object-inspect": "^1.12.3",
-    "pidtree": "^0.6.0",
-    "string-argv": "^0.3.1",
-    "yaml": "^2.2.2"
+    "listr2": "6.6.1",
+    "micromatch": "4.0.5",
+    "pidtree": "0.6.0",
+    "string-argv": "0.3.2",
+    "yaml": "2.3.1"
   },
   "devDependencies": {
-    "@babel/core": "^7.21.0",
-    "@babel/eslint-parser": "^7.19.1",
-    "@babel/preset-env": "^7.20.2",
-    "babel-jest": "^29.5.0",
+    "@babel/core": "7.22.10",
+    "@babel/eslint-parser": "7.22.10",
+    "@babel/preset-env": "7.22.10",
+    "babel-jest": "29.6.2",
     "babel-plugin-transform-imports": "2.0.0",
-    "consolemock": "^1.1.0",
-    "eslint": "^8.35.0",
-    "eslint-config-prettier": "^8.7.0",
-    "eslint-plugin-import": "^2.27.5",
-    "eslint-plugin-node": "^11.1.0",
-    "eslint-plugin-prettier": "^4.2.1",
-    "fs-extra": "^11.1.0",
-    "husky": "^8.0.3",
-    "jest": "^29.5.0",
-    "jest-snapshot-serializer-ansi": "^1.0.0",
-    "prettier": "^2.8.4"
+    "consolemock": "1.1.0",
+    "eslint": "8.46.0",
+    "eslint-config-prettier": "9.0.0",
+    "eslint-plugin-import": "2.28.0",
+    "eslint-plugin-node": "11.1.0",
+    "eslint-plugin-prettier": "5.0.0",
+    "husky": "8.0.3",
+    "jest": "29.6.2",
+    "jest-snapshot-serializer-ansi": "2.1.0",
+    "prettier": "3.0.1"
   },
   "keywords": [
diff --git a/README.md b/README.md
index v13.2.3..v14.0.0 100644
--- a/README.md
+++ b/README.md
@@ -59,5 +59,5 @@
 1. Configure _lint-staged_ to run linters and other tasks:
    - for example: `{ "*.js": "eslint" }` to run ESLint for all staged JS files
-   - See [Configuration](#Configuration) for more info
+   - See [Configuration](#configuration) for more info
 
 Don't forget to commit changes to `package.json` and `.husky` to share this setup with your team!
@@ -73,4 +73,8 @@
 ### Migration
 
+#### v14
+
+- Since `v14.0.0` _lint-staged_ no longer supports Node.js 14. Please upgrade your Node.js version to at least `16.14.0`.
+
 #### v13
 
@@ -219,9 +223,9 @@
 
 - If the glob pattern contains no slashes (`/`), micromatch's `matchBase` option will enabled, so globs match a file's basename regardless of directory:
-  - **`"*.js"`** will match all JS files, like `/test.js` and `/foo/bar/test.js`
-  - **`"!(*test).js"`**. will match all JS files, except those ending in `test.js`, so `foo.js` but not `foo.test.js`
+  - `"*.js"` will match all JS files, like `/test.js` and `/foo/bar/test.js`
+  - `"!(*test).js"` will match all JS files, except those ending in `test.js`, so `foo.js` but not `foo.test.js`
 - If the glob pattern does contain a slash (`/`), it will match for paths as well:
-  - **`"./*.js"`** will match all JS files in the git repo root, so `/test.js` but not `/foo/bar/test.js`
-  - **`"foo/**/*.js"`** will match all JS files inside the `/foo` directory, so `/foo/bar/test.js` but not `/test.js`
+  - `"./*.js"` will match all JS files in the git repo root, so `/test.js` but not `/foo/bar/test.js`
+  - `"foo/**/*.js"` will match all JS files inside the `/foo` directory, so `/foo/bar/test.js` but not `/test.js`
 
 When matching, lint-staged will do the following
@@ -625,7 +629,5 @@
 
 const buildEslintCommand = (filenames) =>
-  `next lint --fix --file ${filenames
-    .map((f) => path.relative(process.cwd(), f))
-    .join(' --file ')}`
+  `next lint --fix --file ${filenames.map((f) => path.relative(process.cwd(), f)).join(' --file ')}`
 
 module.exports = {
diff --git a/lib/normalizePath.js b/lib/normalizePath.js
new file mode 100644
index v13.2.3..v14.0.0 
--- a/lib/normalizePath.js
+++ b/lib/normalizePath.js
@@ -0,0 +1,50 @@
+/**
+ * Reimplementation of "normalize-path"
+ * @see https://github.com/jonschlinkert/normalize-path/blob/52c3a95ebebc2d98c1ad7606cbafa7e658656899/index.js
+ */
+
+/*!
+ * normalize-path <https://github.com/jonschlinkert/normalize-path>
+ *
+ * Copyright (c) 2014-2018, Jon Schlinkert.
+ * Released under the MIT License.
+ */
+
+import path from 'node:path'
+
+/**
+ * A file starting with \\?\
+ * @see https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces
+ */
+const WIN32_FILE_NS = '\\\\?\\'
+
+/**
+ * A file starting with \\.\
+ * @see https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces
+ */
+const WIN32_DEVICE_NS = '\\\\.\\'
+
+/**
+ * Normalize input file path to use POSIX separators
+ * @param {String} input
+ * @returns String
+ */
+export const normalizePath = (input) => {
+  if (input === path.posix.sep || input === path.win32.sep) {
+    return path.posix.sep
+  }
+
+  let normalized = input.split(/[/\\]+/).join(path.posix.sep)
+
+  /** Handle win32 Namespaced paths by changing e.g. \\.\ to //./ */
+  if (input.startsWith(WIN32_FILE_NS) || input.startsWith(WIN32_DEVICE_NS)) {
+    normalized = normalized.replace(/^\/(\.|\?)/, '//$1')
+  }
+
+  /** Remove trailing slash */
+  if (normalized.endsWith(path.posix.sep)) {
+    normalized = normalized.slice(0, -1)
+  }
+
+  return normalized
+}
Size Files
109.0 KB → 110.6 KB (+1.6 KB 🟡) 31 → 32 (+1 🟡)
Command details
npm diff --diff=lint-staged@13.2.3 --diff=lint-staged@14.0.0 --diff-unified=2

See also the npm diff document.

Reported by ybiquitous/npm-diff-action@v1.4.1 (Node.js 18.17.0 and npm 9.8.1)

@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/lint-staged-14.0.0 branch 5 times, most recently from c12b567 to cb834bd Compare August 14, 2023 02:38
Bumps [lint-staged](https://github.com/okonet/lint-staged) from 13.2.3 to 14.0.0.
- [Release notes](https://github.com/okonet/lint-staged/releases)
- [Commits](lint-staged/lint-staged@v13.2.3...v14.0.0)

---
updated-dependencies:
- dependency-name: lint-staged
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/lint-staged-14.0.0 branch from cb834bd to 7167e80 Compare August 14, 2023 02:40
@ybiquitous ybiquitous changed the title build(deps): bump lint-staged from 13.2.3 to 14.0.0 fix(deps): bump lint-staged from 13.2.3 to 14.0.0 Aug 14, 2023
@ybiquitous ybiquitous merged commit a8b9c7c into main Aug 14, 2023
@ybiquitous ybiquitous deleted the dependabot/npm_and_yarn/lint-staged-14.0.0 branch August 14, 2023 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant