immosquare-cleaner 0.1.46 → 0.1.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/rubocop-3.3.4.yml +2 -0
- data/linters/rubocop.yml +2 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/LICENSE-MIT +21 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/README.md +412 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/index.d.ts +61 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/index.js +618 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/legacy.js +539 -0
- data/node_modules/@eslint/eslintrc/node_modules/ignore/package.json +73 -0
- data/node_modules/@eslint/js/package.json +1 -1
- data/node_modules/@eslint/plugin-kit/LICENSE +201 -0
- data/node_modules/@eslint/plugin-kit/README.md +224 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs +555 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts +239 -0
- data/node_modules/@eslint/plugin-kit/dist/cjs/types.ts +7 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts +239 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/index.js +551 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts +6 -0
- data/node_modules/@eslint/plugin-kit/dist/esm/types.ts +7 -0
- data/node_modules/@eslint/plugin-kit/package.json +62 -0
- data/node_modules/eslint/README.md +2 -2
- data/node_modules/eslint/lib/config/config.js +278 -0
- data/node_modules/eslint/lib/config/flat-config-array.js +3 -204
- data/node_modules/eslint/lib/languages/js/source-code/source-code.js +29 -94
- data/node_modules/eslint/lib/linter/apply-disable-directives.js +17 -28
- data/node_modules/eslint/lib/linter/file-context.js +134 -0
- data/node_modules/eslint/lib/linter/linter.js +37 -42
- data/node_modules/eslint/lib/rules/id-length.js +1 -0
- data/node_modules/eslint/lib/rules/no-invalid-regexp.js +34 -18
- data/node_modules/eslint/lib/rules/require-unicode-regexp.js +95 -14
- data/node_modules/eslint/lib/rules/utils/regular-expressions.js +11 -3
- data/node_modules/eslint/lib/types/index.d.ts +1635 -0
- data/node_modules/eslint/lib/types/rules/best-practices.d.ts +1075 -0
- data/node_modules/eslint/lib/types/rules/deprecated.d.ts +294 -0
- data/node_modules/eslint/lib/types/rules/ecmascript-6.d.ts +561 -0
- data/node_modules/eslint/lib/types/rules/index.d.ts +50 -0
- data/node_modules/eslint/lib/types/rules/node-commonjs.d.ts +160 -0
- data/node_modules/eslint/lib/types/rules/possible-errors.d.ts +598 -0
- data/node_modules/eslint/lib/types/rules/strict-mode.d.ts +38 -0
- data/node_modules/eslint/lib/types/rules/stylistic-issues.d.ts +1932 -0
- data/node_modules/eslint/lib/types/rules/variables.d.ts +221 -0
- data/node_modules/eslint/lib/types/use-at-your-own-risk.d.ts +85 -0
- data/node_modules/eslint/package.json +20 -8
- data/node_modules/ignore/index.d.ts +1 -1
- data/node_modules/ignore/index.js +25 -7
- data/node_modules/ignore/legacy.js +34 -14
- data/node_modules/ignore/package.json +12 -11
- data/node_modules/npm-check-updates/build/index.js +282 -282
- data/node_modules/npm-check-updates/build/index.js.map +1 -1
- data/node_modules/npm-check-updates/package.json +1 -1
- data/package.json +3 -3
- metadata +31 -4
- data/linters/rubocop-2.7.6.yml +0 -88
- data/node_modules/eslint/lib/linter/config-comment-parser.js +0 -169
@@ -0,0 +1,539 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
9
|
+
// A simple implementation of make-array
|
10
|
+
function makeArray(subject) {
|
11
|
+
return Array.isArray(subject) ? subject : [subject];
|
12
|
+
}
|
13
|
+
var EMPTY = '';
|
14
|
+
var SPACE = ' ';
|
15
|
+
var ESCAPE = '\\';
|
16
|
+
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
17
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
18
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
19
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
20
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
21
|
+
// /foo,
|
22
|
+
// ./foo,
|
23
|
+
// ../foo,
|
24
|
+
// .
|
25
|
+
// ..
|
26
|
+
var REGEX_TEST_INVALID_PATH = /^\.*\/|^\.+$/;
|
27
|
+
var SLASH = '/';
|
28
|
+
|
29
|
+
// Do not use ternary expression here, since "istanbul ignore next" is buggy
|
30
|
+
var TMP_KEY_IGNORE = 'node-ignore';
|
31
|
+
/* istanbul ignore else */
|
32
|
+
if (typeof Symbol !== 'undefined') {
|
33
|
+
TMP_KEY_IGNORE = Symbol["for"]('node-ignore');
|
34
|
+
}
|
35
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
36
|
+
var define = function define(object, key, value) {
|
37
|
+
return Object.defineProperty(object, key, {
|
38
|
+
value: value
|
39
|
+
});
|
40
|
+
};
|
41
|
+
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
42
|
+
var RETURN_FALSE = function RETURN_FALSE() {
|
43
|
+
return false;
|
44
|
+
};
|
45
|
+
|
46
|
+
// Sanitize the range of a regular expression
|
47
|
+
// The cases are complicated, see test cases for details
|
48
|
+
var sanitizeRange = function sanitizeRange(range) {
|
49
|
+
return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
|
50
|
+
return from.charCodeAt(0) <= to.charCodeAt(0) ? match
|
51
|
+
// Invalid range (out of order) which is ok for gitignore rules but
|
52
|
+
// fatal for JavaScript regular expression, so eliminate it.
|
53
|
+
: EMPTY;
|
54
|
+
});
|
55
|
+
};
|
56
|
+
|
57
|
+
// See fixtures #59
|
58
|
+
var cleanRangeBackSlash = function cleanRangeBackSlash(slashes) {
|
59
|
+
var length = slashes.length;
|
60
|
+
return slashes.slice(0, length - length % 2);
|
61
|
+
};
|
62
|
+
|
63
|
+
// > If the pattern ends with a slash,
|
64
|
+
// > it is removed for the purpose of the following description,
|
65
|
+
// > but it would only find a match with a directory.
|
66
|
+
// > In other words, foo/ will match a directory foo and paths underneath it,
|
67
|
+
// > but will not match a regular file or a symbolic link foo
|
68
|
+
// > (this is consistent with the way how pathspec works in general in Git).
|
69
|
+
// '`foo/`' will not match regular file '`foo`' or symbolic link '`foo`'
|
70
|
+
// -> ignore-rules will not deal with it, because it costs extra `fs.stat` call
|
71
|
+
// you could use option `mark: true` with `glob`
|
72
|
+
|
73
|
+
// '`foo/`' should not continue with the '`..`'
|
74
|
+
var REPLACERS = [
|
75
|
+
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
76
|
+
[
|
77
|
+
// (a\ ) -> (a )
|
78
|
+
// (a ) -> (a)
|
79
|
+
// (a \ ) -> (a )
|
80
|
+
/\\?\s+$/, function (match) {
|
81
|
+
return match.indexOf('\\') === 0 ? SPACE : EMPTY;
|
82
|
+
}],
|
83
|
+
// replace (\ ) with ' '
|
84
|
+
[/\\\s/g, function () {
|
85
|
+
return SPACE;
|
86
|
+
}],
|
87
|
+
// Escape metacharacters
|
88
|
+
// which is written down by users but means special for regular expressions.
|
89
|
+
|
90
|
+
// > There are 12 characters with special meanings:
|
91
|
+
// > - the backslash \,
|
92
|
+
// > - the caret ^,
|
93
|
+
// > - the dollar sign $,
|
94
|
+
// > - the period or dot .,
|
95
|
+
// > - the vertical bar or pipe symbol |,
|
96
|
+
// > - the question mark ?,
|
97
|
+
// > - the asterisk or star *,
|
98
|
+
// > - the plus sign +,
|
99
|
+
// > - the opening parenthesis (,
|
100
|
+
// > - the closing parenthesis ),
|
101
|
+
// > - and the opening square bracket [,
|
102
|
+
// > - the opening curly brace {,
|
103
|
+
// > These special characters are often called "metacharacters".
|
104
|
+
[/[\\$.|*+(){^]/g, function (match) {
|
105
|
+
return "\\".concat(match);
|
106
|
+
}], [
|
107
|
+
// > a question mark (?) matches a single character
|
108
|
+
/(?!\\)\?/g, function () {
|
109
|
+
return '[^/]';
|
110
|
+
}],
|
111
|
+
// leading slash
|
112
|
+
[
|
113
|
+
// > A leading slash matches the beginning of the pathname.
|
114
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
115
|
+
// A leading slash matches the beginning of the pathname
|
116
|
+
/^\//, function () {
|
117
|
+
return '^';
|
118
|
+
}],
|
119
|
+
// replace special metacharacter slash after the leading slash
|
120
|
+
[/\//g, function () {
|
121
|
+
return '\\/';
|
122
|
+
}], [
|
123
|
+
// > A leading "**" followed by a slash means match in all directories.
|
124
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
125
|
+
// > the same as pattern "foo".
|
126
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
127
|
+
// > under directory "foo".
|
128
|
+
// Notice that the '*'s have been replaced as '\\*'
|
129
|
+
/^\^*\\\*\\\*\\\//,
|
130
|
+
// '**/foo' <-> 'foo'
|
131
|
+
function () {
|
132
|
+
return '^(?:.*\\/)?';
|
133
|
+
}],
|
134
|
+
// starting
|
135
|
+
[
|
136
|
+
// there will be no leading '/'
|
137
|
+
// (which has been replaced by section "leading slash")
|
138
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
139
|
+
/^(?=[^^])/, function startingReplacer() {
|
140
|
+
// If has a slash `/` at the beginning or middle
|
141
|
+
return !/\/(?!$)/.test(this)
|
142
|
+
// > Prior to 2.22.1
|
143
|
+
// > If the pattern does not contain a slash /,
|
144
|
+
// > Git treats it as a shell glob pattern
|
145
|
+
// Actually, if there is only a trailing slash,
|
146
|
+
// git also treats it as a shell glob pattern
|
147
|
+
|
148
|
+
// After 2.22.1 (compatible but clearer)
|
149
|
+
// > If there is a separator at the beginning or middle (or both)
|
150
|
+
// > of the pattern, then the pattern is relative to the directory
|
151
|
+
// > level of the particular .gitignore file itself.
|
152
|
+
// > Otherwise the pattern may also match at any level below
|
153
|
+
// > the .gitignore level.
|
154
|
+
? '(?:^|\\/)'
|
155
|
+
|
156
|
+
// > Otherwise, Git treats the pattern as a shell glob suitable for
|
157
|
+
// > consumption by fnmatch(3)
|
158
|
+
: '^';
|
159
|
+
}],
|
160
|
+
// two globstars
|
161
|
+
[
|
162
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
163
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
164
|
+
// Zero, one or several directories
|
165
|
+
// should not use '*', or it will be replaced by the next replacer
|
166
|
+
|
167
|
+
// Check if it is not the last `'/**'`
|
168
|
+
function (_, index, str) {
|
169
|
+
return index + 6 < str.length
|
170
|
+
|
171
|
+
// case: /**/
|
172
|
+
// > A slash followed by two consecutive asterisks then a slash matches
|
173
|
+
// > zero or more directories.
|
174
|
+
// > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
|
175
|
+
// '/**/'
|
176
|
+
? '(?:\\/[^\\/]+)*'
|
177
|
+
|
178
|
+
// case: /**
|
179
|
+
// > A trailing `"/**"` matches everything inside.
|
180
|
+
|
181
|
+
// #21: everything inside but it should not include the current folder
|
182
|
+
: '\\/.+';
|
183
|
+
}],
|
184
|
+
// normal intermediate wildcards
|
185
|
+
[
|
186
|
+
// Never replace escaped '*'
|
187
|
+
// ignore rule '\*' will match the path '*'
|
188
|
+
|
189
|
+
// 'abc.*/' -> go
|
190
|
+
// 'abc.*' -> skip this rule,
|
191
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
192
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
193
|
+
// '*.js' matches '.js'
|
194
|
+
// '*.js' doesn't match 'abc'
|
195
|
+
function (_, p1, p2) {
|
196
|
+
// 1.
|
197
|
+
// > An asterisk "*" matches anything except a slash.
|
198
|
+
// 2.
|
199
|
+
// > Other consecutive asterisks are considered regular asterisks
|
200
|
+
// > and will match according to the previous rules.
|
201
|
+
var unescaped = p2.replace(/\\\*/g, '[^\\/]*');
|
202
|
+
return p1 + unescaped;
|
203
|
+
}], [
|
204
|
+
// unescape, revert step 3 except for back slash
|
205
|
+
// For example, if a user escape a '\\*',
|
206
|
+
// after step 3, the result will be '\\\\\\*'
|
207
|
+
/\\\\\\(?=[$.|*+(){^])/g, function () {
|
208
|
+
return ESCAPE;
|
209
|
+
}], [
|
210
|
+
// '\\\\' -> '\\'
|
211
|
+
/\\\\/g, function () {
|
212
|
+
return ESCAPE;
|
213
|
+
}], [
|
214
|
+
// > The range notation, e.g. [a-zA-Z],
|
215
|
+
// > can be used to match one of the characters in a range.
|
216
|
+
|
217
|
+
// `\` is escaped by step 3
|
218
|
+
/(\\)?\[([^\]/]*?)(\\*)($|\])/g, function (match, leadEscape, range, endEscape, close) {
|
219
|
+
return leadEscape === ESCAPE
|
220
|
+
// '\\[bar]' -> '\\\\[bar\\]'
|
221
|
+
? "\\[".concat(range).concat(cleanRangeBackSlash(endEscape)).concat(close) : close === ']' ? endEscape.length % 2 === 0
|
222
|
+
// A normal case, and it is a range notation
|
223
|
+
// '[bar]'
|
224
|
+
// '[bar\\\\]'
|
225
|
+
? "[".concat(sanitizeRange(range)).concat(endEscape, "]") // Invalid range notaton
|
226
|
+
// '[bar\\]' -> '[bar\\\\]'
|
227
|
+
: '[]' : '[]';
|
228
|
+
}],
|
229
|
+
// ending
|
230
|
+
[
|
231
|
+
// 'js' will not match 'js.'
|
232
|
+
// 'ab' will not match 'abc'
|
233
|
+
/(?:[^*])$/,
|
234
|
+
// WTF!
|
235
|
+
// https://git-scm.com/docs/gitignore
|
236
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
237
|
+
// which re-fixes #24, #38
|
238
|
+
|
239
|
+
// > If there is a separator at the end of the pattern then the pattern
|
240
|
+
// > will only match directories, otherwise the pattern can match both
|
241
|
+
// > files and directories.
|
242
|
+
|
243
|
+
// 'js*' will not match 'a.js'
|
244
|
+
// 'js/' will not match 'a.js'
|
245
|
+
// 'js' will match 'a.js' and 'a.js/'
|
246
|
+
function (match) {
|
247
|
+
return /\/$/.test(match)
|
248
|
+
// foo/ will not match 'foo'
|
249
|
+
? "".concat(match, "$") // foo matches 'foo' and 'foo/'
|
250
|
+
: "".concat(match, "(?=$|\\/$)");
|
251
|
+
}],
|
252
|
+
// trailing wildcard
|
253
|
+
[/(\^|\\\/)?\\\*$/, function (_, p1) {
|
254
|
+
var prefix = p1
|
255
|
+
// '\^':
|
256
|
+
// '/*' does not match EMPTY
|
257
|
+
// '/*' does not match everything
|
258
|
+
|
259
|
+
// '\\\/':
|
260
|
+
// 'abc/*' does not match 'abc/'
|
261
|
+
? "".concat(p1, "[^/]+") // 'a*' matches 'a'
|
262
|
+
// 'a*' matches 'aa'
|
263
|
+
: '[^/]*';
|
264
|
+
return "".concat(prefix, "(?=$|\\/$)");
|
265
|
+
}]];
|
266
|
+
|
267
|
+
// A simple cache, because an ignore rule only has only one certain meaning
|
268
|
+
var regexCache = Object.create(null);
|
269
|
+
|
270
|
+
// @param {pattern}
|
271
|
+
var makeRegex = function makeRegex(pattern, ignoreCase) {
|
272
|
+
var source = regexCache[pattern];
|
273
|
+
if (!source) {
|
274
|
+
source = REPLACERS.reduce(function (prev, current) {
|
275
|
+
return prev.replace(current[0], current[1].bind(pattern));
|
276
|
+
}, pattern);
|
277
|
+
regexCache[pattern] = source;
|
278
|
+
}
|
279
|
+
return ignoreCase ? new RegExp(source, 'i') : new RegExp(source);
|
280
|
+
};
|
281
|
+
var isString = function isString(subject) {
|
282
|
+
return typeof subject === 'string';
|
283
|
+
};
|
284
|
+
|
285
|
+
// > A blank line matches no files, so it can serve as a separator for readability.
|
286
|
+
var checkPattern = function checkPattern(pattern) {
|
287
|
+
return pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
|
288
|
+
|
289
|
+
// > A line starting with # serves as a comment.
|
290
|
+
&& pattern.indexOf('#') !== 0;
|
291
|
+
};
|
292
|
+
var splitPattern = function splitPattern(pattern) {
|
293
|
+
return pattern.split(REGEX_SPLITALL_CRLF);
|
294
|
+
};
|
295
|
+
var IgnoreRule = /*#__PURE__*/_createClass(function IgnoreRule(origin, pattern, negative, regex) {
|
296
|
+
_classCallCheck(this, IgnoreRule);
|
297
|
+
this.origin = origin;
|
298
|
+
this.pattern = pattern;
|
299
|
+
this.negative = negative;
|
300
|
+
this.regex = regex;
|
301
|
+
});
|
302
|
+
var createRule = function createRule(pattern, ignoreCase) {
|
303
|
+
var origin = pattern;
|
304
|
+
var negative = false;
|
305
|
+
|
306
|
+
// > An optional prefix "!" which negates the pattern;
|
307
|
+
if (pattern.indexOf('!') === 0) {
|
308
|
+
negative = true;
|
309
|
+
pattern = pattern.substr(1);
|
310
|
+
}
|
311
|
+
pattern = pattern
|
312
|
+
// > Put a backslash ("\") in front of the first "!" for patterns that
|
313
|
+
// > begin with a literal "!", for example, `"\!important!.txt"`.
|
314
|
+
.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, '!')
|
315
|
+
// > Put a backslash ("\") in front of the first hash for patterns that
|
316
|
+
// > begin with a hash.
|
317
|
+
.replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, '#');
|
318
|
+
var regex = makeRegex(pattern, ignoreCase);
|
319
|
+
return new IgnoreRule(origin, pattern, negative, regex);
|
320
|
+
};
|
321
|
+
var throwError = function throwError(message, Ctor) {
|
322
|
+
throw new Ctor(message);
|
323
|
+
};
|
324
|
+
var checkPath = function checkPath(path, originalPath, doThrow) {
|
325
|
+
if (!isString(path)) {
|
326
|
+
return doThrow("path must be a string, but got `".concat(originalPath, "`"), TypeError);
|
327
|
+
}
|
328
|
+
|
329
|
+
// We don't know if we should ignore EMPTY, so throw
|
330
|
+
if (!path) {
|
331
|
+
return doThrow("path must not be empty", TypeError);
|
332
|
+
}
|
333
|
+
|
334
|
+
// Check if it is a relative path
|
335
|
+
if (checkPath.isNotRelative(path)) {
|
336
|
+
var r = '`path.relative()`d';
|
337
|
+
return doThrow("path should be a ".concat(r, " string, but got \"").concat(originalPath, "\""), RangeError);
|
338
|
+
}
|
339
|
+
return true;
|
340
|
+
};
|
341
|
+
var isNotRelative = function isNotRelative(path) {
|
342
|
+
return REGEX_TEST_INVALID_PATH.test(path);
|
343
|
+
};
|
344
|
+
checkPath.isNotRelative = isNotRelative;
|
345
|
+
checkPath.convert = function (p) {
|
346
|
+
return p;
|
347
|
+
};
|
348
|
+
var Ignore = /*#__PURE__*/function () {
|
349
|
+
function Ignore() {
|
350
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
351
|
+
_ref$ignorecase = _ref.ignorecase,
|
352
|
+
ignorecase = _ref$ignorecase === void 0 ? true : _ref$ignorecase,
|
353
|
+
_ref$ignoreCase = _ref.ignoreCase,
|
354
|
+
ignoreCase = _ref$ignoreCase === void 0 ? ignorecase : _ref$ignoreCase,
|
355
|
+
_ref$allowRelativePat = _ref.allowRelativePaths,
|
356
|
+
allowRelativePaths = _ref$allowRelativePat === void 0 ? false : _ref$allowRelativePat;
|
357
|
+
_classCallCheck(this, Ignore);
|
358
|
+
define(this, KEY_IGNORE, true);
|
359
|
+
this._rules = [];
|
360
|
+
this._ignoreCase = ignoreCase;
|
361
|
+
this._allowRelativePaths = allowRelativePaths;
|
362
|
+
this._initCache();
|
363
|
+
}
|
364
|
+
_createClass(Ignore, [{
|
365
|
+
key: "_initCache",
|
366
|
+
value: function _initCache() {
|
367
|
+
this._ignoreCache = Object.create(null);
|
368
|
+
this._testCache = Object.create(null);
|
369
|
+
}
|
370
|
+
}, {
|
371
|
+
key: "_addPattern",
|
372
|
+
value: function _addPattern(pattern) {
|
373
|
+
// #32
|
374
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
375
|
+
this._rules = this._rules.concat(pattern._rules);
|
376
|
+
this._added = true;
|
377
|
+
return;
|
378
|
+
}
|
379
|
+
if (checkPattern(pattern)) {
|
380
|
+
var rule = createRule(pattern, this._ignoreCase);
|
381
|
+
this._added = true;
|
382
|
+
this._rules.push(rule);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
// @param {Array<string> | string | Ignore} pattern
|
387
|
+
}, {
|
388
|
+
key: "add",
|
389
|
+
value: function add(pattern) {
|
390
|
+
this._added = false;
|
391
|
+
makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._addPattern, this);
|
392
|
+
|
393
|
+
// Some rules have just added to the ignore,
|
394
|
+
// making the behavior changed.
|
395
|
+
if (this._added) {
|
396
|
+
this._initCache();
|
397
|
+
}
|
398
|
+
return this;
|
399
|
+
}
|
400
|
+
|
401
|
+
// legacy
|
402
|
+
}, {
|
403
|
+
key: "addPattern",
|
404
|
+
value: function addPattern(pattern) {
|
405
|
+
return this.add(pattern);
|
406
|
+
}
|
407
|
+
|
408
|
+
// | ignored : unignored
|
409
|
+
// negative | 0:0 | 0:1 | 1:0 | 1:1
|
410
|
+
// -------- | ------- | ------- | ------- | --------
|
411
|
+
// 0 | TEST | TEST | SKIP | X
|
412
|
+
// 1 | TESTIF | SKIP | TEST | X
|
413
|
+
|
414
|
+
// - SKIP: always skip
|
415
|
+
// - TEST: always test
|
416
|
+
// - TESTIF: only test if checkUnignored
|
417
|
+
// - X: that never happen
|
418
|
+
|
419
|
+
// @param {boolean} whether should check if the path is unignored,
|
420
|
+
// setting `checkUnignored` to `false` could reduce additional
|
421
|
+
// path matching.
|
422
|
+
|
423
|
+
// @returns {TestResult} true if a file is ignored
|
424
|
+
}, {
|
425
|
+
key: "_testOne",
|
426
|
+
value: function _testOne(path, checkUnignored) {
|
427
|
+
var ignored = false;
|
428
|
+
var unignored = false;
|
429
|
+
this._rules.forEach(function (rule) {
|
430
|
+
var negative = rule.negative;
|
431
|
+
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
432
|
+
return;
|
433
|
+
}
|
434
|
+
var matched = rule.regex.test(path);
|
435
|
+
if (matched) {
|
436
|
+
ignored = !negative;
|
437
|
+
unignored = negative;
|
438
|
+
}
|
439
|
+
});
|
440
|
+
return {
|
441
|
+
ignored: ignored,
|
442
|
+
unignored: unignored
|
443
|
+
};
|
444
|
+
}
|
445
|
+
|
446
|
+
// @returns {TestResult}
|
447
|
+
}, {
|
448
|
+
key: "_test",
|
449
|
+
value: function _test(originalPath, cache, checkUnignored, slices) {
|
450
|
+
var path = originalPath
|
451
|
+
// Supports nullable path
|
452
|
+
&& checkPath.convert(originalPath);
|
453
|
+
checkPath(path, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
454
|
+
return this._t(path, cache, checkUnignored, slices);
|
455
|
+
}
|
456
|
+
}, {
|
457
|
+
key: "_t",
|
458
|
+
value: function _t(path, cache, checkUnignored, slices) {
|
459
|
+
if (path in cache) {
|
460
|
+
return cache[path];
|
461
|
+
}
|
462
|
+
if (!slices) {
|
463
|
+
// path/to/a.js
|
464
|
+
// ['path', 'to', 'a.js']
|
465
|
+
slices = path.split(SLASH);
|
466
|
+
}
|
467
|
+
slices.pop();
|
468
|
+
|
469
|
+
// If the path has no parent directory, just test it
|
470
|
+
if (!slices.length) {
|
471
|
+
return cache[path] = this._testOne(path, checkUnignored);
|
472
|
+
}
|
473
|
+
var parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
474
|
+
|
475
|
+
// If the path contains a parent directory, check the parent first
|
476
|
+
return cache[path] = parent.ignored
|
477
|
+
// > It is not possible to re-include a file if a parent directory of
|
478
|
+
// > that file is excluded.
|
479
|
+
? parent : this._testOne(path, checkUnignored);
|
480
|
+
}
|
481
|
+
}, {
|
482
|
+
key: "ignores",
|
483
|
+
value: function ignores(path) {
|
484
|
+
return this._test(path, this._ignoreCache, false).ignored;
|
485
|
+
}
|
486
|
+
}, {
|
487
|
+
key: "createFilter",
|
488
|
+
value: function createFilter() {
|
489
|
+
var _this = this;
|
490
|
+
return function (path) {
|
491
|
+
return !_this.ignores(path);
|
492
|
+
};
|
493
|
+
}
|
494
|
+
}, {
|
495
|
+
key: "filter",
|
496
|
+
value: function filter(paths) {
|
497
|
+
return makeArray(paths).filter(this.createFilter());
|
498
|
+
}
|
499
|
+
|
500
|
+
// @returns {TestResult}
|
501
|
+
}, {
|
502
|
+
key: "test",
|
503
|
+
value: function test(path) {
|
504
|
+
return this._test(path, this._testCache, true);
|
505
|
+
}
|
506
|
+
}]);
|
507
|
+
return Ignore;
|
508
|
+
}();
|
509
|
+
var factory = function factory(options) {
|
510
|
+
return new Ignore(options);
|
511
|
+
};
|
512
|
+
var isPathValid = function isPathValid(path) {
|
513
|
+
return checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
514
|
+
};
|
515
|
+
factory.isPathValid = isPathValid;
|
516
|
+
|
517
|
+
// Fixes typescript
|
518
|
+
factory["default"] = factory;
|
519
|
+
module.exports = factory;
|
520
|
+
|
521
|
+
// Windows
|
522
|
+
// --------------------------------------------------------------
|
523
|
+
/* istanbul ignore if */
|
524
|
+
if (
|
525
|
+
// Detect `process` so that it can run in browsers.
|
526
|
+
typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32 || process.platform === 'win32')) {
|
527
|
+
/* eslint no-control-regex: "off" */
|
528
|
+
var makePosix = function makePosix(str) {
|
529
|
+
return /^\\\\\?\\/.test(str) || /[\0-\x1F"<>\|]+/.test(str) ? str : str.replace(/\\/g, '/');
|
530
|
+
};
|
531
|
+
checkPath.convert = makePosix;
|
532
|
+
|
533
|
+
// 'C:\\foo' <- 'C:\\foo' has been converted to 'C:/'
|
534
|
+
// 'd:\\foo'
|
535
|
+
var REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
536
|
+
checkPath.isNotRelative = function (path) {
|
537
|
+
return REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
538
|
+
};
|
539
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
{
|
2
|
+
"name": "ignore",
|
3
|
+
"version": "5.2.4",
|
4
|
+
"description": "Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.",
|
5
|
+
"files": [
|
6
|
+
"legacy.js",
|
7
|
+
"index.js",
|
8
|
+
"index.d.ts",
|
9
|
+
"LICENSE-MIT"
|
10
|
+
],
|
11
|
+
"scripts": {
|
12
|
+
"prepublishOnly": "npm run build",
|
13
|
+
"build": "babel -o legacy.js index.js",
|
14
|
+
"test:lint": "eslint .",
|
15
|
+
"test:tsc": "tsc ./test/ts/simple.ts --lib ES6",
|
16
|
+
"test:ts": "node ./test/ts/simple.js",
|
17
|
+
"tap": "tap --reporter classic",
|
18
|
+
"test:git": "npm run tap test/git-check-ignore.js",
|
19
|
+
"test:ignore": "npm run tap test/ignore.js",
|
20
|
+
"test:others": "npm run tap test/others.js",
|
21
|
+
"test:cases": "npm run tap test/*.js -- --coverage",
|
22
|
+
"test:no-coverage": "npm run tap test/*.js -- --no-check-coverage",
|
23
|
+
"test:only": "npm run test:lint && npm run test:tsc && npm run test:ts && npm run test:cases",
|
24
|
+
"test": "npm run test:only",
|
25
|
+
"test:win32": "IGNORE_TEST_WIN32=1 npm run test",
|
26
|
+
"report": "tap --coverage-report=html",
|
27
|
+
"posttest": "npm run report && codecov"
|
28
|
+
},
|
29
|
+
"repository": {
|
30
|
+
"type": "git",
|
31
|
+
"url": "git@github.com:kaelzhang/node-ignore.git"
|
32
|
+
},
|
33
|
+
"keywords": [
|
34
|
+
"ignore",
|
35
|
+
".gitignore",
|
36
|
+
"gitignore",
|
37
|
+
"npmignore",
|
38
|
+
"rules",
|
39
|
+
"manager",
|
40
|
+
"filter",
|
41
|
+
"regexp",
|
42
|
+
"regex",
|
43
|
+
"fnmatch",
|
44
|
+
"glob",
|
45
|
+
"asterisks",
|
46
|
+
"regular-expression"
|
47
|
+
],
|
48
|
+
"author": "kael",
|
49
|
+
"license": "MIT",
|
50
|
+
"bugs": {
|
51
|
+
"url": "https://github.com/kaelzhang/node-ignore/issues"
|
52
|
+
},
|
53
|
+
"devDependencies": {
|
54
|
+
"@babel/cli": "^7.19.3",
|
55
|
+
"@babel/core": "^7.20.5",
|
56
|
+
"@babel/preset-env": "^7.20.2",
|
57
|
+
"codecov": "^3.8.2",
|
58
|
+
"debug": "^4.3.4",
|
59
|
+
"eslint": "^8.30.0",
|
60
|
+
"eslint-config-ostai": "^3.0.0",
|
61
|
+
"eslint-plugin-import": "^2.26.0",
|
62
|
+
"mkdirp": "^1.0.4",
|
63
|
+
"pre-suf": "^1.1.1",
|
64
|
+
"rimraf": "^3.0.2",
|
65
|
+
"spawn-sync": "^2.0.0",
|
66
|
+
"tap": "^16.3.2",
|
67
|
+
"tmp": "0.2.1",
|
68
|
+
"typescript": "^4.9.4"
|
69
|
+
},
|
70
|
+
"engines": {
|
71
|
+
"node": ">= 4"
|
72
|
+
}
|
73
|
+
}
|