Socket
Socket
Sign inDemoInstall

@humanwhocodes/config-array

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/config-array - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

37

api.js

@@ -283,15 +283,7 @@ 'use strict';

* @param {Object} config The config object to check.
* @param {string} [mode="implicit"] When set to "implicit", any config
* without a `files` property will match; when set to "explicit",
* any config without a `files` property will not match.
* @returns {boolean} True if the file path is matched by the config,
* false if not.
*/
function pathMatches(filePath, basePath, config, mode = "implicit") {
function pathMatches(filePath, basePath, config) {
// a config without `files` field always match implicitly
if (!config.files) {
return mode === "implicit";
}
/*

@@ -662,8 +654,11 @@ * For both files and ignores, functions are passed the absolute

for (const config of this) {
if (pathMatches(filePath, this.basePath, config, "explicit")) {
if (!config.files) {
continue;
}
if (pathMatches(filePath, this.basePath, config)) {
debug(`Matching config found for ${filePath}`);
cache.explicitMatches.set(filePath, true);
return true;
} else {
debug(`No matching config found for ${filePath}`);
}

@@ -705,14 +700,24 @@ }

const matchingConfigs = [];
let matchFound = false;
for (const config of this) {
if (!config.files) {
debug(`Universal config found for ${filePath}`);
matchingConfigs.push(config);
continue;
}
if (pathMatches(filePath, this.basePath, config)) {
debug(`Matching config found for ${filePath}`);
matchingConfigs.push(config);
} else {
debug(`No matching config found for ${filePath}`);
matchFound = true;
continue;
}
}
// if matching both files and ignores, there will be no config to create
if (!matchFound) {
debug(`No matching configs found for ${filePath}`);
// if matching both files and ignores, there will be no config to create
if (matchingConfigs.length === 0) {
// cache and return result - finalConfig is undefined at this point

@@ -719,0 +724,0 @@ this[ConfigArraySymbol.configCache].set(filePath, finalConfig);

# Changelog
### [0.10.1](https://www.github.com/humanwhocodes/config-array/compare/v0.10.0...v0.10.1) (2022-03-03)
### Bug Fixes
* Explicit matching is required against files field ([ab4e428](https://www.github.com/humanwhocodes/config-array/commit/ab4e4282ecea994ef88d273dc47aa24bf3c6972e))
## [0.10.0](https://www.github.com/humanwhocodes/config-array/compare/v0.9.5...v0.10.0) (2022-03-01)

@@ -4,0 +11,0 @@

{
"name": "@humanwhocodes/config-array",
"version": "0.10.0",
"version": "0.10.1",
"description": "Glob-based configuration matching.",

@@ -5,0 +5,0 @@ "author": "Nicholas C. Zakas",

@@ -205,2 +205,3 @@ # Config Array

{
files: ["**/*"],
ignores: ["**/*.json", "!tsconfig.json"]

@@ -291,2 +292,3 @@ },

* The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
* A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own).

@@ -293,0 +295,0 @@ ## Acknowledgements

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc