html-validate 8.23.0 → 8.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/core.js CHANGED
@@ -252,139 +252,149 @@ function getDefaultExportFromCjs (x) {
252
252
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
253
253
  }
254
254
 
255
- var isMergeableObject = function isMergeableObject(value) {
256
- return isNonNullObject(value)
257
- && !isSpecial(value)
258
- };
255
+ var cjs;
256
+ var hasRequiredCjs;
259
257
 
260
- function isNonNullObject(value) {
261
- return !!value && typeof value === 'object'
262
- }
258
+ function requireCjs () {
259
+ if (hasRequiredCjs) return cjs;
260
+ hasRequiredCjs = 1;
263
261
 
264
- function isSpecial(value) {
265
- var stringValue = Object.prototype.toString.call(value);
262
+ var isMergeableObject = function isMergeableObject(value) {
263
+ return isNonNullObject(value)
264
+ && !isSpecial(value)
265
+ };
266
266
 
267
- return stringValue === '[object RegExp]'
268
- || stringValue === '[object Date]'
269
- || isReactElement(value)
270
- }
267
+ function isNonNullObject(value) {
268
+ return !!value && typeof value === 'object'
269
+ }
271
270
 
272
- // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
273
- var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
274
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
271
+ function isSpecial(value) {
272
+ var stringValue = Object.prototype.toString.call(value);
275
273
 
276
- function isReactElement(value) {
277
- return value.$$typeof === REACT_ELEMENT_TYPE
278
- }
274
+ return stringValue === '[object RegExp]'
275
+ || stringValue === '[object Date]'
276
+ || isReactElement(value)
277
+ }
279
278
 
280
- function emptyTarget(val) {
281
- return Array.isArray(val) ? [] : {}
282
- }
279
+ // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
280
+ var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
281
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
283
282
 
284
- function cloneUnlessOtherwiseSpecified(value, options) {
285
- return (options.clone !== false && options.isMergeableObject(value))
286
- ? deepmerge(emptyTarget(value), value, options)
287
- : value
288
- }
283
+ function isReactElement(value) {
284
+ return value.$$typeof === REACT_ELEMENT_TYPE
285
+ }
289
286
 
290
- function defaultArrayMerge(target, source, options) {
291
- return target.concat(source).map(function(element) {
292
- return cloneUnlessOtherwiseSpecified(element, options)
293
- })
294
- }
287
+ function emptyTarget(val) {
288
+ return Array.isArray(val) ? [] : {}
289
+ }
295
290
 
296
- function getMergeFunction(key, options) {
297
- if (!options.customMerge) {
298
- return deepmerge
291
+ function cloneUnlessOtherwiseSpecified(value, options) {
292
+ return (options.clone !== false && options.isMergeableObject(value))
293
+ ? deepmerge(emptyTarget(value), value, options)
294
+ : value
299
295
  }
300
- var customMerge = options.customMerge(key);
301
- return typeof customMerge === 'function' ? customMerge : deepmerge
302
- }
303
296
 
304
- function getEnumerableOwnPropertySymbols(target) {
305
- return Object.getOwnPropertySymbols
306
- ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
307
- return Object.propertyIsEnumerable.call(target, symbol)
297
+ function defaultArrayMerge(target, source, options) {
298
+ return target.concat(source).map(function(element) {
299
+ return cloneUnlessOtherwiseSpecified(element, options)
308
300
  })
309
- : []
310
- }
301
+ }
311
302
 
312
- function getKeys(target) {
313
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
314
- }
303
+ function getMergeFunction(key, options) {
304
+ if (!options.customMerge) {
305
+ return deepmerge
306
+ }
307
+ var customMerge = options.customMerge(key);
308
+ return typeof customMerge === 'function' ? customMerge : deepmerge
309
+ }
315
310
 
316
- function propertyIsOnObject(object, property) {
317
- try {
318
- return property in object
319
- } catch(_) {
320
- return false
311
+ function getEnumerableOwnPropertySymbols(target) {
312
+ return Object.getOwnPropertySymbols
313
+ ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
314
+ return Object.propertyIsEnumerable.call(target, symbol)
315
+ })
316
+ : []
321
317
  }
322
- }
323
318
 
324
- // Protects from prototype poisoning and unexpected merging up the prototype chain.
325
- function propertyIsUnsafe(target, key) {
326
- return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
327
- && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
328
- && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
329
- }
319
+ function getKeys(target) {
320
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
321
+ }
330
322
 
331
- function mergeObject(target, source, options) {
332
- var destination = {};
333
- if (options.isMergeableObject(target)) {
334
- getKeys(target).forEach(function(key) {
335
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
336
- });
323
+ function propertyIsOnObject(object, property) {
324
+ try {
325
+ return property in object
326
+ } catch(_) {
327
+ return false
328
+ }
329
+ }
330
+
331
+ // Protects from prototype poisoning and unexpected merging up the prototype chain.
332
+ function propertyIsUnsafe(target, key) {
333
+ return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
334
+ && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
335
+ && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
337
336
  }
338
- getKeys(source).forEach(function(key) {
339
- if (propertyIsUnsafe(target, key)) {
340
- return
337
+
338
+ function mergeObject(target, source, options) {
339
+ var destination = {};
340
+ if (options.isMergeableObject(target)) {
341
+ getKeys(target).forEach(function(key) {
342
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
343
+ });
341
344
  }
345
+ getKeys(source).forEach(function(key) {
346
+ if (propertyIsUnsafe(target, key)) {
347
+ return
348
+ }
342
349
 
343
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
344
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
350
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
351
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
352
+ } else {
353
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
354
+ }
355
+ });
356
+ return destination
357
+ }
358
+
359
+ function deepmerge(target, source, options) {
360
+ options = options || {};
361
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
362
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
363
+ // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
364
+ // implementations can use it. The caller may not replace it.
365
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
366
+
367
+ var sourceIsArray = Array.isArray(source);
368
+ var targetIsArray = Array.isArray(target);
369
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
370
+
371
+ if (!sourceAndTargetTypesMatch) {
372
+ return cloneUnlessOtherwiseSpecified(source, options)
373
+ } else if (sourceIsArray) {
374
+ return options.arrayMerge(target, source, options)
345
375
  } else {
346
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
376
+ return mergeObject(target, source, options)
347
377
  }
348
- });
349
- return destination
350
- }
351
-
352
- function deepmerge(target, source, options) {
353
- options = options || {};
354
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
355
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
356
- // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
357
- // implementations can use it. The caller may not replace it.
358
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
359
-
360
- var sourceIsArray = Array.isArray(source);
361
- var targetIsArray = Array.isArray(target);
362
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
363
-
364
- if (!sourceAndTargetTypesMatch) {
365
- return cloneUnlessOtherwiseSpecified(source, options)
366
- } else if (sourceIsArray) {
367
- return options.arrayMerge(target, source, options)
368
- } else {
369
- return mergeObject(target, source, options)
370
378
  }
371
- }
372
379
 
373
- deepmerge.all = function deepmergeAll(array, options) {
374
- if (!Array.isArray(array)) {
375
- throw new Error('first argument should be an array')
376
- }
380
+ deepmerge.all = function deepmergeAll(array, options) {
381
+ if (!Array.isArray(array)) {
382
+ throw new Error('first argument should be an array')
383
+ }
377
384
 
378
- return array.reduce(function(prev, next) {
379
- return deepmerge(prev, next, options)
380
- }, {})
381
- };
385
+ return array.reduce(function(prev, next) {
386
+ return deepmerge(prev, next, options)
387
+ }, {})
388
+ };
382
389
 
383
- var deepmerge_1 = deepmerge;
390
+ var deepmerge_1 = deepmerge;
384
391
 
385
- var cjs = deepmerge_1;
392
+ cjs = deepmerge_1;
393
+ return cjs;
394
+ }
386
395
 
387
- var deepmerge$1 = /*@__PURE__*/getDefaultExportFromCjs(cjs);
396
+ var cjsExports = /*@__PURE__*/ requireCjs();
397
+ var deepmerge = /*@__PURE__*/getDefaultExportFromCjs(cjsExports);
388
398
 
389
399
  function stringify(value) {
390
400
  if (typeof value === "string") {
@@ -1217,7 +1227,7 @@ class MetaTable {
1217
1227
  */
1218
1228
  extendValidationSchema(patch) {
1219
1229
  if (patch.properties) {
1220
- this.schema = deepmerge$1(this.schema, {
1230
+ this.schema = deepmerge(this.schema, {
1221
1231
  patternProperties: {
1222
1232
  "^[^$].*$": {
1223
1233
  properties: patch.properties
@@ -1226,7 +1236,7 @@ class MetaTable {
1226
1236
  });
1227
1237
  }
1228
1238
  if (patch.definitions) {
1229
- this.schema = deepmerge$1(this.schema, {
1239
+ this.schema = deepmerge(this.schema, {
1230
1240
  definitions: patch.definitions
1231
1241
  });
1232
1242
  }
@@ -1364,7 +1374,7 @@ class MetaTable {
1364
1374
  }
1365
1375
  }
1366
1376
  mergeElement(a, b) {
1367
- const merged = deepmerge$1(a, b, { arrayMerge: overwriteMerge$1 });
1377
+ const merged = deepmerge(a, b, { arrayMerge: overwriteMerge$1 });
1368
1378
  const filteredAttrs = Object.entries(
1369
1379
  merged.attributes
1370
1380
  ).filter(([, attr]) => {
@@ -1980,7 +1990,7 @@ const table = {
1980
1990
  "nth-child": nthChild,
1981
1991
  scope
1982
1992
  };
1983
- function factory$1(name, context) {
1993
+ function factory(name, context) {
1984
1994
  const fn = table[name];
1985
1995
  if (fn) {
1986
1996
  return fn.bind(context);
@@ -2079,7 +2089,7 @@ function isQuotationMark(ch) {
2079
2089
  function isPseudoElement(ch, buffer) {
2080
2090
  return ch === ":" && buffer === ":";
2081
2091
  }
2082
- function* splitPattern$1(pattern) {
2092
+ function* splitPattern(pattern) {
2083
2093
  if (pattern === "") {
2084
2094
  return;
2085
2095
  }
@@ -2173,7 +2183,7 @@ class PseudoClassMatcher extends Matcher {
2173
2183
  this.args = args;
2174
2184
  }
2175
2185
  match(node, context) {
2176
- const fn = factory$1(this.name, context);
2186
+ const fn = factory(this.name, context);
2177
2187
  return fn(node, this.args);
2178
2188
  }
2179
2189
  }
@@ -2187,7 +2197,7 @@ class Pattern {
2187
2197
  this.selector = pattern;
2188
2198
  this.combinator = parseCombinator(match.shift(), pattern);
2189
2199
  this.tagName = match.shift() || "*";
2190
- this.pattern = Array.from(splitPattern$1(match[0]), (it) => this.createMatcher(it));
2200
+ this.pattern = Array.from(splitPattern(match[0]), (it) => this.createMatcher(it));
2191
2201
  }
2192
2202
  match(node, context) {
2193
2203
  return node.is(this.tagName) && this.pattern.every((cur) => cur.match(node, context));
@@ -4514,6 +4524,9 @@ class AttrQuotes extends Rule {
4514
4524
  }
4515
4525
  setup() {
4516
4526
  this.on("attr", (event) => {
4527
+ if (event.originalAttribute) {
4528
+ return;
4529
+ }
4517
4530
  if (event.value === null) {
4518
4531
  return;
4519
4532
  }
@@ -10445,7 +10458,7 @@ const TRANSFORMER_API = {
10445
10458
 
10446
10459
  var defaultConfig = {};
10447
10460
 
10448
- const config$4 = {
10461
+ const config$5 = {
10449
10462
  rules: {
10450
10463
  "area-alt": ["error", { accessible: true }],
10451
10464
  "aria-hidden-body": "error",
@@ -10478,6 +10491,25 @@ const config$4 = {
10478
10491
  }
10479
10492
  };
10480
10493
 
10494
+ const config$4 = {
10495
+ rules: {
10496
+ /* doctype is usually not included when fetching source code from browser */
10497
+ "missing-doctype": "off",
10498
+ /* some frameworks (such as jQuery) often uses inline style, e.g. for
10499
+ * showing/hiding elements so it is counter-productive to check for inline
10500
+ * style. If anything it should be used on original sorce code only. */
10501
+ "no-inline-style": "off",
10502
+ /* scripts will often add markup with trailing whitespace */
10503
+ "no-trailing-whitespace": "off",
10504
+ /* browser normalizes boolean attributes */
10505
+ "attribute-boolean-style": "off",
10506
+ "attribute-empty-style": "off",
10507
+ /* the browser will often do what it wants, out of users control */
10508
+ "void-style": "off",
10509
+ "no-self-closing": "off"
10510
+ }
10511
+ };
10512
+
10481
10513
  const config$3 = {
10482
10514
  rules: {
10483
10515
  "input-missing-label": "error",
@@ -10618,7 +10650,8 @@ const config = {
10618
10650
  };
10619
10651
 
10620
10652
  const presets = {
10621
- "html-validate:a11y": config$4,
10653
+ "html-validate:a11y": config$5,
10654
+ "html-validate:browser": config$4,
10622
10655
  "html-validate:document": config$3,
10623
10656
  "html-validate:prettier": config$2,
10624
10657
  "html-validate:recommended": config$1,
@@ -10626,9 +10659,8 @@ const presets = {
10626
10659
  /* @deprecated aliases */
10627
10660
  "htmlvalidate:recommended": config$1,
10628
10661
  "htmlvalidate:document": config$3,
10629
- "html-validate:a17y": config$4
10662
+ "html-validate:a17y": config$5
10630
10663
  };
10631
- var Presets = presets;
10632
10664
 
10633
10665
  class ResolvedConfig {
10634
10666
  /**
@@ -10820,9 +10852,9 @@ function overwriteMerge(a, b) {
10820
10852
  return b;
10821
10853
  }
10822
10854
  function mergeInternal(base, rhs) {
10823
- const dst = deepmerge$1(base, { ...rhs, rules: {} });
10855
+ const dst = deepmerge(base, { ...rhs, rules: {} });
10824
10856
  if (rhs.rules) {
10825
- dst.rules = deepmerge$1(dst.rules, rhs.rules, { arrayMerge: overwriteMerge });
10857
+ dst.rules = deepmerge(dst.rules, rhs.rules, { arrayMerge: overwriteMerge });
10826
10858
  }
10827
10859
  const root = Boolean(base.root) || Boolean(rhs.root);
10828
10860
  if (root) {
@@ -11086,7 +11118,7 @@ class Config {
11086
11118
  }
11087
11119
  loadConfigurations(plugins) {
11088
11120
  const configs = /* @__PURE__ */ new Map();
11089
- for (const [name, config] of Object.entries(Presets)) {
11121
+ for (const [name, config] of Object.entries(presets)) {
11090
11122
  Config.validate(config, name);
11091
11123
  configs.set(name, config);
11092
11124
  }
@@ -12849,651 +12881,660 @@ class HtmlValidate {
12849
12881
  }
12850
12882
 
12851
12883
  const name = "html-validate";
12852
- const version = "8.23.0";
12884
+ const version = "8.24.1";
12853
12885
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12854
12886
 
12855
12887
  function definePlugin(plugin) {
12856
12888
  return plugin;
12857
12889
  }
12858
12890
 
12859
- // A simple implementation of make-array
12860
- function makeArray (subject) {
12861
- return Array.isArray(subject)
12862
- ? subject
12863
- : [subject]
12864
- }
12865
-
12866
- const EMPTY = '';
12867
- const SPACE = ' ';
12868
- const ESCAPE = '\\';
12869
- const REGEX_TEST_BLANK_LINE = /^\s+$/;
12870
- const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
12871
- const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
12872
- const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
12873
- const REGEX_SPLITALL_CRLF = /\r?\n/g;
12874
- // /foo,
12875
- // ./foo,
12876
- // ../foo,
12877
- // .
12878
- // ..
12879
- const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
12880
-
12881
- const SLASH = '/';
12882
-
12883
- // Do not use ternary expression here, since "istanbul ignore next" is buggy
12884
- let TMP_KEY_IGNORE = 'node-ignore';
12885
- /* istanbul ignore else */
12886
- if (typeof Symbol !== 'undefined') {
12887
- TMP_KEY_IGNORE = Symbol.for('node-ignore');
12888
- }
12889
- const KEY_IGNORE = TMP_KEY_IGNORE;
12890
-
12891
- const define = (object, key, value) =>
12892
- Object.defineProperty(object, key, {value});
12893
-
12894
- const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
12895
-
12896
- const RETURN_FALSE = () => false;
12897
-
12898
- // Sanitize the range of a regular expression
12899
- // The cases are complicated, see test cases for details
12900
- const sanitizeRange = range => range.replace(
12901
- REGEX_REGEXP_RANGE,
12902
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
12903
- ? match
12904
- // Invalid range (out of order) which is ok for gitignore rules but
12905
- // fatal for JavaScript regular expression, so eliminate it.
12906
- : EMPTY
12907
- );
12908
-
12909
- // See fixtures #59
12910
- const cleanRangeBackSlash = slashes => {
12911
- const {length} = slashes;
12912
- return slashes.slice(0, length - length % 2)
12913
- };
12914
-
12915
- // > If the pattern ends with a slash,
12916
- // > it is removed for the purpose of the following description,
12917
- // > but it would only find a match with a directory.
12918
- // > In other words, foo/ will match a directory foo and paths underneath it,
12919
- // > but will not match a regular file or a symbolic link foo
12920
- // > (this is consistent with the way how pathspec works in general in Git).
12921
- // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
12922
- // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
12923
- // you could use option `mark: true` with `glob`
12924
-
12925
- // '`foo/`' should not continue with the '`..`'
12926
- const REPLACERS = [
12927
-
12928
- [
12929
- // remove BOM
12930
- // TODO:
12931
- // Other similar zero-width characters?
12932
- /^\uFEFF/,
12933
- () => EMPTY
12934
- ],
12935
-
12936
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
12937
- [
12938
- // (a\ ) -> (a )
12939
- // (a ) -> (a)
12940
- // (a ) -> (a)
12941
- // (a \ ) -> (a )
12942
- /((?:\\\\)*?)(\\?\s+)$/,
12943
- (_, m1, m2) => m1 + (
12944
- m2.indexOf('\\') === 0
12945
- ? SPACE
12946
- : EMPTY
12947
- )
12948
- ],
12949
-
12950
- // replace (\ ) with ' '
12951
- // (\ ) -> ' '
12952
- // (\\ ) -> '\\ '
12953
- // (\\\ ) -> '\\ '
12954
- [
12955
- /(\\+?)\s/g,
12956
- (_, m1) => {
12957
- const {length} = m1;
12958
- return m1.slice(0, length - length % 2) + SPACE
12959
- }
12960
- ],
12961
-
12962
- // Escape metacharacters
12963
- // which is written down by users but means special for regular expressions.
12964
-
12965
- // > There are 12 characters with special meanings:
12966
- // > - the backslash \,
12967
- // > - the caret ^,
12968
- // > - the dollar sign $,
12969
- // > - the period or dot .,
12970
- // > - the vertical bar or pipe symbol |,
12971
- // > - the question mark ?,
12972
- // > - the asterisk or star *,
12973
- // > - the plus sign +,
12974
- // > - the opening parenthesis (,
12975
- // > - the closing parenthesis ),
12976
- // > - and the opening square bracket [,
12977
- // > - the opening curly brace {,
12978
- // > These special characters are often called "metacharacters".
12979
- [
12980
- /[\\$.|*+(){^]/g,
12981
- match => `\\${match}`
12982
- ],
12983
-
12984
- [
12985
- // > a question mark (?) matches a single character
12986
- /(?!\\)\?/g,
12987
- () => '[^/]'
12988
- ],
12989
-
12990
- // leading slash
12991
- [
12992
-
12993
- // > A leading slash matches the beginning of the pathname.
12994
- // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
12995
- // A leading slash matches the beginning of the pathname
12996
- /^\//,
12997
- () => '^'
12998
- ],
12999
-
13000
- // replace special metacharacter slash after the leading slash
13001
- [
13002
- /\//g,
13003
- () => '\\/'
13004
- ],
13005
-
13006
- [
13007
- // > A leading "**" followed by a slash means match in all directories.
13008
- // > For example, "**/foo" matches file or directory "foo" anywhere,
13009
- // > the same as pattern "foo".
13010
- // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
13011
- // > under directory "foo".
13012
- // Notice that the '*'s have been replaced as '\\*'
13013
- /^\^*\\\*\\\*\\\//,
13014
-
13015
- // '**/foo' <-> 'foo'
13016
- () => '^(?:.*\\/)?'
13017
- ],
13018
-
13019
- // starting
13020
- [
13021
- // there will be no leading '/'
13022
- // (which has been replaced by section "leading slash")
13023
- // If starts with '**', adding a '^' to the regular expression also works
13024
- /^(?=[^^])/,
13025
- function startingReplacer () {
13026
- // If has a slash `/` at the beginning or middle
13027
- return !/\/(?!$)/.test(this)
13028
- // > Prior to 2.22.1
13029
- // > If the pattern does not contain a slash /,
13030
- // > Git treats it as a shell glob pattern
13031
- // Actually, if there is only a trailing slash,
13032
- // git also treats it as a shell glob pattern
13033
-
13034
- // After 2.22.1 (compatible but clearer)
13035
- // > If there is a separator at the beginning or middle (or both)
13036
- // > of the pattern, then the pattern is relative to the directory
13037
- // > level of the particular .gitignore file itself.
13038
- // > Otherwise the pattern may also match at any level below
13039
- // > the .gitignore level.
13040
- ? '(?:^|\\/)'
13041
-
13042
- // > Otherwise, Git treats the pattern as a shell glob suitable for
13043
- // > consumption by fnmatch(3)
13044
- : '^'
13045
- }
13046
- ],
13047
-
13048
- // two globstars
13049
- [
13050
- // Use lookahead assertions so that we could match more than one `'/**'`
13051
- /\\\/\\\*\\\*(?=\\\/|$)/g,
13052
-
13053
- // Zero, one or several directories
13054
- // should not use '*', or it will be replaced by the next replacer
13055
-
13056
- // Check if it is not the last `'/**'`
13057
- (_, index, str) => index + 6 < str.length
13058
-
13059
- // case: /**/
13060
- // > A slash followed by two consecutive asterisks then a slash matches
13061
- // > zero or more directories.
13062
- // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
13063
- // '/**/'
13064
- ? '(?:\\/[^\\/]+)*'
13065
-
13066
- // case: /**
13067
- // > A trailing `"/**"` matches everything inside.
13068
-
13069
- // #21: everything inside but it should not include the current folder
13070
- : '\\/.+'
13071
- ],
13072
-
13073
- // normal intermediate wildcards
13074
- [
13075
- // Never replace escaped '*'
13076
- // ignore rule '\*' will match the path '*'
13077
-
13078
- // 'abc.*/' -> go
13079
- // 'abc.*' -> skip this rule,
13080
- // coz trailing single wildcard will be handed by [trailing wildcard]
13081
- /(^|[^\\]+)(\\\*)+(?=.+)/g,
13082
-
13083
- // '*.js' matches '.js'
13084
- // '*.js' doesn't match 'abc'
13085
- (_, p1, p2) => {
13086
- // 1.
13087
- // > An asterisk "*" matches anything except a slash.
13088
- // 2.
13089
- // > Other consecutive asterisks are considered regular asterisks
13090
- // > and will match according to the previous rules.
13091
- const unescaped = p2.replace(/\\\*/g, '[^\\/]*');
13092
- return p1 + unescaped
13093
- }
13094
- ],
13095
-
13096
- [
13097
- // unescape, revert step 3 except for back slash
13098
- // For example, if a user escape a '\\*',
13099
- // after step 3, the result will be '\\\\\\*'
13100
- /\\\\\\(?=[$.|*+(){^])/g,
13101
- () => ESCAPE
13102
- ],
13103
-
13104
- [
13105
- // '\\\\' -> '\\'
13106
- /\\\\/g,
13107
- () => ESCAPE
13108
- ],
13109
-
13110
- [
13111
- // > The range notation, e.g. [a-zA-Z],
13112
- // > can be used to match one of the characters in a range.
13113
-
13114
- // `\` is escaped by step 3
13115
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
13116
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
13117
- // '\\[bar]' -> '\\\\[bar\\]'
13118
- ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
13119
- : close === ']'
13120
- ? endEscape.length % 2 === 0
13121
- // A normal case, and it is a range notation
13122
- // '[bar]'
13123
- // '[bar\\\\]'
13124
- ? `[${sanitizeRange(range)}${endEscape}]`
13125
- // Invalid range notaton
13126
- // '[bar\\]' -> '[bar\\\\]'
13127
- : '[]'
13128
- : '[]'
13129
- ],
13130
-
13131
- // ending
13132
- [
13133
- // 'js' will not match 'js.'
13134
- // 'ab' will not match 'abc'
13135
- /(?:[^*])$/,
13136
-
13137
- // WTF!
13138
- // https://git-scm.com/docs/gitignore
13139
- // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
13140
- // which re-fixes #24, #38
13141
-
13142
- // > If there is a separator at the end of the pattern then the pattern
13143
- // > will only match directories, otherwise the pattern can match both
13144
- // > files and directories.
13145
-
13146
- // 'js*' will not match 'a.js'
13147
- // 'js/' will not match 'a.js'
13148
- // 'js' will match 'a.js' and 'a.js/'
13149
- match => /\/$/.test(match)
13150
- // foo/ will not match 'foo'
13151
- ? `${match}$`
13152
- // foo matches 'foo' and 'foo/'
13153
- : `${match}(?=$|\\/$)`
13154
- ],
13155
-
13156
- // trailing wildcard
13157
- [
13158
- /(\^|\\\/)?\\\*$/,
13159
- (_, p1) => {
13160
- const prefix = p1
13161
- // '\^':
13162
- // '/*' does not match EMPTY
13163
- // '/*' does not match everything
13164
-
13165
- // '\\\/':
13166
- // 'abc/*' does not match 'abc/'
13167
- ? `${p1}[^/]+`
13168
-
13169
- // 'a*' matches 'a'
13170
- // 'a*' matches 'aa'
13171
- : '[^/]*';
13172
-
13173
- return `${prefix}(?=$|\\/$)`
13174
- }
13175
- ],
13176
- ];
13177
-
13178
- // A simple cache, because an ignore rule only has only one certain meaning
13179
- const regexCache = Object.create(null);
13180
-
13181
- // @param {pattern}
13182
- const makeRegex = (pattern, ignoreCase) => {
13183
- let source = regexCache[pattern];
13184
-
13185
- if (!source) {
13186
- source = REPLACERS.reduce(
13187
- (prev, [matcher, replacer]) =>
13188
- prev.replace(matcher, replacer.bind(pattern)),
13189
- pattern
13190
- );
13191
- regexCache[pattern] = source;
13192
- }
13193
-
13194
- return ignoreCase
13195
- ? new RegExp(source, 'i')
13196
- : new RegExp(source)
13197
- };
13198
-
13199
- const isString = subject => typeof subject === 'string';
13200
-
13201
- // > A blank line matches no files, so it can serve as a separator for readability.
13202
- const checkPattern = pattern => pattern
13203
- && isString(pattern)
13204
- && !REGEX_TEST_BLANK_LINE.test(pattern)
13205
- && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
13206
-
13207
- // > A line starting with # serves as a comment.
13208
- && pattern.indexOf('#') !== 0;
13209
-
13210
- const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
13211
-
13212
- class IgnoreRule {
13213
- constructor (
13214
- origin,
13215
- pattern,
13216
- negative,
13217
- regex
13218
- ) {
13219
- this.origin = origin;
13220
- this.pattern = pattern;
13221
- this.negative = negative;
13222
- this.regex = regex;
13223
- }
13224
- }
13225
-
13226
- const createRule = (pattern, ignoreCase) => {
13227
- const origin = pattern;
13228
- let negative = false;
13229
-
13230
- // > An optional prefix "!" which negates the pattern;
13231
- if (pattern.indexOf('!') === 0) {
13232
- negative = true;
13233
- pattern = pattern.substr(1);
13234
- }
13235
-
13236
- pattern = pattern
13237
- // > Put a backslash ("\") in front of the first "!" for patterns that
13238
- // > begin with a literal "!", for example, `"\!important!.txt"`.
13239
- .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
13240
- // > Put a backslash ("\") in front of the first hash for patterns that
13241
- // > begin with a hash.
13242
- .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
13243
-
13244
- const regex = makeRegex(pattern, ignoreCase);
13245
-
13246
- return new IgnoreRule(
13247
- origin,
13248
- pattern,
13249
- negative,
13250
- regex
13251
- )
13252
- };
13253
-
13254
- const throwError = (message, Ctor) => {
13255
- throw new Ctor(message)
13256
- };
13257
-
13258
- const checkPath = (path, originalPath, doThrow) => {
13259
- if (!isString(path)) {
13260
- return doThrow(
13261
- `path must be a string, but got \`${originalPath}\``,
13262
- TypeError
13263
- )
13264
- }
13265
-
13266
- // We don't know if we should ignore EMPTY, so throw
13267
- if (!path) {
13268
- return doThrow(`path must not be empty`, TypeError)
13269
- }
13270
-
13271
- // Check if it is a relative path
13272
- if (checkPath.isNotRelative(path)) {
13273
- const r = '`path.relative()`d';
13274
- return doThrow(
13275
- `path should be a ${r} string, but got "${originalPath}"`,
13276
- RangeError
13277
- )
13278
- }
13279
-
13280
- return true
13281
- };
13282
-
13283
- const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
13284
-
13285
- checkPath.isNotRelative = isNotRelative;
13286
- checkPath.convert = p => p;
13287
-
13288
- class Ignore {
13289
- constructor ({
13290
- ignorecase = true,
13291
- ignoreCase = ignorecase,
13292
- allowRelativePaths = false
13293
- } = {}) {
13294
- define(this, KEY_IGNORE, true);
13295
-
13296
- this._rules = [];
13297
- this._ignoreCase = ignoreCase;
13298
- this._allowRelativePaths = allowRelativePaths;
13299
- this._initCache();
13300
- }
13301
-
13302
- _initCache () {
13303
- this._ignoreCache = Object.create(null);
13304
- this._testCache = Object.create(null);
13305
- }
13306
-
13307
- _addPattern (pattern) {
13308
- // #32
13309
- if (pattern && pattern[KEY_IGNORE]) {
13310
- this._rules = this._rules.concat(pattern._rules);
13311
- this._added = true;
13312
- return
13313
- }
13314
-
13315
- if (checkPattern(pattern)) {
13316
- const rule = createRule(pattern, this._ignoreCase);
13317
- this._added = true;
13318
- this._rules.push(rule);
13319
- }
13320
- }
13321
-
13322
- // @param {Array<string> | string | Ignore} pattern
13323
- add (pattern) {
13324
- this._added = false;
13325
-
13326
- makeArray(
13327
- isString(pattern)
13328
- ? splitPattern(pattern)
13329
- : pattern
13330
- ).forEach(this._addPattern, this);
13331
-
13332
- // Some rules have just added to the ignore,
13333
- // making the behavior changed.
13334
- if (this._added) {
13335
- this._initCache();
13336
- }
13337
-
13338
- return this
13339
- }
13340
-
13341
- // legacy
13342
- addPattern (pattern) {
13343
- return this.add(pattern)
13344
- }
13345
-
13346
- // | ignored : unignored
13347
- // negative | 0:0 | 0:1 | 1:0 | 1:1
13348
- // -------- | ------- | ------- | ------- | --------
13349
- // 0 | TEST | TEST | SKIP | X
13350
- // 1 | TESTIF | SKIP | TEST | X
13351
-
13352
- // - SKIP: always skip
13353
- // - TEST: always test
13354
- // - TESTIF: only test if checkUnignored
13355
- // - X: that never happen
13356
-
13357
- // @param {boolean} whether should check if the path is unignored,
13358
- // setting `checkUnignored` to `false` could reduce additional
13359
- // path matching.
13360
-
13361
- // @returns {TestResult} true if a file is ignored
13362
- _testOne (path, checkUnignored) {
13363
- let ignored = false;
13364
- let unignored = false;
13365
-
13366
- this._rules.forEach(rule => {
13367
- const {negative} = rule;
13368
- if (
13369
- unignored === negative && ignored !== unignored
13370
- || negative && !ignored && !unignored && !checkUnignored
13371
- ) {
13372
- return
13373
- }
13374
-
13375
- const matched = rule.regex.test(path);
13376
-
13377
- if (matched) {
13378
- ignored = !negative;
13379
- unignored = negative;
13380
- }
13381
- });
13382
-
13383
- return {
13384
- ignored,
13385
- unignored
13386
- }
13387
- }
13388
-
13389
- // @returns {TestResult}
13390
- _test (originalPath, cache, checkUnignored, slices) {
13391
- const path = originalPath
13392
- // Supports nullable path
13393
- && checkPath.convert(originalPath);
13394
-
13395
- checkPath(
13396
- path,
13397
- originalPath,
13398
- this._allowRelativePaths
13399
- ? RETURN_FALSE
13400
- : throwError
13401
- );
13402
-
13403
- return this._t(path, cache, checkUnignored, slices)
13404
- }
13405
-
13406
- _t (path, cache, checkUnignored, slices) {
13407
- if (path in cache) {
13408
- return cache[path]
13409
- }
13410
-
13411
- if (!slices) {
13412
- // path/to/a.js
13413
- // ['path', 'to', 'a.js']
13414
- slices = path.split(SLASH);
13415
- }
13416
-
13417
- slices.pop();
13418
-
13419
- // If the path has no parent directory, just test it
13420
- if (!slices.length) {
13421
- return cache[path] = this._testOne(path, checkUnignored)
13422
- }
13423
-
13424
- const parent = this._t(
13425
- slices.join(SLASH) + SLASH,
13426
- cache,
13427
- checkUnignored,
13428
- slices
13429
- );
13430
-
13431
- // If the path contains a parent directory, check the parent first
13432
- return cache[path] = parent.ignored
13433
- // > It is not possible to re-include a file if a parent directory of
13434
- // > that file is excluded.
13435
- ? parent
13436
- : this._testOne(path, checkUnignored)
13437
- }
13438
-
13439
- ignores (path) {
13440
- return this._test(path, this._ignoreCache, false).ignored
13441
- }
13442
-
13443
- createFilter () {
13444
- return path => !this.ignores(path)
13445
- }
13446
-
13447
- filter (paths) {
13448
- return makeArray(paths).filter(this.createFilter())
13449
- }
13450
-
13451
- // @returns {TestResult}
13452
- test (path) {
13453
- return this._test(path, this._testCache, true)
13454
- }
13455
- }
13456
-
13457
- const factory = options => new Ignore(options);
13458
-
13459
- const isPathValid = path =>
13460
- checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
13461
-
13462
- factory.isPathValid = isPathValid;
12891
+ var ignore$1;
12892
+ var hasRequiredIgnore;
13463
12893
 
13464
- // Fixes typescript
13465
- factory.default = factory;
13466
-
13467
- var ignore = factory;
12894
+ function requireIgnore () {
12895
+ if (hasRequiredIgnore) return ignore$1;
12896
+ hasRequiredIgnore = 1;
12897
+ // A simple implementation of make-array
12898
+ function makeArray (subject) {
12899
+ return Array.isArray(subject)
12900
+ ? subject
12901
+ : [subject]
12902
+ }
13468
12903
 
13469
- // Windows
13470
- // --------------------------------------------------------------
13471
- /* istanbul ignore if */
13472
- if (
13473
- // Detect `process` so that it can run in browsers.
13474
- typeof process !== 'undefined'
13475
- && (
13476
- process.env && process.env.IGNORE_TEST_WIN32
13477
- || process.platform === 'win32'
13478
- )
13479
- ) {
13480
- /* eslint no-control-regex: "off" */
13481
- const makePosix = str => /^\\\\\?\\/.test(str)
13482
- || /["<>|\u0000-\u001F]+/u.test(str)
13483
- ? str
13484
- : str.replace(/\\/g, '/');
12904
+ const EMPTY = '';
12905
+ const SPACE = ' ';
12906
+ const ESCAPE = '\\';
12907
+ const REGEX_TEST_BLANK_LINE = /^\s+$/;
12908
+ const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
12909
+ const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
12910
+ const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
12911
+ const REGEX_SPLITALL_CRLF = /\r?\n/g;
12912
+ // /foo,
12913
+ // ./foo,
12914
+ // ../foo,
12915
+ // .
12916
+ // ..
12917
+ const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
12918
+
12919
+ const SLASH = '/';
12920
+
12921
+ // Do not use ternary expression here, since "istanbul ignore next" is buggy
12922
+ let TMP_KEY_IGNORE = 'node-ignore';
12923
+ /* istanbul ignore else */
12924
+ if (typeof Symbol !== 'undefined') {
12925
+ TMP_KEY_IGNORE = Symbol.for('node-ignore');
12926
+ }
12927
+ const KEY_IGNORE = TMP_KEY_IGNORE;
12928
+
12929
+ const define = (object, key, value) =>
12930
+ Object.defineProperty(object, key, {value});
12931
+
12932
+ const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
12933
+
12934
+ const RETURN_FALSE = () => false;
12935
+
12936
+ // Sanitize the range of a regular expression
12937
+ // The cases are complicated, see test cases for details
12938
+ const sanitizeRange = range => range.replace(
12939
+ REGEX_REGEXP_RANGE,
12940
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
12941
+ ? match
12942
+ // Invalid range (out of order) which is ok for gitignore rules but
12943
+ // fatal for JavaScript regular expression, so eliminate it.
12944
+ : EMPTY
12945
+ );
12946
+
12947
+ // See fixtures #59
12948
+ const cleanRangeBackSlash = slashes => {
12949
+ const {length} = slashes;
12950
+ return slashes.slice(0, length - length % 2)
12951
+ };
12952
+
12953
+ // > If the pattern ends with a slash,
12954
+ // > it is removed for the purpose of the following description,
12955
+ // > but it would only find a match with a directory.
12956
+ // > In other words, foo/ will match a directory foo and paths underneath it,
12957
+ // > but will not match a regular file or a symbolic link foo
12958
+ // > (this is consistent with the way how pathspec works in general in Git).
12959
+ // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
12960
+ // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
12961
+ // you could use option `mark: true` with `glob`
12962
+
12963
+ // '`foo/`' should not continue with the '`..`'
12964
+ const REPLACERS = [
12965
+
12966
+ [
12967
+ // remove BOM
12968
+ // TODO:
12969
+ // Other similar zero-width characters?
12970
+ /^\uFEFF/,
12971
+ () => EMPTY
12972
+ ],
12973
+
12974
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
12975
+ [
12976
+ // (a\ ) -> (a )
12977
+ // (a ) -> (a)
12978
+ // (a ) -> (a)
12979
+ // (a \ ) -> (a )
12980
+ /((?:\\\\)*?)(\\?\s+)$/,
12981
+ (_, m1, m2) => m1 + (
12982
+ m2.indexOf('\\') === 0
12983
+ ? SPACE
12984
+ : EMPTY
12985
+ )
12986
+ ],
12987
+
12988
+ // replace (\ ) with ' '
12989
+ // (\ ) -> ' '
12990
+ // (\\ ) -> '\\ '
12991
+ // (\\\ ) -> '\\ '
12992
+ [
12993
+ /(\\+?)\s/g,
12994
+ (_, m1) => {
12995
+ const {length} = m1;
12996
+ return m1.slice(0, length - length % 2) + SPACE
12997
+ }
12998
+ ],
12999
+
13000
+ // Escape metacharacters
13001
+ // which is written down by users but means special for regular expressions.
13002
+
13003
+ // > There are 12 characters with special meanings:
13004
+ // > - the backslash \,
13005
+ // > - the caret ^,
13006
+ // > - the dollar sign $,
13007
+ // > - the period or dot .,
13008
+ // > - the vertical bar or pipe symbol |,
13009
+ // > - the question mark ?,
13010
+ // > - the asterisk or star *,
13011
+ // > - the plus sign +,
13012
+ // > - the opening parenthesis (,
13013
+ // > - the closing parenthesis ),
13014
+ // > - and the opening square bracket [,
13015
+ // > - the opening curly brace {,
13016
+ // > These special characters are often called "metacharacters".
13017
+ [
13018
+ /[\\$.|*+(){^]/g,
13019
+ match => `\\${match}`
13020
+ ],
13021
+
13022
+ [
13023
+ // > a question mark (?) matches a single character
13024
+ /(?!\\)\?/g,
13025
+ () => '[^/]'
13026
+ ],
13027
+
13028
+ // leading slash
13029
+ [
13030
+
13031
+ // > A leading slash matches the beginning of the pathname.
13032
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
13033
+ // A leading slash matches the beginning of the pathname
13034
+ /^\//,
13035
+ () => '^'
13036
+ ],
13037
+
13038
+ // replace special metacharacter slash after the leading slash
13039
+ [
13040
+ /\//g,
13041
+ () => '\\/'
13042
+ ],
13043
+
13044
+ [
13045
+ // > A leading "**" followed by a slash means match in all directories.
13046
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
13047
+ // > the same as pattern "foo".
13048
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
13049
+ // > under directory "foo".
13050
+ // Notice that the '*'s have been replaced as '\\*'
13051
+ /^\^*\\\*\\\*\\\//,
13052
+
13053
+ // '**/foo' <-> 'foo'
13054
+ () => '^(?:.*\\/)?'
13055
+ ],
13056
+
13057
+ // starting
13058
+ [
13059
+ // there will be no leading '/'
13060
+ // (which has been replaced by section "leading slash")
13061
+ // If starts with '**', adding a '^' to the regular expression also works
13062
+ /^(?=[^^])/,
13063
+ function startingReplacer () {
13064
+ // If has a slash `/` at the beginning or middle
13065
+ return !/\/(?!$)/.test(this)
13066
+ // > Prior to 2.22.1
13067
+ // > If the pattern does not contain a slash /,
13068
+ // > Git treats it as a shell glob pattern
13069
+ // Actually, if there is only a trailing slash,
13070
+ // git also treats it as a shell glob pattern
13071
+
13072
+ // After 2.22.1 (compatible but clearer)
13073
+ // > If there is a separator at the beginning or middle (or both)
13074
+ // > of the pattern, then the pattern is relative to the directory
13075
+ // > level of the particular .gitignore file itself.
13076
+ // > Otherwise the pattern may also match at any level below
13077
+ // > the .gitignore level.
13078
+ ? '(?:^|\\/)'
13079
+
13080
+ // > Otherwise, Git treats the pattern as a shell glob suitable for
13081
+ // > consumption by fnmatch(3)
13082
+ : '^'
13083
+ }
13084
+ ],
13085
+
13086
+ // two globstars
13087
+ [
13088
+ // Use lookahead assertions so that we could match more than one `'/**'`
13089
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
13090
+
13091
+ // Zero, one or several directories
13092
+ // should not use '*', or it will be replaced by the next replacer
13093
+
13094
+ // Check if it is not the last `'/**'`
13095
+ (_, index, str) => index + 6 < str.length
13096
+
13097
+ // case: /**/
13098
+ // > A slash followed by two consecutive asterisks then a slash matches
13099
+ // > zero or more directories.
13100
+ // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
13101
+ // '/**/'
13102
+ ? '(?:\\/[^\\/]+)*'
13103
+
13104
+ // case: /**
13105
+ // > A trailing `"/**"` matches everything inside.
13106
+
13107
+ // #21: everything inside but it should not include the current folder
13108
+ : '\\/.+'
13109
+ ],
13110
+
13111
+ // normal intermediate wildcards
13112
+ [
13113
+ // Never replace escaped '*'
13114
+ // ignore rule '\*' will match the path '*'
13115
+
13116
+ // 'abc.*/' -> go
13117
+ // 'abc.*' -> skip this rule,
13118
+ // coz trailing single wildcard will be handed by [trailing wildcard]
13119
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
13120
+
13121
+ // '*.js' matches '.js'
13122
+ // '*.js' doesn't match 'abc'
13123
+ (_, p1, p2) => {
13124
+ // 1.
13125
+ // > An asterisk "*" matches anything except a slash.
13126
+ // 2.
13127
+ // > Other consecutive asterisks are considered regular asterisks
13128
+ // > and will match according to the previous rules.
13129
+ const unescaped = p2.replace(/\\\*/g, '[^\\/]*');
13130
+ return p1 + unescaped
13131
+ }
13132
+ ],
13133
+
13134
+ [
13135
+ // unescape, revert step 3 except for back slash
13136
+ // For example, if a user escape a '\\*',
13137
+ // after step 3, the result will be '\\\\\\*'
13138
+ /\\\\\\(?=[$.|*+(){^])/g,
13139
+ () => ESCAPE
13140
+ ],
13141
+
13142
+ [
13143
+ // '\\\\' -> '\\'
13144
+ /\\\\/g,
13145
+ () => ESCAPE
13146
+ ],
13147
+
13148
+ [
13149
+ // > The range notation, e.g. [a-zA-Z],
13150
+ // > can be used to match one of the characters in a range.
13151
+
13152
+ // `\` is escaped by step 3
13153
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
13154
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
13155
+ // '\\[bar]' -> '\\\\[bar\\]'
13156
+ ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
13157
+ : close === ']'
13158
+ ? endEscape.length % 2 === 0
13159
+ // A normal case, and it is a range notation
13160
+ // '[bar]'
13161
+ // '[bar\\\\]'
13162
+ ? `[${sanitizeRange(range)}${endEscape}]`
13163
+ // Invalid range notaton
13164
+ // '[bar\\]' -> '[bar\\\\]'
13165
+ : '[]'
13166
+ : '[]'
13167
+ ],
13168
+
13169
+ // ending
13170
+ [
13171
+ // 'js' will not match 'js.'
13172
+ // 'ab' will not match 'abc'
13173
+ /(?:[^*])$/,
13174
+
13175
+ // WTF!
13176
+ // https://git-scm.com/docs/gitignore
13177
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
13178
+ // which re-fixes #24, #38
13179
+
13180
+ // > If there is a separator at the end of the pattern then the pattern
13181
+ // > will only match directories, otherwise the pattern can match both
13182
+ // > files and directories.
13183
+
13184
+ // 'js*' will not match 'a.js'
13185
+ // 'js/' will not match 'a.js'
13186
+ // 'js' will match 'a.js' and 'a.js/'
13187
+ match => /\/$/.test(match)
13188
+ // foo/ will not match 'foo'
13189
+ ? `${match}$`
13190
+ // foo matches 'foo' and 'foo/'
13191
+ : `${match}(?=$|\\/$)`
13192
+ ],
13193
+
13194
+ // trailing wildcard
13195
+ [
13196
+ /(\^|\\\/)?\\\*$/,
13197
+ (_, p1) => {
13198
+ const prefix = p1
13199
+ // '\^':
13200
+ // '/*' does not match EMPTY
13201
+ // '/*' does not match everything
13202
+
13203
+ // '\\\/':
13204
+ // 'abc/*' does not match 'abc/'
13205
+ ? `${p1}[^/]+`
13206
+
13207
+ // 'a*' matches 'a'
13208
+ // 'a*' matches 'aa'
13209
+ : '[^/]*';
13210
+
13211
+ return `${prefix}(?=$|\\/$)`
13212
+ }
13213
+ ],
13214
+ ];
13215
+
13216
+ // A simple cache, because an ignore rule only has only one certain meaning
13217
+ const regexCache = Object.create(null);
13218
+
13219
+ // @param {pattern}
13220
+ const makeRegex = (pattern, ignoreCase) => {
13221
+ let source = regexCache[pattern];
13222
+
13223
+ if (!source) {
13224
+ source = REPLACERS.reduce(
13225
+ (prev, [matcher, replacer]) =>
13226
+ prev.replace(matcher, replacer.bind(pattern)),
13227
+ pattern
13228
+ );
13229
+ regexCache[pattern] = source;
13230
+ }
13231
+
13232
+ return ignoreCase
13233
+ ? new RegExp(source, 'i')
13234
+ : new RegExp(source)
13235
+ };
13236
+
13237
+ const isString = subject => typeof subject === 'string';
13238
+
13239
+ // > A blank line matches no files, so it can serve as a separator for readability.
13240
+ const checkPattern = pattern => pattern
13241
+ && isString(pattern)
13242
+ && !REGEX_TEST_BLANK_LINE.test(pattern)
13243
+ && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
13244
+
13245
+ // > A line starting with # serves as a comment.
13246
+ && pattern.indexOf('#') !== 0;
13247
+
13248
+ const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
13249
+
13250
+ class IgnoreRule {
13251
+ constructor (
13252
+ origin,
13253
+ pattern,
13254
+ negative,
13255
+ regex
13256
+ ) {
13257
+ this.origin = origin;
13258
+ this.pattern = pattern;
13259
+ this.negative = negative;
13260
+ this.regex = regex;
13261
+ }
13262
+ }
13485
13263
 
13486
- checkPath.convert = makePosix;
13264
+ const createRule = (pattern, ignoreCase) => {
13265
+ const origin = pattern;
13266
+ let negative = false;
13267
+
13268
+ // > An optional prefix "!" which negates the pattern;
13269
+ if (pattern.indexOf('!') === 0) {
13270
+ negative = true;
13271
+ pattern = pattern.substr(1);
13272
+ }
13273
+
13274
+ pattern = pattern
13275
+ // > Put a backslash ("\") in front of the first "!" for patterns that
13276
+ // > begin with a literal "!", for example, `"\!important!.txt"`.
13277
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
13278
+ // > Put a backslash ("\") in front of the first hash for patterns that
13279
+ // > begin with a hash.
13280
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
13281
+
13282
+ const regex = makeRegex(pattern, ignoreCase);
13283
+
13284
+ return new IgnoreRule(
13285
+ origin,
13286
+ pattern,
13287
+ negative,
13288
+ regex
13289
+ )
13290
+ };
13291
+
13292
+ const throwError = (message, Ctor) => {
13293
+ throw new Ctor(message)
13294
+ };
13295
+
13296
+ const checkPath = (path, originalPath, doThrow) => {
13297
+ if (!isString(path)) {
13298
+ return doThrow(
13299
+ `path must be a string, but got \`${originalPath}\``,
13300
+ TypeError
13301
+ )
13302
+ }
13303
+
13304
+ // We don't know if we should ignore EMPTY, so throw
13305
+ if (!path) {
13306
+ return doThrow(`path must not be empty`, TypeError)
13307
+ }
13308
+
13309
+ // Check if it is a relative path
13310
+ if (checkPath.isNotRelative(path)) {
13311
+ const r = '`path.relative()`d';
13312
+ return doThrow(
13313
+ `path should be a ${r} string, but got "${originalPath}"`,
13314
+ RangeError
13315
+ )
13316
+ }
13317
+
13318
+ return true
13319
+ };
13320
+
13321
+ const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
13322
+
13323
+ checkPath.isNotRelative = isNotRelative;
13324
+ checkPath.convert = p => p;
13325
+
13326
+ class Ignore {
13327
+ constructor ({
13328
+ ignorecase = true,
13329
+ ignoreCase = ignorecase,
13330
+ allowRelativePaths = false
13331
+ } = {}) {
13332
+ define(this, KEY_IGNORE, true);
13333
+
13334
+ this._rules = [];
13335
+ this._ignoreCase = ignoreCase;
13336
+ this._allowRelativePaths = allowRelativePaths;
13337
+ this._initCache();
13338
+ }
13339
+
13340
+ _initCache () {
13341
+ this._ignoreCache = Object.create(null);
13342
+ this._testCache = Object.create(null);
13343
+ }
13344
+
13345
+ _addPattern (pattern) {
13346
+ // #32
13347
+ if (pattern && pattern[KEY_IGNORE]) {
13348
+ this._rules = this._rules.concat(pattern._rules);
13349
+ this._added = true;
13350
+ return
13351
+ }
13352
+
13353
+ if (checkPattern(pattern)) {
13354
+ const rule = createRule(pattern, this._ignoreCase);
13355
+ this._added = true;
13356
+ this._rules.push(rule);
13357
+ }
13358
+ }
13359
+
13360
+ // @param {Array<string> | string | Ignore} pattern
13361
+ add (pattern) {
13362
+ this._added = false;
13363
+
13364
+ makeArray(
13365
+ isString(pattern)
13366
+ ? splitPattern(pattern)
13367
+ : pattern
13368
+ ).forEach(this._addPattern, this);
13369
+
13370
+ // Some rules have just added to the ignore,
13371
+ // making the behavior changed.
13372
+ if (this._added) {
13373
+ this._initCache();
13374
+ }
13375
+
13376
+ return this
13377
+ }
13378
+
13379
+ // legacy
13380
+ addPattern (pattern) {
13381
+ return this.add(pattern)
13382
+ }
13383
+
13384
+ // | ignored : unignored
13385
+ // negative | 0:0 | 0:1 | 1:0 | 1:1
13386
+ // -------- | ------- | ------- | ------- | --------
13387
+ // 0 | TEST | TEST | SKIP | X
13388
+ // 1 | TESTIF | SKIP | TEST | X
13389
+
13390
+ // - SKIP: always skip
13391
+ // - TEST: always test
13392
+ // - TESTIF: only test if checkUnignored
13393
+ // - X: that never happen
13394
+
13395
+ // @param {boolean} whether should check if the path is unignored,
13396
+ // setting `checkUnignored` to `false` could reduce additional
13397
+ // path matching.
13398
+
13399
+ // @returns {TestResult} true if a file is ignored
13400
+ _testOne (path, checkUnignored) {
13401
+ let ignored = false;
13402
+ let unignored = false;
13403
+
13404
+ this._rules.forEach(rule => {
13405
+ const {negative} = rule;
13406
+ if (
13407
+ unignored === negative && ignored !== unignored
13408
+ || negative && !ignored && !unignored && !checkUnignored
13409
+ ) {
13410
+ return
13411
+ }
13412
+
13413
+ const matched = rule.regex.test(path);
13414
+
13415
+ if (matched) {
13416
+ ignored = !negative;
13417
+ unignored = negative;
13418
+ }
13419
+ });
13420
+
13421
+ return {
13422
+ ignored,
13423
+ unignored
13424
+ }
13425
+ }
13426
+
13427
+ // @returns {TestResult}
13428
+ _test (originalPath, cache, checkUnignored, slices) {
13429
+ const path = originalPath
13430
+ // Supports nullable path
13431
+ && checkPath.convert(originalPath);
13432
+
13433
+ checkPath(
13434
+ path,
13435
+ originalPath,
13436
+ this._allowRelativePaths
13437
+ ? RETURN_FALSE
13438
+ : throwError
13439
+ );
13440
+
13441
+ return this._t(path, cache, checkUnignored, slices)
13442
+ }
13443
+
13444
+ _t (path, cache, checkUnignored, slices) {
13445
+ if (path in cache) {
13446
+ return cache[path]
13447
+ }
13448
+
13449
+ if (!slices) {
13450
+ // path/to/a.js
13451
+ // ['path', 'to', 'a.js']
13452
+ slices = path.split(SLASH);
13453
+ }
13454
+
13455
+ slices.pop();
13456
+
13457
+ // If the path has no parent directory, just test it
13458
+ if (!slices.length) {
13459
+ return cache[path] = this._testOne(path, checkUnignored)
13460
+ }
13461
+
13462
+ const parent = this._t(
13463
+ slices.join(SLASH) + SLASH,
13464
+ cache,
13465
+ checkUnignored,
13466
+ slices
13467
+ );
13468
+
13469
+ // If the path contains a parent directory, check the parent first
13470
+ return cache[path] = parent.ignored
13471
+ // > It is not possible to re-include a file if a parent directory of
13472
+ // > that file is excluded.
13473
+ ? parent
13474
+ : this._testOne(path, checkUnignored)
13475
+ }
13476
+
13477
+ ignores (path) {
13478
+ return this._test(path, this._ignoreCache, false).ignored
13479
+ }
13480
+
13481
+ createFilter () {
13482
+ return path => !this.ignores(path)
13483
+ }
13484
+
13485
+ filter (paths) {
13486
+ return makeArray(paths).filter(this.createFilter())
13487
+ }
13488
+
13489
+ // @returns {TestResult}
13490
+ test (path) {
13491
+ return this._test(path, this._testCache, true)
13492
+ }
13493
+ }
13487
13494
 
13488
- // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
13489
- // 'd:\\foo'
13490
- const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
13491
- checkPath.isNotRelative = path =>
13492
- REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
13493
- || isNotRelative(path);
13495
+ const factory = options => new Ignore(options);
13496
+
13497
+ const isPathValid = path =>
13498
+ checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
13499
+
13500
+ factory.isPathValid = isPathValid;
13501
+
13502
+ // Fixes typescript
13503
+ factory.default = factory;
13504
+
13505
+ ignore$1 = factory;
13506
+
13507
+ // Windows
13508
+ // --------------------------------------------------------------
13509
+ /* istanbul ignore if */
13510
+ if (
13511
+ // Detect `process` so that it can run in browsers.
13512
+ typeof process !== 'undefined'
13513
+ && (
13514
+ process.env && process.env.IGNORE_TEST_WIN32
13515
+ || process.platform === 'win32'
13516
+ )
13517
+ ) {
13518
+ /* eslint no-control-regex: "off" */
13519
+ const makePosix = str => /^\\\\\?\\/.test(str)
13520
+ || /["<>|\u0000-\u001F]+/u.test(str)
13521
+ ? str
13522
+ : str.replace(/\\/g, '/');
13523
+
13524
+ checkPath.convert = makePosix;
13525
+
13526
+ // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
13527
+ // 'd:\\foo'
13528
+ const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
13529
+ checkPath.isNotRelative = path =>
13530
+ REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
13531
+ || isNotRelative(path);
13532
+ }
13533
+ return ignore$1;
13494
13534
  }
13495
13535
 
13496
- var ignore$1 = /*@__PURE__*/getDefaultExportFromCjs(ignore);
13536
+ var ignoreExports = /*@__PURE__*/ requireIgnore();
13537
+ var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
13497
13538
 
13498
13539
  const entities = {
13499
13540
  ">": "&gt;",
@@ -13821,7 +13862,6 @@ exports.NestedError = NestedError;
13821
13862
  exports.NodeClosed = NodeClosed;
13822
13863
  exports.NodeType = NodeType;
13823
13864
  exports.Parser = Parser;
13824
- exports.Presets = Presets;
13825
13865
  exports.Reporter = Reporter;
13826
13866
  exports.ResolvedConfig = ResolvedConfig;
13827
13867
  exports.Rule = Rule;
@@ -13839,14 +13879,15 @@ exports.bugs = bugs;
13839
13879
  exports.classifyNodeText = classifyNodeText;
13840
13880
  exports.codeframe = codeframe;
13841
13881
  exports.compatibilityCheckImpl = compatibilityCheckImpl;
13842
- exports.deepmerge = deepmerge$1;
13882
+ exports.deepmerge = deepmerge;
13843
13883
  exports.defineConfig = defineConfig;
13844
13884
  exports.definePlugin = definePlugin;
13845
13885
  exports.ensureError = ensureError;
13846
13886
  exports.getFormatter = getFormatter;
13847
- exports.ignore = ignore$1;
13887
+ exports.ignore = ignore;
13848
13888
  exports.keywordPatternMatcher = keywordPatternMatcher;
13849
13889
  exports.name = name;
13890
+ exports.presets = presets;
13850
13891
  exports.ruleExists = ruleExists;
13851
13892
  exports.sliceLocation = sliceLocation;
13852
13893
  exports.staticResolver = staticResolver;