@dineroregnskab/eslint-plugin-custom-rules 2.0.6 → 2.0.7

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.
Files changed (174) hide show
  1. package/eslint-plugin-custom-rules.js +2 -0
  2. package/package.json +1 -1
  3. package/node_modules/@aashutoshrathi/word-wrap/LICENSE +0 -21
  4. package/node_modules/@aashutoshrathi/word-wrap/README.md +0 -182
  5. package/node_modules/@aashutoshrathi/word-wrap/index.d.ts +0 -50
  6. package/node_modules/@aashutoshrathi/word-wrap/index.js +0 -52
  7. package/node_modules/@aashutoshrathi/word-wrap/package.json +0 -81
  8. package/node_modules/@angular-eslint/bundled-angular-compiler/README.md +0 -1
  9. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.d.ts +0 -5
  10. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.js +0 -32004
  11. package/node_modules/@angular-eslint/bundled-angular-compiler/package.json +0 -19
  12. package/node_modules/@angular-eslint/template-parser/LICENSE +0 -21
  13. package/node_modules/@angular-eslint/template-parser/README.md +0 -1
  14. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.d.ts +0 -6
  15. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.js +0 -69
  16. package/node_modules/@angular-eslint/template-parser/dist/index.d.ts +0 -44
  17. package/node_modules/@angular-eslint/template-parser/dist/index.js +0 -219
  18. package/node_modules/@angular-eslint/template-parser/package.json +0 -28
  19. package/node_modules/@eslint/eslintrc/LICENSE +0 -19
  20. package/node_modules/@eslint/eslintrc/README.md +0 -115
  21. package/node_modules/@eslint/eslintrc/conf/config-schema.js +0 -79
  22. package/node_modules/@eslint/eslintrc/conf/environments.js +0 -215
  23. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +0 -1104
  24. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +0 -1
  25. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +0 -4333
  26. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +0 -1
  27. package/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +0 -532
  28. package/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +0 -523
  29. package/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +0 -115
  30. package/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +0 -145
  31. package/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +0 -238
  32. package/node_modules/@eslint/eslintrc/lib/config-array/index.js +0 -19
  33. package/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +0 -225
  34. package/node_modules/@eslint/eslintrc/lib/config-array-factory.js +0 -1149
  35. package/node_modules/@eslint/eslintrc/lib/flat-compat.js +0 -318
  36. package/node_modules/@eslint/eslintrc/lib/index-universal.js +0 -29
  37. package/node_modules/@eslint/eslintrc/lib/index.js +0 -56
  38. package/node_modules/@eslint/eslintrc/lib/shared/ajv.js +0 -191
  39. package/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +0 -135
  40. package/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +0 -325
  41. package/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +0 -63
  42. package/node_modules/@eslint/eslintrc/lib/shared/naming.js +0 -96
  43. package/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +0 -42
  44. package/node_modules/@eslint/eslintrc/lib/shared/types.js +0 -149
  45. package/node_modules/@eslint/eslintrc/package.json +0 -82
  46. package/node_modules/@eslint/eslintrc/universal.js +0 -9
  47. package/node_modules/@eslint/js/LICENSE +0 -19
  48. package/node_modules/@eslint/js/README.md +0 -57
  49. package/node_modules/@eslint/js/package.json +0 -31
  50. package/node_modules/@eslint/js/src/configs/eslint-all.js +0 -211
  51. package/node_modules/@eslint/js/src/configs/eslint-recommended.js +0 -76
  52. package/node_modules/@eslint/js/src/index.js +0 -17
  53. package/node_modules/@eslint-community/eslint-utils/LICENSE +0 -21
  54. package/node_modules/@eslint-community/eslint-utils/README.md +0 -37
  55. package/node_modules/@eslint-community/eslint-utils/index.js +0 -2068
  56. package/node_modules/@eslint-community/eslint-utils/index.js.map +0 -1
  57. package/node_modules/@eslint-community/eslint-utils/index.mjs +0 -2027
  58. package/node_modules/@eslint-community/eslint-utils/index.mjs.map +0 -1
  59. package/node_modules/@eslint-community/eslint-utils/package.json +0 -73
  60. package/node_modules/@eslint-community/regexpp/LICENSE +0 -21
  61. package/node_modules/@eslint-community/regexpp/README.md +0 -177
  62. package/node_modules/@eslint-community/regexpp/index.d.ts +0 -1065
  63. package/node_modules/@eslint-community/regexpp/index.js +0 -2747
  64. package/node_modules/@eslint-community/regexpp/index.js.map +0 -1
  65. package/node_modules/@eslint-community/regexpp/index.mjs +0 -2737
  66. package/node_modules/@eslint-community/regexpp/index.mjs.map +0 -1
  67. package/node_modules/@eslint-community/regexpp/package.json +0 -93
  68. package/node_modules/@humanwhocodes/config-array/LICENSE +0 -201
  69. package/node_modules/@humanwhocodes/config-array/README.md +0 -342
  70. package/node_modules/@humanwhocodes/config-array/api.js +0 -1061
  71. package/node_modules/@humanwhocodes/config-array/package.json +0 -61
  72. package/node_modules/@humanwhocodes/module-importer/CHANGELOG.md +0 -15
  73. package/node_modules/@humanwhocodes/module-importer/LICENSE +0 -201
  74. package/node_modules/@humanwhocodes/module-importer/README.md +0 -80
  75. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs +0 -22
  76. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts +0 -27
  77. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.ts +0 -2
  78. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.js +0 -18
  79. package/node_modules/@humanwhocodes/module-importer/package.json +0 -65
  80. package/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs +0 -81
  81. package/node_modules/@humanwhocodes/module-importer/src/module-importer.js +0 -22
  82. package/node_modules/@humanwhocodes/object-schema/.eslintrc.js +0 -29
  83. package/node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml +0 -27
  84. package/node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml +0 -39
  85. package/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +0 -26
  86. package/node_modules/@humanwhocodes/object-schema/LICENSE +0 -29
  87. package/node_modules/@humanwhocodes/object-schema/README.md +0 -234
  88. package/node_modules/@humanwhocodes/object-schema/package.json +0 -33
  89. package/node_modules/@humanwhocodes/object-schema/src/index.js +0 -7
  90. package/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +0 -53
  91. package/node_modules/@humanwhocodes/object-schema/src/object-schema.js +0 -301
  92. package/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +0 -102
  93. package/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +0 -66
  94. package/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +0 -659
  95. package/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +0 -186
  96. package/node_modules/@nodelib/fs.scandir/LICENSE +0 -21
  97. package/node_modules/@nodelib/fs.scandir/README.md +0 -171
  98. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +0 -20
  99. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +0 -19
  100. package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +0 -4
  101. package/node_modules/@nodelib/fs.scandir/out/constants.js +0 -17
  102. package/node_modules/@nodelib/fs.scandir/out/index.d.ts +0 -12
  103. package/node_modules/@nodelib/fs.scandir/out/index.js +0 -26
  104. package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +0 -7
  105. package/node_modules/@nodelib/fs.scandir/out/providers/async.js +0 -104
  106. package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +0 -1
  107. package/node_modules/@nodelib/fs.scandir/out/providers/common.js +0 -13
  108. package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +0 -5
  109. package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +0 -54
  110. package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +0 -20
  111. package/node_modules/@nodelib/fs.scandir/out/settings.js +0 -24
  112. package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +0 -20
  113. package/node_modules/@nodelib/fs.scandir/out/types/index.js +0 -2
  114. package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +0 -2
  115. package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +0 -19
  116. package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +0 -2
  117. package/node_modules/@nodelib/fs.scandir/out/utils/index.js +0 -5
  118. package/node_modules/@nodelib/fs.scandir/package.json +0 -44
  119. package/node_modules/@nodelib/fs.stat/LICENSE +0 -21
  120. package/node_modules/@nodelib/fs.stat/README.md +0 -126
  121. package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +0 -13
  122. package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +0 -17
  123. package/node_modules/@nodelib/fs.stat/out/index.d.ts +0 -12
  124. package/node_modules/@nodelib/fs.stat/out/index.js +0 -26
  125. package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +0 -4
  126. package/node_modules/@nodelib/fs.stat/out/providers/async.js +0 -36
  127. package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +0 -3
  128. package/node_modules/@nodelib/fs.stat/out/providers/sync.js +0 -23
  129. package/node_modules/@nodelib/fs.stat/out/settings.d.ts +0 -16
  130. package/node_modules/@nodelib/fs.stat/out/settings.js +0 -16
  131. package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +0 -4
  132. package/node_modules/@nodelib/fs.stat/out/types/index.js +0 -2
  133. package/node_modules/@nodelib/fs.stat/package.json +0 -37
  134. package/node_modules/@nodelib/fs.walk/LICENSE +0 -21
  135. package/node_modules/@nodelib/fs.walk/README.md +0 -215
  136. package/node_modules/@nodelib/fs.walk/out/index.d.ts +0 -14
  137. package/node_modules/@nodelib/fs.walk/out/index.js +0 -34
  138. package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +0 -12
  139. package/node_modules/@nodelib/fs.walk/out/providers/async.js +0 -30
  140. package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +0 -4
  141. package/node_modules/@nodelib/fs.walk/out/providers/index.js +0 -9
  142. package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +0 -12
  143. package/node_modules/@nodelib/fs.walk/out/providers/stream.js +0 -34
  144. package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +0 -10
  145. package/node_modules/@nodelib/fs.walk/out/providers/sync.js +0 -14
  146. package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +0 -30
  147. package/node_modules/@nodelib/fs.walk/out/readers/async.js +0 -97
  148. package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +0 -7
  149. package/node_modules/@nodelib/fs.walk/out/readers/common.js +0 -31
  150. package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +0 -6
  151. package/node_modules/@nodelib/fs.walk/out/readers/reader.js +0 -11
  152. package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +0 -15
  153. package/node_modules/@nodelib/fs.walk/out/readers/sync.js +0 -59
  154. package/node_modules/@nodelib/fs.walk/out/settings.d.ts +0 -30
  155. package/node_modules/@nodelib/fs.walk/out/settings.js +0 -26
  156. package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +0 -8
  157. package/node_modules/@nodelib/fs.walk/out/types/index.js +0 -2
  158. package/node_modules/@nodelib/fs.walk/package.json +0 -44
  159. package/node_modules/@ungap/structured-clone/.github/workflows/node.js.yml +0 -31
  160. package/node_modules/@ungap/structured-clone/LICENSE +0 -15
  161. package/node_modules/@ungap/structured-clone/README.md +0 -95
  162. package/node_modules/@ungap/structured-clone/cjs/deserialize.js +0 -78
  163. package/node_modules/@ungap/structured-clone/cjs/index.js +0 -27
  164. package/node_modules/@ungap/structured-clone/cjs/json.js +0 -24
  165. package/node_modules/@ungap/structured-clone/cjs/package.json +0 -1
  166. package/node_modules/@ungap/structured-clone/cjs/serialize.js +0 -160
  167. package/node_modules/@ungap/structured-clone/cjs/types.js +0 -22
  168. package/node_modules/@ungap/structured-clone/esm/deserialize.js +0 -79
  169. package/node_modules/@ungap/structured-clone/esm/index.js +0 -25
  170. package/node_modules/@ungap/structured-clone/esm/json.js +0 -21
  171. package/node_modules/@ungap/structured-clone/esm/serialize.js +0 -161
  172. package/node_modules/@ungap/structured-clone/esm/types.js +0 -11
  173. package/node_modules/@ungap/structured-clone/package.json +0 -53
  174. package/node_modules/@ungap/structured-clone/structured-json.js +0 -1
