html-validate 8.24.0 → 8.24.2

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/es/core.js CHANGED
@@ -242,139 +242,149 @@ function getDefaultExportFromCjs (x) {
242
242
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
243
243
  }
244
244
 
245
- var isMergeableObject = function isMergeableObject(value) {
246
- return isNonNullObject(value)
247
- && !isSpecial(value)
248
- };
245
+ var cjs;
246
+ var hasRequiredCjs;
249
247
 
250
- function isNonNullObject(value) {
251
- return !!value && typeof value === 'object'
252
- }
248
+ function requireCjs () {
249
+ if (hasRequiredCjs) return cjs;
250
+ hasRequiredCjs = 1;
253
251
 
254
- function isSpecial(value) {
255
- var stringValue = Object.prototype.toString.call(value);
252
+ var isMergeableObject = function isMergeableObject(value) {
253
+ return isNonNullObject(value)
254
+ && !isSpecial(value)
255
+ };
256
256
 
257
- return stringValue === '[object RegExp]'
258
- || stringValue === '[object Date]'
259
- || isReactElement(value)
260
- }
257
+ function isNonNullObject(value) {
258
+ return !!value && typeof value === 'object'
259
+ }
261
260
 
262
- // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
263
- var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
264
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
261
+ function isSpecial(value) {
262
+ var stringValue = Object.prototype.toString.call(value);
265
263
 
266
- function isReactElement(value) {
267
- return value.$$typeof === REACT_ELEMENT_TYPE
268
- }
264
+ return stringValue === '[object RegExp]'
265
+ || stringValue === '[object Date]'
266
+ || isReactElement(value)
267
+ }
269
268
 
270
- function emptyTarget(val) {
271
- return Array.isArray(val) ? [] : {}
272
- }
269
+ // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
270
+ var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
271
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
273
272
 
274
- function cloneUnlessOtherwiseSpecified(value, options) {
275
- return (options.clone !== false && options.isMergeableObject(value))
276
- ? deepmerge(emptyTarget(value), value, options)
277
- : value
278
- }
273
+ function isReactElement(value) {
274
+ return value.$$typeof === REACT_ELEMENT_TYPE
275
+ }
279
276
 
280
- function defaultArrayMerge(target, source, options) {
281
- return target.concat(source).map(function(element) {
282
- return cloneUnlessOtherwiseSpecified(element, options)
283
- })
284
- }
277
+ function emptyTarget(val) {
278
+ return Array.isArray(val) ? [] : {}
279
+ }
285
280
 
286
- function getMergeFunction(key, options) {
287
- if (!options.customMerge) {
288
- return deepmerge
281
+ function cloneUnlessOtherwiseSpecified(value, options) {
282
+ return (options.clone !== false && options.isMergeableObject(value))
283
+ ? deepmerge(emptyTarget(value), value, options)
284
+ : value
289
285
  }
290
- var customMerge = options.customMerge(key);
291
- return typeof customMerge === 'function' ? customMerge : deepmerge
292
- }
293
286
 
294
- function getEnumerableOwnPropertySymbols(target) {
295
- return Object.getOwnPropertySymbols
296
- ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
297
- return Object.propertyIsEnumerable.call(target, symbol)
287
+ function defaultArrayMerge(target, source, options) {
288
+ return target.concat(source).map(function(element) {
289
+ return cloneUnlessOtherwiseSpecified(element, options)
298
290
  })
299
- : []
300
- }
291
+ }
301
292
 
302
- function getKeys(target) {
303
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
304
- }
293
+ function getMergeFunction(key, options) {
294
+ if (!options.customMerge) {
295
+ return deepmerge
296
+ }
297
+ var customMerge = options.customMerge(key);
298
+ return typeof customMerge === 'function' ? customMerge : deepmerge
299
+ }
305
300
 
306
- function propertyIsOnObject(object, property) {
307
- try {
308
- return property in object
309
- } catch(_) {
310
- return false
301
+ function getEnumerableOwnPropertySymbols(target) {
302
+ return Object.getOwnPropertySymbols
303
+ ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
304
+ return Object.propertyIsEnumerable.call(target, symbol)
305
+ })
306
+ : []
311
307
  }
312
- }
313
308
 
314
- // Protects from prototype poisoning and unexpected merging up the prototype chain.
315
- function propertyIsUnsafe(target, key) {
316
- return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
317
- && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
318
- && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
319
- }
309
+ function getKeys(target) {
310
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
311
+ }
320
312
 
321
- function mergeObject(target, source, options) {
322
- var destination = {};
323
- if (options.isMergeableObject(target)) {
324
- getKeys(target).forEach(function(key) {
325
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
326
- });
313
+ function propertyIsOnObject(object, property) {
314
+ try {
315
+ return property in object
316
+ } catch(_) {
317
+ return false
318
+ }
319
+ }
320
+
321
+ // Protects from prototype poisoning and unexpected merging up the prototype chain.
322
+ function propertyIsUnsafe(target, key) {
323
+ return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
324
+ && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
325
+ && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
327
326
  }
328
- getKeys(source).forEach(function(key) {
329
- if (propertyIsUnsafe(target, key)) {
330
- return
327
+
328
+ function mergeObject(target, source, options) {
329
+ var destination = {};
330
+ if (options.isMergeableObject(target)) {
331
+ getKeys(target).forEach(function(key) {
332
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
333
+ });
331
334
  }
335
+ getKeys(source).forEach(function(key) {
336
+ if (propertyIsUnsafe(target, key)) {
337
+ return
338
+ }
332
339
 
333
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
334
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
340
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
341
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
342
+ } else {
343
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
344
+ }
345
+ });
346
+ return destination
347
+ }
348
+
349
+ function deepmerge(target, source, options) {
350
+ options = options || {};
351
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
352
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
353
+ // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
354
+ // implementations can use it. The caller may not replace it.
355
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
356
+
357
+ var sourceIsArray = Array.isArray(source);
358
+ var targetIsArray = Array.isArray(target);
359
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
360
+
361
+ if (!sourceAndTargetTypesMatch) {
362
+ return cloneUnlessOtherwiseSpecified(source, options)
363
+ } else if (sourceIsArray) {
364
+ return options.arrayMerge(target, source, options)
335
365
  } else {
336
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
366
+ return mergeObject(target, source, options)
337
367
  }
338
- });
339
- return destination
340
- }
341
-
342
- function deepmerge(target, source, options) {
343
- options = options || {};
344
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
345
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
346
- // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
347
- // implementations can use it. The caller may not replace it.
348
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
349
-
350
- var sourceIsArray = Array.isArray(source);
351
- var targetIsArray = Array.isArray(target);
352
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
353
-
354
- if (!sourceAndTargetTypesMatch) {
355
- return cloneUnlessOtherwiseSpecified(source, options)
356
- } else if (sourceIsArray) {
357
- return options.arrayMerge(target, source, options)
358
- } else {
359
- return mergeObject(target, source, options)
360
368
  }
361
- }
362
369
 
363
- deepmerge.all = function deepmergeAll(array, options) {
364
- if (!Array.isArray(array)) {
365
- throw new Error('first argument should be an array')
366
- }
370
+ deepmerge.all = function deepmergeAll(array, options) {
371
+ if (!Array.isArray(array)) {
372
+ throw new Error('first argument should be an array')
373
+ }
367
374
 
368
- return array.reduce(function(prev, next) {
369
- return deepmerge(prev, next, options)
370
- }, {})
371
- };
375
+ return array.reduce(function(prev, next) {
376
+ return deepmerge(prev, next, options)
377
+ }, {})
378
+ };
372
379
 
373
- var deepmerge_1 = deepmerge;
380
+ var deepmerge_1 = deepmerge;
374
381
 
375
- var cjs = deepmerge_1;
382
+ cjs = deepmerge_1;
383
+ return cjs;
384
+ }
376
385
 
377
- var deepmerge$1 = /*@__PURE__*/getDefaultExportFromCjs(cjs);
386
+ var cjsExports = /*@__PURE__*/ requireCjs();
387
+ var deepmerge = /*@__PURE__*/getDefaultExportFromCjs(cjsExports);
378
388
 
379
389
  function stringify(value) {
380
390
  if (typeof value === "string") {
@@ -1207,7 +1217,7 @@ class MetaTable {
1207
1217
  */
1208
1218
  extendValidationSchema(patch) {
1209
1219
  if (patch.properties) {
1210
- this.schema = deepmerge$1(this.schema, {
1220
+ this.schema = deepmerge(this.schema, {
1211
1221
  patternProperties: {
1212
1222
  "^[^$].*$": {
1213
1223
  properties: patch.properties
@@ -1216,7 +1226,7 @@ class MetaTable {
1216
1226
  });
1217
1227
  }
1218
1228
  if (patch.definitions) {
1219
- this.schema = deepmerge$1(this.schema, {
1229
+ this.schema = deepmerge(this.schema, {
1220
1230
  definitions: patch.definitions
1221
1231
  });
1222
1232
  }
@@ -1354,7 +1364,7 @@ class MetaTable {
1354
1364
  }
1355
1365
  }
1356
1366
  mergeElement(a, b) {
1357
- const merged = deepmerge$1(a, b, { arrayMerge: overwriteMerge$1 });
1367
+ const merged = deepmerge(a, b, { arrayMerge: overwriteMerge$1 });
1358
1368
  const filteredAttrs = Object.entries(
1359
1369
  merged.attributes
1360
1370
  ).filter(([, attr]) => {
@@ -1970,7 +1980,7 @@ const table = {
1970
1980
  "nth-child": nthChild,
1971
1981
  scope
1972
1982
  };
1973
- function factory$1(name, context) {
1983
+ function factory(name, context) {
1974
1984
  const fn = table[name];
1975
1985
  if (fn) {
1976
1986
  return fn.bind(context);
@@ -2069,7 +2079,7 @@ function isQuotationMark(ch) {
2069
2079
  function isPseudoElement(ch, buffer) {
2070
2080
  return ch === ":" && buffer === ":";
2071
2081
  }
2072
- function* splitPattern$1(pattern) {
2082
+ function* splitPattern(pattern) {
2073
2083
  if (pattern === "") {
2074
2084
  return;
2075
2085
  }
@@ -2163,7 +2173,7 @@ class PseudoClassMatcher extends Matcher {
2163
2173
  this.args = args;
2164
2174
  }
2165
2175
  match(node, context) {
2166
- const fn = factory$1(this.name, context);
2176
+ const fn = factory(this.name, context);
2167
2177
  return fn(node, this.args);
2168
2178
  }
2169
2179
  }
@@ -2177,7 +2187,7 @@ class Pattern {
2177
2187
  this.selector = pattern;
2178
2188
  this.combinator = parseCombinator(match.shift(), pattern);
2179
2189
  this.tagName = match.shift() || "*";
2180
- this.pattern = Array.from(splitPattern$1(match[0]), (it) => this.createMatcher(it));
2190
+ this.pattern = Array.from(splitPattern(match[0]), (it) => this.createMatcher(it));
2181
2191
  }
2182
2192
  match(node, context) {
2183
2193
  return node.is(this.tagName) && this.pattern.every((cur) => cur.match(node, context));
@@ -4504,6 +4514,9 @@ class AttrQuotes extends Rule {
4504
4514
  }
4505
4515
  setup() {
4506
4516
  this.on("attr", (event) => {
4517
+ if (event.originalAttribute) {
4518
+ return;
4519
+ }
4507
4520
  if (event.value === null) {
4508
4521
  return;
4509
4522
  }
@@ -10829,9 +10842,9 @@ function overwriteMerge(a, b) {
10829
10842
  return b;
10830
10843
  }
10831
10844
  function mergeInternal(base, rhs) {
10832
- const dst = deepmerge$1(base, { ...rhs, rules: {} });
10845
+ const dst = deepmerge(base, { ...rhs, rules: {} });
10833
10846
  if (rhs.rules) {
10834
- dst.rules = deepmerge$1(dst.rules, rhs.rules, { arrayMerge: overwriteMerge });
10847
+ dst.rules = deepmerge(dst.rules, rhs.rules, { arrayMerge: overwriteMerge });
10835
10848
  }
10836
10849
  const root = Boolean(base.root) || Boolean(rhs.root);
10837
10850
  if (root) {
@@ -12858,651 +12871,660 @@ class HtmlValidate {
12858
12871
  }
12859
12872
 
12860
12873
  const name = "html-validate";
12861
- const version = "8.24.0";
12874
+ const version = "8.24.2";
12862
12875
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12863
12876
 
12864
12877
  function definePlugin(plugin) {
12865
12878
  return plugin;
12866
12879
  }
12867
12880
 
12868
- // A simple implementation of make-array
12869
- function makeArray (subject) {
12870
- return Array.isArray(subject)
12871
- ? subject
12872
- : [subject]
12873
- }
12874
-
12875
- const EMPTY = '';
12876
- const SPACE = ' ';
12877
- const ESCAPE = '\\';
12878
- const REGEX_TEST_BLANK_LINE = /^\s+$/;
12879
- const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
12880
- const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
12881
- const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
12882
- const REGEX_SPLITALL_CRLF = /\r?\n/g;
12883
- // /foo,
12884
- // ./foo,
12885
- // ../foo,
12886
- // .
12887
- // ..
12888
- const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
12889
-
12890
- const SLASH = '/';
12891
-
12892
- // Do not use ternary expression here, since "istanbul ignore next" is buggy
12893
- let TMP_KEY_IGNORE = 'node-ignore';
12894
- /* istanbul ignore else */
12895
- if (typeof Symbol !== 'undefined') {
12896
- TMP_KEY_IGNORE = Symbol.for('node-ignore');
12897
- }
12898
- const KEY_IGNORE = TMP_KEY_IGNORE;
12899
-
12900
- const define = (object, key, value) =>
12901
- Object.defineProperty(object, key, {value});
12902
-
12903
- const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
12904
-
12905
- const RETURN_FALSE = () => false;
12906
-
12907
- // Sanitize the range of a regular expression
12908
- // The cases are complicated, see test cases for details
12909
- const sanitizeRange = range => range.replace(
12910
- REGEX_REGEXP_RANGE,
12911
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
12912
- ? match
12913
- // Invalid range (out of order) which is ok for gitignore rules but
12914
- // fatal for JavaScript regular expression, so eliminate it.
12915
- : EMPTY
12916
- );
12917
-
12918
- // See fixtures #59
12919
- const cleanRangeBackSlash = slashes => {
12920
- const {length} = slashes;
12921
- return slashes.slice(0, length - length % 2)
12922
- };
12923
-
12924
- // > If the pattern ends with a slash,
12925
- // > it is removed for the purpose of the following description,
12926
- // > but it would only find a match with a directory.
12927
- // > In other words, foo/ will match a directory foo and paths underneath it,
12928
- // > but will not match a regular file or a symbolic link foo
12929
- // > (this is consistent with the way how pathspec works in general in Git).
12930
- // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
12931
- // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
12932
- // you could use option `mark: true` with `glob`
12933
-
12934
- // '`foo/`' should not continue with the '`..`'
12935
- const REPLACERS = [
12936
-
12937
- [
12938
- // remove BOM
12939
- // TODO:
12940
- // Other similar zero-width characters?
12941
- /^\uFEFF/,
12942
- () => EMPTY
12943
- ],
12944
-
12945
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
12946
- [
12947
- // (a\ ) -> (a )
12948
- // (a ) -> (a)
12949
- // (a ) -> (a)
12950
- // (a \ ) -> (a )
12951
- /((?:\\\\)*?)(\\?\s+)$/,
12952
- (_, m1, m2) => m1 + (
12953
- m2.indexOf('\\') === 0
12954
- ? SPACE
12955
- : EMPTY
12956
- )
12957
- ],
12958
-
12959
- // replace (\ ) with ' '
12960
- // (\ ) -> ' '
12961
- // (\\ ) -> '\\ '
12962
- // (\\\ ) -> '\\ '
12963
- [
12964
- /(\\+?)\s/g,
12965
- (_, m1) => {
12966
- const {length} = m1;
12967
- return m1.slice(0, length - length % 2) + SPACE
12968
- }
12969
- ],
12970
-
12971
- // Escape metacharacters
12972
- // which is written down by users but means special for regular expressions.
12973
-
12974
- // > There are 12 characters with special meanings:
12975
- // > - the backslash \,
12976
- // > - the caret ^,
12977
- // > - the dollar sign $,
12978
- // > - the period or dot .,
12979
- // > - the vertical bar or pipe symbol |,
12980
- // > - the question mark ?,
12981
- // > - the asterisk or star *,
12982
- // > - the plus sign +,
12983
- // > - the opening parenthesis (,
12984
- // > - the closing parenthesis ),
12985
- // > - and the opening square bracket [,
12986
- // > - the opening curly brace {,
12987
- // > These special characters are often called "metacharacters".
12988
- [
12989
- /[\\$.|*+(){^]/g,
12990
- match => `\\${match}`
12991
- ],
12992
-
12993
- [
12994
- // > a question mark (?) matches a single character
12995
- /(?!\\)\?/g,
12996
- () => '[^/]'
12997
- ],
12998
-
12999
- // leading slash
13000
- [
13001
-
13002
- // > A leading slash matches the beginning of the pathname.
13003
- // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
13004
- // A leading slash matches the beginning of the pathname
13005
- /^\//,
13006
- () => '^'
13007
- ],
13008
-
13009
- // replace special metacharacter slash after the leading slash
13010
- [
13011
- /\//g,
13012
- () => '\\/'
13013
- ],
13014
-
13015
- [
13016
- // > A leading "**" followed by a slash means match in all directories.
13017
- // > For example, "**/foo" matches file or directory "foo" anywhere,
13018
- // > the same as pattern "foo".
13019
- // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
13020
- // > under directory "foo".
13021
- // Notice that the '*'s have been replaced as '\\*'
13022
- /^\^*\\\*\\\*\\\//,
13023
-
13024
- // '**/foo' <-> 'foo'
13025
- () => '^(?:.*\\/)?'
13026
- ],
13027
-
13028
- // starting
13029
- [
13030
- // there will be no leading '/'
13031
- // (which has been replaced by section "leading slash")
13032
- // If starts with '**', adding a '^' to the regular expression also works
13033
- /^(?=[^^])/,
13034
- function startingReplacer () {
13035
- // If has a slash `/` at the beginning or middle
13036
- return !/\/(?!$)/.test(this)
13037
- // > Prior to 2.22.1
13038
- // > If the pattern does not contain a slash /,
13039
- // > Git treats it as a shell glob pattern
13040
- // Actually, if there is only a trailing slash,
13041
- // git also treats it as a shell glob pattern
13042
-
13043
- // After 2.22.1 (compatible but clearer)
13044
- // > If there is a separator at the beginning or middle (or both)
13045
- // > of the pattern, then the pattern is relative to the directory
13046
- // > level of the particular .gitignore file itself.
13047
- // > Otherwise the pattern may also match at any level below
13048
- // > the .gitignore level.
13049
- ? '(?:^|\\/)'
13050
-
13051
- // > Otherwise, Git treats the pattern as a shell glob suitable for
13052
- // > consumption by fnmatch(3)
13053
- : '^'
13054
- }
13055
- ],
13056
-
13057
- // two globstars
13058
- [
13059
- // Use lookahead assertions so that we could match more than one `'/**'`
13060
- /\\\/\\\*\\\*(?=\\\/|$)/g,
13061
-
13062
- // Zero, one or several directories
13063
- // should not use '*', or it will be replaced by the next replacer
13064
-
13065
- // Check if it is not the last `'/**'`
13066
- (_, index, str) => index + 6 < str.length
13067
-
13068
- // case: /**/
13069
- // > A slash followed by two consecutive asterisks then a slash matches
13070
- // > zero or more directories.
13071
- // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
13072
- // '/**/'
13073
- ? '(?:\\/[^\\/]+)*'
13074
-
13075
- // case: /**
13076
- // > A trailing `"/**"` matches everything inside.
13077
-
13078
- // #21: everything inside but it should not include the current folder
13079
- : '\\/.+'
13080
- ],
13081
-
13082
- // normal intermediate wildcards
13083
- [
13084
- // Never replace escaped '*'
13085
- // ignore rule '\*' will match the path '*'
13086
-
13087
- // 'abc.*/' -> go
13088
- // 'abc.*' -> skip this rule,
13089
- // coz trailing single wildcard will be handed by [trailing wildcard]
13090
- /(^|[^\\]+)(\\\*)+(?=.+)/g,
13091
-
13092
- // '*.js' matches '.js'
13093
- // '*.js' doesn't match 'abc'
13094
- (_, p1, p2) => {
13095
- // 1.
13096
- // > An asterisk "*" matches anything except a slash.
13097
- // 2.
13098
- // > Other consecutive asterisks are considered regular asterisks
13099
- // > and will match according to the previous rules.
13100
- const unescaped = p2.replace(/\\\*/g, '[^\\/]*');
13101
- return p1 + unescaped
13102
- }
13103
- ],
13104
-
13105
- [
13106
- // unescape, revert step 3 except for back slash
13107
- // For example, if a user escape a '\\*',
13108
- // after step 3, the result will be '\\\\\\*'
13109
- /\\\\\\(?=[$.|*+(){^])/g,
13110
- () => ESCAPE
13111
- ],
13112
-
13113
- [
13114
- // '\\\\' -> '\\'
13115
- /\\\\/g,
13116
- () => ESCAPE
13117
- ],
13118
-
13119
- [
13120
- // > The range notation, e.g. [a-zA-Z],
13121
- // > can be used to match one of the characters in a range.
13122
-
13123
- // `\` is escaped by step 3
13124
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
13125
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
13126
- // '\\[bar]' -> '\\\\[bar\\]'
13127
- ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
13128
- : close === ']'
13129
- ? endEscape.length % 2 === 0
13130
- // A normal case, and it is a range notation
13131
- // '[bar]'
13132
- // '[bar\\\\]'
13133
- ? `[${sanitizeRange(range)}${endEscape}]`
13134
- // Invalid range notaton
13135
- // '[bar\\]' -> '[bar\\\\]'
13136
- : '[]'
13137
- : '[]'
13138
- ],
13139
-
13140
- // ending
13141
- [
13142
- // 'js' will not match 'js.'
13143
- // 'ab' will not match 'abc'
13144
- /(?:[^*])$/,
13145
-
13146
- // WTF!
13147
- // https://git-scm.com/docs/gitignore
13148
- // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
13149
- // which re-fixes #24, #38
13150
-
13151
- // > If there is a separator at the end of the pattern then the pattern
13152
- // > will only match directories, otherwise the pattern can match both
13153
- // > files and directories.
13154
-
13155
- // 'js*' will not match 'a.js'
13156
- // 'js/' will not match 'a.js'
13157
- // 'js' will match 'a.js' and 'a.js/'
13158
- match => /\/$/.test(match)
13159
- // foo/ will not match 'foo'
13160
- ? `${match}$`
13161
- // foo matches 'foo' and 'foo/'
13162
- : `${match}(?=$|\\/$)`
13163
- ],
13164
-
13165
- // trailing wildcard
13166
- [
13167
- /(\^|\\\/)?\\\*$/,
13168
- (_, p1) => {
13169
- const prefix = p1
13170
- // '\^':
13171
- // '/*' does not match EMPTY
13172
- // '/*' does not match everything
13173
-
13174
- // '\\\/':
13175
- // 'abc/*' does not match 'abc/'
13176
- ? `${p1}[^/]+`
13177
-
13178
- // 'a*' matches 'a'
13179
- // 'a*' matches 'aa'
13180
- : '[^/]*';
13181
-
13182
- return `${prefix}(?=$|\\/$)`
13183
- }
13184
- ],
13185
- ];
13186
-
13187
- // A simple cache, because an ignore rule only has only one certain meaning
13188
- const regexCache = Object.create(null);
13189
-
13190
- // @param {pattern}
13191
- const makeRegex = (pattern, ignoreCase) => {
13192
- let source = regexCache[pattern];
13193
-
13194
- if (!source) {
13195
- source = REPLACERS.reduce(
13196
- (prev, [matcher, replacer]) =>
13197
- prev.replace(matcher, replacer.bind(pattern)),
13198
- pattern
13199
- );
13200
- regexCache[pattern] = source;
13201
- }
13202
-
13203
- return ignoreCase
13204
- ? new RegExp(source, 'i')
13205
- : new RegExp(source)
13206
- };
13207
-
13208
- const isString = subject => typeof subject === 'string';
13209
-
13210
- // > A blank line matches no files, so it can serve as a separator for readability.
13211
- const checkPattern = pattern => pattern
13212
- && isString(pattern)
13213
- && !REGEX_TEST_BLANK_LINE.test(pattern)
13214
- && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
13215
-
13216
- // > A line starting with # serves as a comment.
13217
- && pattern.indexOf('#') !== 0;
13218
-
13219
- const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
13220
-
13221
- class IgnoreRule {
13222
- constructor (
13223
- origin,
13224
- pattern,
13225
- negative,
13226
- regex
13227
- ) {
13228
- this.origin = origin;
13229
- this.pattern = pattern;
13230
- this.negative = negative;
13231
- this.regex = regex;
13232
- }
13233
- }
13234
-
13235
- const createRule = (pattern, ignoreCase) => {
13236
- const origin = pattern;
13237
- let negative = false;
13238
-
13239
- // > An optional prefix "!" which negates the pattern;
13240
- if (pattern.indexOf('!') === 0) {
13241
- negative = true;
13242
- pattern = pattern.substr(1);
13243
- }
13244
-
13245
- pattern = pattern
13246
- // > Put a backslash ("\") in front of the first "!" for patterns that
13247
- // > begin with a literal "!", for example, `"\!important!.txt"`.
13248
- .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
13249
- // > Put a backslash ("\") in front of the first hash for patterns that
13250
- // > begin with a hash.
13251
- .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
13252
-
13253
- const regex = makeRegex(pattern, ignoreCase);
13254
-
13255
- return new IgnoreRule(
13256
- origin,
13257
- pattern,
13258
- negative,
13259
- regex
13260
- )
13261
- };
13262
-
13263
- const throwError = (message, Ctor) => {
13264
- throw new Ctor(message)
13265
- };
13266
-
13267
- const checkPath = (path, originalPath, doThrow) => {
13268
- if (!isString(path)) {
13269
- return doThrow(
13270
- `path must be a string, but got \`${originalPath}\``,
13271
- TypeError
13272
- )
13273
- }
13274
-
13275
- // We don't know if we should ignore EMPTY, so throw
13276
- if (!path) {
13277
- return doThrow(`path must not be empty`, TypeError)
13278
- }
13279
-
13280
- // Check if it is a relative path
13281
- if (checkPath.isNotRelative(path)) {
13282
- const r = '`path.relative()`d';
13283
- return doThrow(
13284
- `path should be a ${r} string, but got "${originalPath}"`,
13285
- RangeError
13286
- )
13287
- }
13288
-
13289
- return true
13290
- };
13291
-
13292
- const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
13293
-
13294
- checkPath.isNotRelative = isNotRelative;
13295
- checkPath.convert = p => p;
13296
-
13297
- class Ignore {
13298
- constructor ({
13299
- ignorecase = true,
13300
- ignoreCase = ignorecase,
13301
- allowRelativePaths = false
13302
- } = {}) {
13303
- define(this, KEY_IGNORE, true);
13304
-
13305
- this._rules = [];
13306
- this._ignoreCase = ignoreCase;
13307
- this._allowRelativePaths = allowRelativePaths;
13308
- this._initCache();
13309
- }
13310
-
13311
- _initCache () {
13312
- this._ignoreCache = Object.create(null);
13313
- this._testCache = Object.create(null);
13314
- }
13315
-
13316
- _addPattern (pattern) {
13317
- // #32
13318
- if (pattern && pattern[KEY_IGNORE]) {
13319
- this._rules = this._rules.concat(pattern._rules);
13320
- this._added = true;
13321
- return
13322
- }
13323
-
13324
- if (checkPattern(pattern)) {
13325
- const rule = createRule(pattern, this._ignoreCase);
13326
- this._added = true;
13327
- this._rules.push(rule);
13328
- }
13329
- }
13330
-
13331
- // @param {Array<string> | string | Ignore} pattern
13332
- add (pattern) {
13333
- this._added = false;
13334
-
13335
- makeArray(
13336
- isString(pattern)
13337
- ? splitPattern(pattern)
13338
- : pattern
13339
- ).forEach(this._addPattern, this);
13340
-
13341
- // Some rules have just added to the ignore,
13342
- // making the behavior changed.
13343
- if (this._added) {
13344
- this._initCache();
13345
- }
13346
-
13347
- return this
13348
- }
12881
+ var ignore$1;
12882
+ var hasRequiredIgnore;
13349
12883
 
13350
- // legacy
13351
- addPattern (pattern) {
13352
- return this.add(pattern)
13353
- }
13354
-
13355
- // | ignored : unignored
13356
- // negative | 0:0 | 0:1 | 1:0 | 1:1
13357
- // -------- | ------- | ------- | ------- | --------
13358
- // 0 | TEST | TEST | SKIP | X
13359
- // 1 | TESTIF | SKIP | TEST | X
13360
-
13361
- // - SKIP: always skip
13362
- // - TEST: always test
13363
- // - TESTIF: only test if checkUnignored
13364
- // - X: that never happen
13365
-
13366
- // @param {boolean} whether should check if the path is unignored,
13367
- // setting `checkUnignored` to `false` could reduce additional
13368
- // path matching.
13369
-
13370
- // @returns {TestResult} true if a file is ignored
13371
- _testOne (path, checkUnignored) {
13372
- let ignored = false;
13373
- let unignored = false;
13374
-
13375
- this._rules.forEach(rule => {
13376
- const {negative} = rule;
13377
- if (
13378
- unignored === negative && ignored !== unignored
13379
- || negative && !ignored && !unignored && !checkUnignored
13380
- ) {
13381
- return
13382
- }
13383
-
13384
- const matched = rule.regex.test(path);
13385
-
13386
- if (matched) {
13387
- ignored = !negative;
13388
- unignored = negative;
13389
- }
13390
- });
13391
-
13392
- return {
13393
- ignored,
13394
- unignored
13395
- }
13396
- }
13397
-
13398
- // @returns {TestResult}
13399
- _test (originalPath, cache, checkUnignored, slices) {
13400
- const path = originalPath
13401
- // Supports nullable path
13402
- && checkPath.convert(originalPath);
13403
-
13404
- checkPath(
13405
- path,
13406
- originalPath,
13407
- this._allowRelativePaths
13408
- ? RETURN_FALSE
13409
- : throwError
13410
- );
13411
-
13412
- return this._t(path, cache, checkUnignored, slices)
13413
- }
13414
-
13415
- _t (path, cache, checkUnignored, slices) {
13416
- if (path in cache) {
13417
- return cache[path]
13418
- }
13419
-
13420
- if (!slices) {
13421
- // path/to/a.js
13422
- // ['path', 'to', 'a.js']
13423
- slices = path.split(SLASH);
13424
- }
13425
-
13426
- slices.pop();
13427
-
13428
- // If the path has no parent directory, just test it
13429
- if (!slices.length) {
13430
- return cache[path] = this._testOne(path, checkUnignored)
13431
- }
13432
-
13433
- const parent = this._t(
13434
- slices.join(SLASH) + SLASH,
13435
- cache,
13436
- checkUnignored,
13437
- slices
13438
- );
13439
-
13440
- // If the path contains a parent directory, check the parent first
13441
- return cache[path] = parent.ignored
13442
- // > It is not possible to re-include a file if a parent directory of
13443
- // > that file is excluded.
13444
- ? parent
13445
- : this._testOne(path, checkUnignored)
13446
- }
13447
-
13448
- ignores (path) {
13449
- return this._test(path, this._ignoreCache, false).ignored
13450
- }
13451
-
13452
- createFilter () {
13453
- return path => !this.ignores(path)
13454
- }
13455
-
13456
- filter (paths) {
13457
- return makeArray(paths).filter(this.createFilter())
13458
- }
13459
-
13460
- // @returns {TestResult}
13461
- test (path) {
13462
- return this._test(path, this._testCache, true)
13463
- }
13464
- }
13465
-
13466
- const factory = options => new Ignore(options);
13467
-
13468
- const isPathValid = path =>
13469
- checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
13470
-
13471
- factory.isPathValid = isPathValid;
13472
-
13473
- // Fixes typescript
13474
- factory.default = factory;
13475
-
13476
- var ignore = factory;
12884
+ function requireIgnore () {
12885
+ if (hasRequiredIgnore) return ignore$1;
12886
+ hasRequiredIgnore = 1;
12887
+ // A simple implementation of make-array
12888
+ function makeArray (subject) {
12889
+ return Array.isArray(subject)
12890
+ ? subject
12891
+ : [subject]
12892
+ }
13477
12893
 
13478
- // Windows
13479
- // --------------------------------------------------------------
13480
- /* istanbul ignore if */
13481
- if (
13482
- // Detect `process` so that it can run in browsers.
13483
- typeof process !== 'undefined'
13484
- && (
13485
- process.env && process.env.IGNORE_TEST_WIN32
13486
- || process.platform === 'win32'
13487
- )
13488
- ) {
13489
- /* eslint no-control-regex: "off" */
13490
- const makePosix = str => /^\\\\\?\\/.test(str)
13491
- || /["<>|\u0000-\u001F]+/u.test(str)
13492
- ? str
13493
- : str.replace(/\\/g, '/');
12894
+ const EMPTY = '';
12895
+ const SPACE = ' ';
12896
+ const ESCAPE = '\\';
12897
+ const REGEX_TEST_BLANK_LINE = /^\s+$/;
12898
+ const REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
12899
+ const REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
12900
+ const REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
12901
+ const REGEX_SPLITALL_CRLF = /\r?\n/g;
12902
+ // /foo,
12903
+ // ./foo,
12904
+ // ../foo,
12905
+ // .
12906
+ // ..
12907
+ const REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
12908
+
12909
+ const SLASH = '/';
12910
+
12911
+ // Do not use ternary expression here, since "istanbul ignore next" is buggy
12912
+ let TMP_KEY_IGNORE = 'node-ignore';
12913
+ /* istanbul ignore else */
12914
+ if (typeof Symbol !== 'undefined') {
12915
+ TMP_KEY_IGNORE = Symbol.for('node-ignore');
12916
+ }
12917
+ const KEY_IGNORE = TMP_KEY_IGNORE;
12918
+
12919
+ const define = (object, key, value) =>
12920
+ Object.defineProperty(object, key, {value});
12921
+
12922
+ const REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
12923
+
12924
+ const RETURN_FALSE = () => false;
12925
+
12926
+ // Sanitize the range of a regular expression
12927
+ // The cases are complicated, see test cases for details
12928
+ const sanitizeRange = range => range.replace(
12929
+ REGEX_REGEXP_RANGE,
12930
+ (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0)
12931
+ ? match
12932
+ // Invalid range (out of order) which is ok for gitignore rules but
12933
+ // fatal for JavaScript regular expression, so eliminate it.
12934
+ : EMPTY
12935
+ );
12936
+
12937
+ // See fixtures #59
12938
+ const cleanRangeBackSlash = slashes => {
12939
+ const {length} = slashes;
12940
+ return slashes.slice(0, length - length % 2)
12941
+ };
12942
+
12943
+ // > If the pattern ends with a slash,
12944
+ // > it is removed for the purpose of the following description,
12945
+ // > but it would only find a match with a directory.
12946
+ // > In other words, foo/ will match a directory foo and paths underneath it,
12947
+ // > but will not match a regular file or a symbolic link foo
12948
+ // > (this is consistent with the way how pathspec works in general in Git).
12949
+ // '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
12950
+ // -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
12951
+ // you could use option `mark: true` with `glob`
12952
+
12953
+ // '`foo/`' should not continue with the '`..`'
12954
+ const REPLACERS = [
12955
+
12956
+ [
12957
+ // remove BOM
12958
+ // TODO:
12959
+ // Other similar zero-width characters?
12960
+ /^\uFEFF/,
12961
+ () => EMPTY
12962
+ ],
12963
+
12964
+ // > Trailing spaces are ignored unless they are quoted with backslash ("\")
12965
+ [
12966
+ // (a\ ) -> (a )
12967
+ // (a ) -> (a)
12968
+ // (a ) -> (a)
12969
+ // (a \ ) -> (a )
12970
+ /((?:\\\\)*?)(\\?\s+)$/,
12971
+ (_, m1, m2) => m1 + (
12972
+ m2.indexOf('\\') === 0
12973
+ ? SPACE
12974
+ : EMPTY
12975
+ )
12976
+ ],
12977
+
12978
+ // replace (\ ) with ' '
12979
+ // (\ ) -> ' '
12980
+ // (\\ ) -> '\\ '
12981
+ // (\\\ ) -> '\\ '
12982
+ [
12983
+ /(\\+?)\s/g,
12984
+ (_, m1) => {
12985
+ const {length} = m1;
12986
+ return m1.slice(0, length - length % 2) + SPACE
12987
+ }
12988
+ ],
12989
+
12990
+ // Escape metacharacters
12991
+ // which is written down by users but means special for regular expressions.
12992
+
12993
+ // > There are 12 characters with special meanings:
12994
+ // > - the backslash \,
12995
+ // > - the caret ^,
12996
+ // > - the dollar sign $,
12997
+ // > - the period or dot .,
12998
+ // > - the vertical bar or pipe symbol |,
12999
+ // > - the question mark ?,
13000
+ // > - the asterisk or star *,
13001
+ // > - the plus sign +,
13002
+ // > - the opening parenthesis (,
13003
+ // > - the closing parenthesis ),
13004
+ // > - and the opening square bracket [,
13005
+ // > - the opening curly brace {,
13006
+ // > These special characters are often called "metacharacters".
13007
+ [
13008
+ /[\\$.|*+(){^]/g,
13009
+ match => `\\${match}`
13010
+ ],
13011
+
13012
+ [
13013
+ // > a question mark (?) matches a single character
13014
+ /(?!\\)\?/g,
13015
+ () => '[^/]'
13016
+ ],
13017
+
13018
+ // leading slash
13019
+ [
13020
+
13021
+ // > A leading slash matches the beginning of the pathname.
13022
+ // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
13023
+ // A leading slash matches the beginning of the pathname
13024
+ /^\//,
13025
+ () => '^'
13026
+ ],
13027
+
13028
+ // replace special metacharacter slash after the leading slash
13029
+ [
13030
+ /\//g,
13031
+ () => '\\/'
13032
+ ],
13033
+
13034
+ [
13035
+ // > A leading "**" followed by a slash means match in all directories.
13036
+ // > For example, "**/foo" matches file or directory "foo" anywhere,
13037
+ // > the same as pattern "foo".
13038
+ // > "**/foo/bar" matches file or directory "bar" anywhere that is directly
13039
+ // > under directory "foo".
13040
+ // Notice that the '*'s have been replaced as '\\*'
13041
+ /^\^*\\\*\\\*\\\//,
13042
+
13043
+ // '**/foo' <-> 'foo'
13044
+ () => '^(?:.*\\/)?'
13045
+ ],
13046
+
13047
+ // starting
13048
+ [
13049
+ // there will be no leading '/'
13050
+ // (which has been replaced by section "leading slash")
13051
+ // If starts with '**', adding a '^' to the regular expression also works
13052
+ /^(?=[^^])/,
13053
+ function startingReplacer () {
13054
+ // If has a slash `/` at the beginning or middle
13055
+ return !/\/(?!$)/.test(this)
13056
+ // > Prior to 2.22.1
13057
+ // > If the pattern does not contain a slash /,
13058
+ // > Git treats it as a shell glob pattern
13059
+ // Actually, if there is only a trailing slash,
13060
+ // git also treats it as a shell glob pattern
13061
+
13062
+ // After 2.22.1 (compatible but clearer)
13063
+ // > If there is a separator at the beginning or middle (or both)
13064
+ // > of the pattern, then the pattern is relative to the directory
13065
+ // > level of the particular .gitignore file itself.
13066
+ // > Otherwise the pattern may also match at any level below
13067
+ // > the .gitignore level.
13068
+ ? '(?:^|\\/)'
13069
+
13070
+ // > Otherwise, Git treats the pattern as a shell glob suitable for
13071
+ // > consumption by fnmatch(3)
13072
+ : '^'
13073
+ }
13074
+ ],
13075
+
13076
+ // two globstars
13077
+ [
13078
+ // Use lookahead assertions so that we could match more than one `'/**'`
13079
+ /\\\/\\\*\\\*(?=\\\/|$)/g,
13080
+
13081
+ // Zero, one or several directories
13082
+ // should not use '*', or it will be replaced by the next replacer
13083
+
13084
+ // Check if it is not the last `'/**'`
13085
+ (_, index, str) => index + 6 < str.length
13086
+
13087
+ // case: /**/
13088
+ // > A slash followed by two consecutive asterisks then a slash matches
13089
+ // > zero or more directories.
13090
+ // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
13091
+ // '/**/'
13092
+ ? '(?:\\/[^\\/]+)*'
13093
+
13094
+ // case: /**
13095
+ // > A trailing `"/**"` matches everything inside.
13096
+
13097
+ // #21: everything inside but it should not include the current folder
13098
+ : '\\/.+'
13099
+ ],
13100
+
13101
+ // normal intermediate wildcards
13102
+ [
13103
+ // Never replace escaped '*'
13104
+ // ignore rule '\*' will match the path '*'
13105
+
13106
+ // 'abc.*/' -> go
13107
+ // 'abc.*' -> skip this rule,
13108
+ // coz trailing single wildcard will be handed by [trailing wildcard]
13109
+ /(^|[^\\]+)(\\\*)+(?=.+)/g,
13110
+
13111
+ // '*.js' matches '.js'
13112
+ // '*.js' doesn't match 'abc'
13113
+ (_, p1, p2) => {
13114
+ // 1.
13115
+ // > An asterisk "*" matches anything except a slash.
13116
+ // 2.
13117
+ // > Other consecutive asterisks are considered regular asterisks
13118
+ // > and will match according to the previous rules.
13119
+ const unescaped = p2.replace(/\\\*/g, '[^\\/]*');
13120
+ return p1 + unescaped
13121
+ }
13122
+ ],
13123
+
13124
+ [
13125
+ // unescape, revert step 3 except for back slash
13126
+ // For example, if a user escape a '\\*',
13127
+ // after step 3, the result will be '\\\\\\*'
13128
+ /\\\\\\(?=[$.|*+(){^])/g,
13129
+ () => ESCAPE
13130
+ ],
13131
+
13132
+ [
13133
+ // '\\\\' -> '\\'
13134
+ /\\\\/g,
13135
+ () => ESCAPE
13136
+ ],
13137
+
13138
+ [
13139
+ // > The range notation, e.g. [a-zA-Z],
13140
+ // > can be used to match one of the characters in a range.
13141
+
13142
+ // `\` is escaped by step 3
13143
+ /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
13144
+ (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE
13145
+ // '\\[bar]' -> '\\\\[bar\\]'
13146
+ ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`
13147
+ : close === ']'
13148
+ ? endEscape.length % 2 === 0
13149
+ // A normal case, and it is a range notation
13150
+ // '[bar]'
13151
+ // '[bar\\\\]'
13152
+ ? `[${sanitizeRange(range)}${endEscape}]`
13153
+ // Invalid range notaton
13154
+ // '[bar\\]' -> '[bar\\\\]'
13155
+ : '[]'
13156
+ : '[]'
13157
+ ],
13158
+
13159
+ // ending
13160
+ [
13161
+ // 'js' will not match 'js.'
13162
+ // 'ab' will not match 'abc'
13163
+ /(?:[^*])$/,
13164
+
13165
+ // WTF!
13166
+ // https://git-scm.com/docs/gitignore
13167
+ // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
13168
+ // which re-fixes #24, #38
13169
+
13170
+ // > If there is a separator at the end of the pattern then the pattern
13171
+ // > will only match directories, otherwise the pattern can match both
13172
+ // > files and directories.
13173
+
13174
+ // 'js*' will not match 'a.js'
13175
+ // 'js/' will not match 'a.js'
13176
+ // 'js' will match 'a.js' and 'a.js/'
13177
+ match => /\/$/.test(match)
13178
+ // foo/ will not match 'foo'
13179
+ ? `${match}$`
13180
+ // foo matches 'foo' and 'foo/'
13181
+ : `${match}(?=$|\\/$)`
13182
+ ],
13183
+
13184
+ // trailing wildcard
13185
+ [
13186
+ /(\^|\\\/)?\\\*$/,
13187
+ (_, p1) => {
13188
+ const prefix = p1
13189
+ // '\^':
13190
+ // '/*' does not match EMPTY
13191
+ // '/*' does not match everything
13192
+
13193
+ // '\\\/':
13194
+ // 'abc/*' does not match 'abc/'
13195
+ ? `${p1}[^/]+`
13196
+
13197
+ // 'a*' matches 'a'
13198
+ // 'a*' matches 'aa'
13199
+ : '[^/]*';
13200
+
13201
+ return `${prefix}(?=$|\\/$)`
13202
+ }
13203
+ ],
13204
+ ];
13205
+
13206
+ // A simple cache, because an ignore rule only has only one certain meaning
13207
+ const regexCache = Object.create(null);
13208
+
13209
+ // @param {pattern}
13210
+ const makeRegex = (pattern, ignoreCase) => {
13211
+ let source = regexCache[pattern];
13212
+
13213
+ if (!source) {
13214
+ source = REPLACERS.reduce(
13215
+ (prev, [matcher, replacer]) =>
13216
+ prev.replace(matcher, replacer.bind(pattern)),
13217
+ pattern
13218
+ );
13219
+ regexCache[pattern] = source;
13220
+ }
13221
+
13222
+ return ignoreCase
13223
+ ? new RegExp(source, 'i')
13224
+ : new RegExp(source)
13225
+ };
13226
+
13227
+ const isString = subject => typeof subject === 'string';
13228
+
13229
+ // > A blank line matches no files, so it can serve as a separator for readability.
13230
+ const checkPattern = pattern => pattern
13231
+ && isString(pattern)
13232
+ && !REGEX_TEST_BLANK_LINE.test(pattern)
13233
+ && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
13234
+
13235
+ // > A line starting with # serves as a comment.
13236
+ && pattern.indexOf('#') !== 0;
13237
+
13238
+ const splitPattern = pattern => pattern.split(REGEX_SPLITALL_CRLF);
13239
+
13240
+ class IgnoreRule {
13241
+ constructor (
13242
+ origin,
13243
+ pattern,
13244
+ negative,
13245
+ regex
13246
+ ) {
13247
+ this.origin = origin;
13248
+ this.pattern = pattern;
13249
+ this.negative = negative;
13250
+ this.regex = regex;
13251
+ }
13252
+ }
13494
13253
 
13495
- checkPath.convert = makePosix;
13254
+ const createRule = (pattern, ignoreCase) => {
13255
+ const origin = pattern;
13256
+ let negative = false;
13257
+
13258
+ // > An optional prefix "!" which negates the pattern;
13259
+ if (pattern.indexOf('!') === 0) {
13260
+ negative = true;
13261
+ pattern = pattern.substr(1);
13262
+ }
13263
+
13264
+ pattern = pattern
13265
+ // > Put a backslash ("\") in front of the first "!" for patterns that
13266
+ // > begin with a literal "!", for example, `"\!important!.txt"`.
13267
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
13268
+ // > Put a backslash ("\") in front of the first hash for patterns that
13269
+ // > begin with a hash.
13270
+ .replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
13271
+
13272
+ const regex = makeRegex(pattern, ignoreCase);
13273
+
13274
+ return new IgnoreRule(
13275
+ origin,
13276
+ pattern,
13277
+ negative,
13278
+ regex
13279
+ )
13280
+ };
13281
+
13282
+ const throwError = (message, Ctor) => {
13283
+ throw new Ctor(message)
13284
+ };
13285
+
13286
+ const checkPath = (path, originalPath, doThrow) => {
13287
+ if (!isString(path)) {
13288
+ return doThrow(
13289
+ `path must be a string, but got \`${originalPath}\``,
13290
+ TypeError
13291
+ )
13292
+ }
13293
+
13294
+ // We don't know if we should ignore EMPTY, so throw
13295
+ if (!path) {
13296
+ return doThrow(`path must not be empty`, TypeError)
13297
+ }
13298
+
13299
+ // Check if it is a relative path
13300
+ if (checkPath.isNotRelative(path)) {
13301
+ const r = '`path.relative()`d';
13302
+ return doThrow(
13303
+ `path should be a ${r} string, but got "${originalPath}"`,
13304
+ RangeError
13305
+ )
13306
+ }
13307
+
13308
+ return true
13309
+ };
13310
+
13311
+ const isNotRelative = path => REGEX_TEST_INVALID_PATH.test(path);
13312
+
13313
+ checkPath.isNotRelative = isNotRelative;
13314
+ checkPath.convert = p => p;
13315
+
13316
+ class Ignore {
13317
+ constructor ({
13318
+ ignorecase = true,
13319
+ ignoreCase = ignorecase,
13320
+ allowRelativePaths = false
13321
+ } = {}) {
13322
+ define(this, KEY_IGNORE, true);
13323
+
13324
+ this._rules = [];
13325
+ this._ignoreCase = ignoreCase;
13326
+ this._allowRelativePaths = allowRelativePaths;
13327
+ this._initCache();
13328
+ }
13329
+
13330
+ _initCache () {
13331
+ this._ignoreCache = Object.create(null);
13332
+ this._testCache = Object.create(null);
13333
+ }
13334
+
13335
+ _addPattern (pattern) {
13336
+ // #32
13337
+ if (pattern && pattern[KEY_IGNORE]) {
13338
+ this._rules = this._rules.concat(pattern._rules);
13339
+ this._added = true;
13340
+ return
13341
+ }
13342
+
13343
+ if (checkPattern(pattern)) {
13344
+ const rule = createRule(pattern, this._ignoreCase);
13345
+ this._added = true;
13346
+ this._rules.push(rule);
13347
+ }
13348
+ }
13349
+
13350
+ // @param {Array<string> | string | Ignore} pattern
13351
+ add (pattern) {
13352
+ this._added = false;
13353
+
13354
+ makeArray(
13355
+ isString(pattern)
13356
+ ? splitPattern(pattern)
13357
+ : pattern
13358
+ ).forEach(this._addPattern, this);
13359
+
13360
+ // Some rules have just added to the ignore,
13361
+ // making the behavior changed.
13362
+ if (this._added) {
13363
+ this._initCache();
13364
+ }
13365
+
13366
+ return this
13367
+ }
13368
+
13369
+ // legacy
13370
+ addPattern (pattern) {
13371
+ return this.add(pattern)
13372
+ }
13373
+
13374
+ // | ignored : unignored
13375
+ // negative | 0:0 | 0:1 | 1:0 | 1:1
13376
+ // -------- | ------- | ------- | ------- | --------
13377
+ // 0 | TEST | TEST | SKIP | X
13378
+ // 1 | TESTIF | SKIP | TEST | X
13379
+
13380
+ // - SKIP: always skip
13381
+ // - TEST: always test
13382
+ // - TESTIF: only test if checkUnignored
13383
+ // - X: that never happen
13384
+
13385
+ // @param {boolean} whether should check if the path is unignored,
13386
+ // setting `checkUnignored` to `false` could reduce additional
13387
+ // path matching.
13388
+
13389
+ // @returns {TestResult} true if a file is ignored
13390
+ _testOne (path, checkUnignored) {
13391
+ let ignored = false;
13392
+ let unignored = false;
13393
+
13394
+ this._rules.forEach(rule => {
13395
+ const {negative} = rule;
13396
+ if (
13397
+ unignored === negative && ignored !== unignored
13398
+ || negative && !ignored && !unignored && !checkUnignored
13399
+ ) {
13400
+ return
13401
+ }
13402
+
13403
+ const matched = rule.regex.test(path);
13404
+
13405
+ if (matched) {
13406
+ ignored = !negative;
13407
+ unignored = negative;
13408
+ }
13409
+ });
13410
+
13411
+ return {
13412
+ ignored,
13413
+ unignored
13414
+ }
13415
+ }
13416
+
13417
+ // @returns {TestResult}
13418
+ _test (originalPath, cache, checkUnignored, slices) {
13419
+ const path = originalPath
13420
+ // Supports nullable path
13421
+ && checkPath.convert(originalPath);
13422
+
13423
+ checkPath(
13424
+ path,
13425
+ originalPath,
13426
+ this._allowRelativePaths
13427
+ ? RETURN_FALSE
13428
+ : throwError
13429
+ );
13430
+
13431
+ return this._t(path, cache, checkUnignored, slices)
13432
+ }
13433
+
13434
+ _t (path, cache, checkUnignored, slices) {
13435
+ if (path in cache) {
13436
+ return cache[path]
13437
+ }
13438
+
13439
+ if (!slices) {
13440
+ // path/to/a.js
13441
+ // ['path', 'to', 'a.js']
13442
+ slices = path.split(SLASH);
13443
+ }
13444
+
13445
+ slices.pop();
13446
+
13447
+ // If the path has no parent directory, just test it
13448
+ if (!slices.length) {
13449
+ return cache[path] = this._testOne(path, checkUnignored)
13450
+ }
13451
+
13452
+ const parent = this._t(
13453
+ slices.join(SLASH) + SLASH,
13454
+ cache,
13455
+ checkUnignored,
13456
+ slices
13457
+ );
13458
+
13459
+ // If the path contains a parent directory, check the parent first
13460
+ return cache[path] = parent.ignored
13461
+ // > It is not possible to re-include a file if a parent directory of
13462
+ // > that file is excluded.
13463
+ ? parent
13464
+ : this._testOne(path, checkUnignored)
13465
+ }
13466
+
13467
+ ignores (path) {
13468
+ return this._test(path, this._ignoreCache, false).ignored
13469
+ }
13470
+
13471
+ createFilter () {
13472
+ return path => !this.ignores(path)
13473
+ }
13474
+
13475
+ filter (paths) {
13476
+ return makeArray(paths).filter(this.createFilter())
13477
+ }
13478
+
13479
+ // @returns {TestResult}
13480
+ test (path) {
13481
+ return this._test(path, this._testCache, true)
13482
+ }
13483
+ }
13496
13484
 
13497
- // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
13498
- // 'd:\\foo'
13499
- const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
13500
- checkPath.isNotRelative = path =>
13501
- REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
13502
- || isNotRelative(path);
13485
+ const factory = options => new Ignore(options);
13486
+
13487
+ const isPathValid = path =>
13488
+ checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
13489
+
13490
+ factory.isPathValid = isPathValid;
13491
+
13492
+ // Fixes typescript
13493
+ factory.default = factory;
13494
+
13495
+ ignore$1 = factory;
13496
+
13497
+ // Windows
13498
+ // --------------------------------------------------------------
13499
+ /* istanbul ignore if */
13500
+ if (
13501
+ // Detect `process` so that it can run in browsers.
13502
+ typeof process !== 'undefined'
13503
+ && (
13504
+ process.env && process.env.IGNORE_TEST_WIN32
13505
+ || process.platform === 'win32'
13506
+ )
13507
+ ) {
13508
+ /* eslint no-control-regex: "off" */
13509
+ const makePosix = str => /^\\\\\?\\/.test(str)
13510
+ || /["<>|\u0000-\u001F]+/u.test(str)
13511
+ ? str
13512
+ : str.replace(/\\/g, '/');
13513
+
13514
+ checkPath.convert = makePosix;
13515
+
13516
+ // 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
13517
+ // 'd:\\foo'
13518
+ const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
13519
+ checkPath.isNotRelative = path =>
13520
+ REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path)
13521
+ || isNotRelative(path);
13522
+ }
13523
+ return ignore$1;
13503
13524
  }
13504
13525
 
13505
- var ignore$1 = /*@__PURE__*/getDefaultExportFromCjs(ignore);
13526
+ var ignoreExports = /*@__PURE__*/ requireIgnore();
13527
+ var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
13506
13528
 
13507
13529
  const entities = {
13508
13530
  ">": "&gt;",
@@ -13813,5 +13835,5 @@ function compatibilityCheckImpl(name, declared, options) {
13813
13835
  return false;
13814
13836
  }
13815
13837
 
13816
- export { Attribute as A, Reporter as B, Config as C, DOMNode as D, definePlugin as E, ruleExists as F, walk as G, HtmlValidate as H, EventHandler as I, compatibilityCheckImpl as J, codeframe as K, name as L, MetaCopyableProperty as M, NodeClosed as N, bugs as O, Parser as P, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, defineConfig as c, deepmerge$1 as d, ensureError as e, StaticConfigLoader as f, getFormatter as g, DOMTokenList as h, ignore$1 as i, DOMTree as j, DynamicValue as k, HtmlElement as l, NodeType as m, NestedError as n, SchemaValidationError as o, presets as p, MetaTable as q, TextContent$1 as r, staticResolver as s, Rule as t, ariaNaming as u, version as v, TextClassification as w, classifyNodeText as x, keywordPatternMatcher as y, sliceLocation as z };
13838
+ export { Attribute as A, Reporter as B, Config as C, DOMNode as D, definePlugin as E, ruleExists as F, walk as G, HtmlValidate as H, EventHandler as I, compatibilityCheckImpl as J, codeframe as K, name as L, MetaCopyableProperty as M, NodeClosed as N, bugs as O, Parser as P, ResolvedConfig as R, Severity as S, TextNode as T, UserError as U, Validator as V, WrappedError as W, ConfigError as a, ConfigLoader as b, defineConfig as c, deepmerge as d, ensureError as e, StaticConfigLoader as f, getFormatter as g, DOMTokenList as h, ignore as i, DOMTree as j, DynamicValue as k, HtmlElement as l, NodeType as m, NestedError as n, SchemaValidationError as o, presets as p, MetaTable as q, TextContent$1 as r, staticResolver as s, Rule as t, ariaNaming as u, version as v, TextClassification as w, classifyNodeText as x, keywordPatternMatcher as y, sliceLocation as z };
13817
13839
  //# sourceMappingURL=core.js.map