lint-staged
Advanced tools
Comparing version 15.0.2 to 15.1.0
/** @typedef {import('./index').Logger} Logger */ | ||
import path from 'node:path' | ||
import debug from 'debug' | ||
@@ -12,4 +14,8 @@ import { lilconfig } from 'lilconfig' | ||
const PACKAGE_JSON = 'package.json' | ||
const CONFIG_NAME = 'lint-staged' | ||
const PACKAGE_JSON_FILE = 'package.json' | ||
const PACKAGE_YAML_FILES = ['package.yaml', 'package.yml'] | ||
/** | ||
@@ -20,3 +26,4 @@ * The list of files `lint-staged` will read configuration | ||
export const searchPlaces = [ | ||
PACKAGE_JSON, | ||
PACKAGE_JSON_FILE, | ||
...PACKAGE_YAML_FILES, | ||
'.lintstagedrc', | ||
@@ -34,8 +41,8 @@ '.lintstagedrc.json', | ||
const jsonParse = (path, content) => { | ||
const jsonParse = (filePath, content) => { | ||
try { | ||
return JSON.parse(content) | ||
} catch (error) { | ||
if (path.endsWith(PACKAGE_JSON)) { | ||
debugLog('Ignoring invalid package file `%s` with content:\n%s', path, content) | ||
if (path.basename(filePath) === PACKAGE_JSON_FILE) { | ||
debugLog('Ignoring invalid package file `%s` with content:\n%s', filePath, content) | ||
return undefined | ||
@@ -48,4 +55,17 @@ } | ||
const yamlParse = (path, content) => YAML.parse(content) | ||
const yamlParse = (filePath, content) => { | ||
const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filePath)) | ||
try { | ||
const yaml = YAML.parse(content) | ||
return isPackageFile ? yaml[CONFIG_NAME] : yaml | ||
} catch (error) { | ||
if (isPackageFile) { | ||
debugLog('Ignoring invalid package file `%s` with content:\n%s', filePath, content) | ||
return undefined | ||
} | ||
throw error | ||
} | ||
} | ||
/** | ||
@@ -67,3 +87,3 @@ * `lilconfig` doesn't support yaml files by default, | ||
const explorer = lilconfig('lint-staged', { searchPlaces, loaders }) | ||
const explorer = lilconfig(CONFIG_NAME, { searchPlaces, loaders }) | ||
@@ -70,0 +90,0 @@ /** |
@@ -111,3 +111,3 @@ /** @typedef {import('./index').Logger} Logger */ | ||
ctx.shouldBackup = hasInitialCommit && stash | ||
if (!ctx.shouldBackup) { | ||
if (!ctx.shouldBackup && !quiet) { | ||
logger.warn(skippingBackup(hasInitialCommit, diff)) | ||
@@ -246,3 +246,3 @@ } | ||
if (hasDeprecatedGitAdd) { | ||
if (hasDeprecatedGitAdd && !quiet) { | ||
logger.warn(DEPRECATED_GIT_ADD) | ||
@@ -249,0 +249,0 @@ } |
{ | ||
"name": "lint-staged", | ||
"version": "15.0.2", | ||
"version": "15.1.0", | ||
"description": "Lint files staged by git", | ||
@@ -48,18 +48,18 @@ "license": "MIT", | ||
"string-argv": "0.3.2", | ||
"yaml": "2.3.3" | ||
"yaml": "2.3.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.23.2", | ||
"@babel/eslint-parser": "7.22.15", | ||
"@babel/preset-env": "7.23.2", | ||
"@babel/core": "7.23.3", | ||
"@babel/eslint-parser": "7.23.3", | ||
"@babel/preset-env": "7.23.3", | ||
"@changesets/changelog-github": "0.4.8", | ||
"@changesets/cli": "2.26.2", | ||
"@commitlint/cli": "17.8.0", | ||
"@commitlint/config-conventional": "17.8.0", | ||
"@commitlint/cli": "18.4.0", | ||
"@commitlint/config-conventional": "18.4.0", | ||
"babel-jest": "29.7.0", | ||
"babel-plugin-transform-imports": "2.0.0", | ||
"consolemock": "1.1.0", | ||
"eslint": "8.51.0", | ||
"eslint": "8.53.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-import": "2.28.1", | ||
"eslint-plugin-import": "2.29.0", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -66,0 +66,0 @@ "eslint-plugin-prettier": "5.0.1", |
@@ -75,2 +75,6 @@ # 🚫💩 lint-staged [![Test & Release](https://github.com/okonet/lint-staged/actions/workflows/push.yml/badge.svg)](https://github.com/okonet/lint-staged/actions/workflows/push.yml) [![Publish](https://github.com/okonet/lint-staged/actions/workflows/tag.yml/badge.svg)](https://github.com/okonet/lint-staged/actions/workflows/tag.yml) [![npm version](https://badge.fury.io/js/lint-staged.svg)](https://badge.fury.io/js/lint-staged) [![Codecov](https://codecov.io/gh/okonet/lint-staged/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/lint-staged) | ||
#### v15 | ||
- Since `v15.0.0` _lint-staged_ no longer supports Node.js 16. Please upgrade your Node.js version to at least `18.12.0`. | ||
#### v14 | ||
@@ -83,2 +87,3 @@ | ||
- Since `v13.0.0` _lint-staged_ no longer supports Node.js 12. Please upgrade your Node.js version to at least `14.13.1`, or `16.0.0` onward. | ||
- Version `v13.3.0` was incorrectly released including code of version `v14.0.0`. This means the breaking changes of `v14` are also included in `v13.3.0`, the last `v13` version released | ||
@@ -150,3 +155,3 @@ #### v12 | ||
- `lint-staged` object in your `package.json` | ||
- `lint-staged` object in your `package.json`, or [`package.yaml`](https://github.com/pnpm/pnpm/pull/1799) | ||
- `.lintstagedrc` file in JSON or YML format, or you can be explicit with the file extension: | ||
@@ -153,0 +158,0 @@ - `.lintstagedrc.json` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116156
1992
932
+ Addedyaml@2.3.4(transitive)
- Removedyaml@2.3.3(transitive)
Updatedyaml@2.3.4