@@ -1,145 +0,0 @@
1
- /**
2
- * @fileoverview `ExtractedConfig` class.
3
- *
4
- * `ExtractedConfig` class expresses a final configuration for a specific file.
5
- *
6
- * It provides one method.
7
- *
8
- * - `toCompatibleObjectAsConfigFileContent()`
9
- * Convert this configuration to the compatible object as the content of
10
- * config files. It converts the loaded parser and plugins to strings.
11
- * `CLIEngine#getConfigForFile(filePath)` method uses this method.
12
- *
13
- * `ConfigArray#extractConfig(filePath)` creates a `ExtractedConfig` instance.
14
- *
15
- * @author Toru Nagashima <https://github.com/mysticatea>
16
- */
17
-
18
- import { IgnorePattern } from "./ignore-pattern.js";
19
-
20
- // For VSCode intellisense
21
- /** @typedef {import("../../shared/types").ConfigData} ConfigData */
22
- /** @typedef {import("../../shared/types").GlobalConf} GlobalConf */
23
- /** @typedef {import("../../shared/types").SeverityConf} SeverityConf */
24
- /** @typedef {import("./config-dependency").DependentParser} DependentParser */
25
- /** @typedef {import("./config-dependency").DependentPlugin} DependentPlugin */
26
-
27
- /**
28
- * Check if `xs` starts with `ys`.
29
- * @template T
30
- * @param {T[]} xs The array to check.
31
- * @param {T[]} ys The array that may be the first part of `xs`.
32
- * @returns {boolean} `true` if `xs` starts with `ys`.
33
- */
34
- function startsWith(xs, ys) {
35
- return xs.length >= ys.length && ys.every((y, i) => y === xs[i]);
36
- }
37
-
38
- /**
39
- * The class for extracted config data.
40
- */
41
- class ExtractedConfig {
42
- constructor() {
43
-
44
- /**
45
- * The config name what `noInlineConfig` setting came from.
46
- * @type {string}
47
- */
48
- this.configNameOfNoInlineConfig = "";
49
-
50
- /**
51
- * Environments.
52
- * @type {Record<string, boolean>}
53
- */
54
- this.env = {};
55
-
56
- /**
57
- * Global variables.
58
- * @type {Record<string, GlobalConf>}
59
- */
60
- this.globals = {};
61
-
62
- /**
63
- * The glob patterns that ignore to lint.
64
- * @type {(((filePath:string, dot?:boolean) => boolean) & { basePath:string; patterns:string[] }) | undefined}
65
- */
66
- this.ignores = void 0;
67
-
68
- /**
69
- * The flag that disables directive comments.
70
- * @type {boolean|undefined}
71
- */
72
- this.noInlineConfig = void 0;
73
-
74
- /**
75
- * Parser definition.
76
- * @type {DependentParser|null}
77
- */
78
- this.parser = null;
79
-
80
- /**
81
- * Options for the parser.
82
- * @type {Object}
83
- */
84
- this.parserOptions = {};
85
-
86
- /**
87
- * Plugin definitions.
88
- * @type {Record<string, DependentPlugin>}
89
- */
90
- this.plugins = {};
91
-
92
- /**
93
- * Processor ID.
94
- * @type {string|null}
95
- */
96
- this.processor = null;
97
-
98
- /**
99
- * The flag that reports unused `eslint-disable` directive comments.
100
- * @type {boolean|undefined}
101
- */
102
- this.reportUnusedDisableDirectives = void 0;
103
-
104
- /**
105
- * Rule settings.
106
- * @type {Record<string, [SeverityConf, ...any[]]>}
107
- */
108
- this.rules = {};
109
-
110
- /**
111
- * Shared settings.
112
- * @type {Object}
113
- */
114
- this.settings = {};
115
- }
116
-
117
- /**
118
- * Convert this config to the compatible object as a config file content.
119
- * @returns {ConfigData} The converted object.
120
- */
121
- toCompatibleObjectAsConfigFileContent() {
122
- const {
123
- /* eslint-disable no-unused-vars */
124
- configNameOfNoInlineConfig: _ignore1,
125
- processor: _ignore2,
126
- /* eslint-enable no-unused-vars */
127
- ignores,
128
- ...config
129
- } = this;
130
-
131
- config.parser = config.parser && config.parser.filePath;
132
- config.plugins = Object.keys(config.plugins).filter(Boolean).reverse();
133
- config.ignorePatterns = ignores ? ignores.patterns : [];
134
-
135
- // Strip the default patterns from `ignorePatterns`.
136
- if (startsWith(config.ignorePatterns, IgnorePattern.DefaultPatterns)) {
137
- config.ignorePatterns =
138
- config.ignorePatterns.slice(IgnorePattern.DefaultPatterns.length);
139
- }
140
-
141
- return config;
142
- }
143
- }
144
-
145
- export { ExtractedConfig };
@@ -1,238 +0,0 @@
1
- /**
2
- * @fileoverview `IgnorePattern` class.
3
- *
4
- * `IgnorePattern` class has the set of glob patterns and the base path.
5
- *
6
- * It provides two static methods.
7
- *
8
- * - `IgnorePattern.createDefaultIgnore(cwd)`
9
- * Create the default predicate function.
10
- * - `IgnorePattern.createIgnore(ignorePatterns)`
11
- * Create the predicate function from multiple `IgnorePattern` objects.
12
- *
13
- * It provides two properties and a method.
14
- *
15
- * - `patterns`
16
- * The glob patterns that ignore to lint.
17
- * - `basePath`
18
- * The base path of the glob patterns. If absolute paths existed in the
19
- * glob patterns, those are handled as relative paths to the base path.
20
- * - `getPatternsRelativeTo(basePath)`
21
- * Get `patterns` as modified for a given base path. It modifies the
22
- * absolute paths in the patterns as prepending the difference of two base
23
- * paths.
24
- *
25
- * `ConfigArrayFactory` creates `IgnorePattern` objects when it processes
26
- * `ignorePatterns` properties.
27
- *
28
- * @author Toru Nagashima <https://github.com/mysticatea>
29
- */
30
-
31
- //------------------------------------------------------------------------------
32
- // Requirements
33
- //------------------------------------------------------------------------------
34
-
35
- import assert from "assert";
36
- import path from "path";
37
- import ignore from "ignore";
38
- import debugOrig from "debug";
39
-
40
- const debug = debugOrig("eslintrc:ignore-pattern");
41
-
42
- /** @typedef {ReturnType<import("ignore").default>} Ignore */
43
-
44
- //------------------------------------------------------------------------------
45
- // Helpers
46
- //------------------------------------------------------------------------------
47
-
48
- /**
49
- * Get the path to the common ancestor directory of given paths.
50
- * @param {string[]} sourcePaths The paths to calculate the common ancestor.
51
- * @returns {string} The path to the common ancestor directory.
52
- */
53
- function getCommonAncestorPath(sourcePaths) {
54
- let result = sourcePaths[0];
55
-
56
- for (let i = 1; i < sourcePaths.length; ++i) {
57
- const a = result;
58
- const b = sourcePaths[i];
59
-
60
- // Set the shorter one (it's the common ancestor if one includes the other).
61
- result = a.length < b.length ? a : b;
62
-
63
- // Set the common ancestor.
64
- for (let j = 0, lastSepPos = 0; j < a.length && j < b.length; ++j) {
65
- if (a[j] !== b[j]) {
66
- result = a.slice(0, lastSepPos);
67
- break;
68
- }
69
- if (a[j] === path.sep) {
70
- lastSepPos = j;
71
- }
72
- }
73
- }
74
-
75
- let resolvedResult = result || path.sep;
76
-
77
- // if Windows common ancestor is root of drive must have trailing slash to be absolute.
78
- if (resolvedResult && resolvedResult.endsWith(":") && process.platform === "win32") {
79
- resolvedResult += path.sep;
80
- }
81
- return resolvedResult;
82
- }
83
-
84
- /**
85
- * Make relative path.
86
- * @param {string} from The source path to get relative path.
87
- * @param {string} to The destination path to get relative path.
88
- * @returns {string} The relative path.
89
- */
90
- function relative(from, to) {
91
- const relPath = path.relative(from, to);
92
-
93
- if (path.sep === "/") {
94
- return relPath;
95
- }
96
- return relPath.split(path.sep).join("/");
97
- }
98
-
99
- /**
100
- * Get the trailing slash if existed.
101
- * @param {string} filePath The path to check.
102
- * @returns {string} The trailing slash if existed.
103
- */
104
- function dirSuffix(filePath) {
105
- const isDir = (
106
- filePath.endsWith(path.sep) ||
107
- (process.platform === "win32" && filePath.endsWith("/"))
108
- );
109
-
110
- return isDir ? "/" : "";
111
- }
112
-
113
- const DefaultPatterns = Object.freeze(["/**/node_modules/*"]);
114
- const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]);
115
-
116
- //------------------------------------------------------------------------------
117
- // Public
118
- //------------------------------------------------------------------------------
119
-
120
- class IgnorePattern {
121
-
122
- /**
123
- * The default patterns.
124
- * @type {string[]}
125
- */
126
- static get DefaultPatterns() {
127
- return DefaultPatterns;
128
- }
129
-
130
- /**
131
- * Create the default predicate function.
132
- * @param {string} cwd The current working directory.
133
- * @returns {((filePath:string, dot:boolean) => boolean) & {basePath:string; patterns:string[]}}
134
- * The preficate function.
135
- * The first argument is an absolute path that is checked.
136
- * The second argument is the flag to not ignore dotfiles.
137
- * If the predicate function returned `true`, it means the path should be ignored.
138
- */
139
- static createDefaultIgnore(cwd) {
140
- return this.createIgnore([new IgnorePattern(DefaultPatterns, cwd)]);
141
- }
142
-
143
- /**
144
- * Create the predicate function from multiple `IgnorePattern` objects.
145
- * @param {IgnorePattern[]} ignorePatterns The list of ignore patterns.
146
- * @returns {((filePath:string, dot?:boolean) => boolean) & {basePath:string; patterns:string[]}}
147
- * The preficate function.
148
- * The first argument is an absolute path that is checked.
149
- * The second argument is the flag to not ignore dotfiles.
150
- * If the predicate function returned `true`, it means the path should be ignored.
151
- */
152
- static createIgnore(ignorePatterns) {
153
- debug("Create with: %o", ignorePatterns);
154
-
155
- const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath));
156
- const patterns = [].concat(
157
- ...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath))
158
- );
159
- const ig = ignore({ allowRelativePaths: true }).add([...DotPatterns, ...patterns]);
160
- const dotIg = ignore({ allowRelativePaths: true }).add(patterns);
161
-
162
- debug(" processed: %o", { basePath, patterns });
163
-
164
- return Object.assign(
165
- (filePath, dot = false) => {
166
- assert(path.isAbsolute(filePath), "'filePath' should be an absolute path.");
167
- const relPathRaw = relative(basePath, filePath);
168
- const relPath = relPathRaw && (relPathRaw + dirSuffix(filePath));
169
- const adoptedIg = dot ? dotIg : ig;
170
- const result = relPath !== "" && adoptedIg.ignores(relPath);
171
-
172
- debug("Check", { filePath, dot, relativePath: relPath, result });
173
- return result;
174
- },
175
- { basePath, patterns }
176
- );
177
- }
178
-
179
- /**
180
- * Initialize a new `IgnorePattern` instance.
181
- * @param {string[]} patterns The glob patterns that ignore to lint.
182
- * @param {string} basePath The base path of `patterns`.
183
- */
184
- constructor(patterns, basePath) {
185
- assert(path.isAbsolute(basePath), "'basePath' should be an absolute path.");
186
-
187
- /**
188
- * The glob patterns that ignore to lint.
189
- * @type {string[]}
190
- */
191
- this.patterns = patterns;
192
-
193
- /**
194
- * The base path of `patterns`.
195
- * @type {string}
196
- */
197
- this.basePath = basePath;
198
-
199
- /**
200
- * If `true` then patterns which don't start with `/` will match the paths to the outside of `basePath`. Defaults to `false`.
201
- *
202
- * It's set `true` for `.eslintignore`, `package.json`, and `--ignore-path` for backward compatibility.
203
- * It's `false` as-is for `ignorePatterns` property in config files.
204
- * @type {boolean}
205
- */
206
- this.loose = false;
207
- }
208
-
209
- /**
210
- * Get `patterns` as modified for a given base path. It modifies the
211
- * absolute paths in the patterns as prepending the difference of two base
212
- * paths.
213
- * @param {string} newBasePath The base path.
214
- * @returns {string[]} Modifired patterns.
215
- */
216
- getPatternsRelativeTo(newBasePath) {
217
- assert(path.isAbsolute(newBasePath), "'newBasePath' should be an absolute path.");
218
- const { basePath, loose, patterns } = this;
219
-
220
- if (newBasePath === basePath) {
221
- return patterns;
222
- }
223
- const prefix = `/${relative(newBasePath, basePath)}`;
224
-
225
- return patterns.map(pattern => {
226
- const negative = pattern.startsWith("!");
227
- const head = negative ? "!" : "";
228
- const body = negative ? pattern.slice(1) : pattern;
229
-
230
- if (body.startsWith("/") || body.startsWith("../")) {
231
- return `${head}${prefix}${body}`;
232
- }
233
- return loose ? pattern : `${head}${prefix}/**/${body}`;
234
- });
235
- }
236
- }
237
-
238
- export { IgnorePattern };
@@ -1,19 +0,0 @@
1
- /**
2
- * @fileoverview `ConfigArray` class.
3
- * @author Toru Nagashima <https://github.com/mysticatea>
4
- */
5
-
6
- import { ConfigArray, getUsedExtractedConfigs } from "./config-array.js";
7
- import { ConfigDependency } from "./config-dependency.js";
8
- import { ExtractedConfig } from "./extracted-config.js";
9
- import { IgnorePattern } from "./ignore-pattern.js";
10
- import { OverrideTester } from "./override-tester.js";
11
-
12
- export {
13
- ConfigArray,
14
- ConfigDependency,
15
- ExtractedConfig,
16
- IgnorePattern,
17
- OverrideTester,
18
- getUsedExtractedConfigs
19
- };
@@ -1,225 +0,0 @@
1
- /**
2
- * @fileoverview `OverrideTester` class.
3
- *
4
- * `OverrideTester` class handles `files` property and `excludedFiles` property
5
- * of `overrides` config.
6
- *
7
- * It provides one method.
8
- *
9
- * - `test(filePath)`
10
- * Test if a file path matches the pair of `files` property and
11
- * `excludedFiles` property. The `filePath` argument must be an absolute
12
- * path.
13
- *
14
- * `ConfigArrayFactory` creates `OverrideTester` objects when it processes
15
- * `overrides` properties.
16
- *
17
- * @author Toru Nagashima <https://github.com/mysticatea>
18
- */
19
-
20
- import assert from "assert";
21
- import path from "path";
22
- import util from "util";
23
- import minimatch from "minimatch";
24
-
25
- const { Minimatch } = minimatch;
26
-
27
- const minimatchOpts = { dot: true, matchBase: true };
28
-
29
- /**
30
- * @typedef {Object} Pattern
31
- * @property {InstanceType<Minimatch>[] | null} includes The positive matchers.
32
- * @property {InstanceType<Minimatch>[] | null} excludes The negative matchers.
33
- */
34
-
35
- /**
36
- * Normalize a given pattern to an array.
37
- * @param {string|string[]|undefined} patterns A glob pattern or an array of glob patterns.
38
- * @returns {string[]|null} Normalized patterns.
39
- * @private
40
- */
41
- function normalizePatterns(patterns) {
42
- if (Array.isArray(patterns)) {
43
- return patterns.filter(Boolean);
44
- }
45
- if (typeof patterns === "string" && patterns) {
46
- return [patterns];
47
- }
48
- return [];
49
- }
50
-
51
- /**
52
- * Create the matchers of given patterns.
53
- * @param {string[]} patterns The patterns.
54
- * @returns {InstanceType<Minimatch>[] | null} The matchers.
55
- */
56
- function toMatcher(patterns) {
57
- if (patterns.length === 0) {
58
- return null;
59
- }
60
- return patterns.map(pattern => {
61
- if (/^\.[/\\]/u.test(pattern)) {
62
- return new Minimatch(
63
- pattern.slice(2),
64
-
65
- // `./*.js` should not match with `subdir/foo.js`
66
- { ...minimatchOpts, matchBase: false }
67
- );
68
- }
69
- return new Minimatch(pattern, minimatchOpts);
70
- });
71
- }
72
-
73
- /**
74
- * Convert a given matcher to string.
75
- * @param {Pattern} matchers The matchers.
76
- * @returns {string} The string expression of the matcher.
77
- */
78
- function patternToJson({ includes, excludes }) {
79
- return {
80
- includes: includes && includes.map(m => m.pattern),
81
- excludes: excludes && excludes.map(m => m.pattern)
82
- };
83
- }
84
-
85
- /**
86
- * The class to test given paths are matched by the patterns.
87
- */
88
- class OverrideTester {
89
-
90
- /**
91
- * Create a tester with given criteria.
92
- * If there are no criteria, returns `null`.
93
- * @param {string|string[]} files The glob patterns for included files.
94
- * @param {string|string[]} excludedFiles The glob patterns for excluded files.
95
- * @param {string} basePath The path to the base directory to test paths.
96
- * @returns {OverrideTester|null} The created instance or `null`.
97
- */
98
- static create(files, excludedFiles, basePath) {
99
- const includePatterns = normalizePatterns(files);
100
- const excludePatterns = normalizePatterns(excludedFiles);
101
- let endsWithWildcard = false;
102
-
103
- if (includePatterns.length === 0) {
104
- return null;
105
- }
106
-
107
- // Rejects absolute paths or relative paths to parents.
108
- for (const pattern of includePatterns) {
109
- if (path.isAbsolute(pattern) || pattern.includes("..")) {
110
- throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`);
111
- }
112
- if (pattern.endsWith("*")) {
113
- endsWithWildcard = true;
114
- }
115
- }
116
- for (const pattern of excludePatterns) {
117
- if (path.isAbsolute(pattern) || pattern.includes("..")) {
118
- throw new Error(`Invalid override pattern (expected relative path not containing '..'): ${pattern}`);
119
- }
120
- }
121
-
122
- const includes = toMatcher(includePatterns);
123
- const excludes = toMatcher(excludePatterns);
124
-
125
- return new OverrideTester(
126
- [{ includes, excludes }],
127
- basePath,
128
- endsWithWildcard
129
- );
130
- }
131
-
132
- /**
133
- * Combine two testers by logical and.
134
- * If either of the testers was `null`, returns the other tester.
135
- * The `basePath` property of the two must be the same value.
136
- * @param {OverrideTester|null} a A tester.
137
- * @param {OverrideTester|null} b Another tester.
138
- * @returns {OverrideTester|null} Combined tester.
139
- */
140
- static and(a, b) {
141
- if (!b) {
142
- return a && new OverrideTester(
143
- a.patterns,
144
- a.basePath,
145
- a.endsWithWildcard
146
- );
147
- }
148
- if (!a) {
149
- return new OverrideTester(
150
- b.patterns,
151
- b.basePath,
152
- b.endsWithWildcard
153
- );
154
- }
155
-
156
- assert.strictEqual(a.basePath, b.basePath);
157
- return new OverrideTester(
158
- a.patterns.concat(b.patterns),
159
- a.basePath,
160
- a.endsWithWildcard || b.endsWithWildcard
161
- );
162
- }
163
-
164
- /**
165
- * Initialize this instance.
166
- * @param {Pattern[]} patterns The matchers.
167
- * @param {string} basePath The base path.
168
- * @param {boolean} endsWithWildcard If `true` then a pattern ends with `*`.
169
- */
170
- constructor(patterns, basePath, endsWithWildcard = false) {
171
-
172
- /** @type {Pattern[]} */
173
- this.patterns = patterns;
174
-
175
- /** @type {string} */
176
- this.basePath = basePath;
177
-
178
- /** @type {boolean} */
179
- this.endsWithWildcard = endsWithWildcard;
180
- }
181
-
182
- /**
183
- * Test if a given path is matched or not.
184
- * @param {string} filePath The absolute path to the target file.
185
- * @returns {boolean} `true` if the path was matched.
186
- */
187
- test(filePath) {
188
- if (typeof filePath !== "string" || !path.isAbsolute(filePath)) {
189
- throw new Error(`'filePath' should be an absolute path, but got ${filePath}.`);
190
- }
191
- const relativePath = path.relative(this.basePath, filePath);
192
-
193
- return this.patterns.every(({ includes, excludes }) => (
194
- (!includes || includes.some(m => m.match(relativePath))) &&
195
- (!excludes || !excludes.some(m => m.match(relativePath)))
196
- ));
197
- }
198
-
199
- // eslint-disable-next-line jsdoc/require-description
200
- /**
201
- * @returns {Object} a JSON compatible object.
202
- */
203
- toJSON() {
204
- if (this.patterns.length === 1) {
205
- return {
206
- ...patternToJson(this.patterns[0]),
207
- basePath: this.basePath
208
- };
209
- }
210
- return {
211
- AND: this.patterns.map(patternToJson),
212
- basePath: this.basePath
213
- };
214
- }
215
-
216
- // eslint-disable-next-line jsdoc/require-description
217
- /**
218
- * @returns {Object} an object to display by `console.log()`.
219
- */
220
- [util.inspect.custom]() {
221
- return this.toJSON();
222
- }
223
- }
224
-
225
- export { OverrideTester };