@markuplint/file-resolver 3.3.1 → 3.4.0

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.
@@ -39,7 +39,7 @@ class ConfigProvider {
39
39
  switch (prefix) {
40
40
  case 'plugin:': {
41
41
  const plugin = plugins.find(plugin => plugin.name === namespace);
42
- const config = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _a === void 0 ? void 0 : _a[name];
42
+ const config = name && ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _a === void 0 ? void 0 : _a[name]);
43
43
  if (config) {
44
44
  this.set(config, held);
45
45
  }
@@ -56,9 +56,10 @@ class ConfigProvider {
56
56
  const globs = Object.keys(overrides);
57
57
  for (const glob of globs) {
58
58
  const isMatched = targetFile.matches(glob);
59
- if (isMatched) {
59
+ const config = overrides[glob];
60
+ if (isMatched && config) {
60
61
  // Note: Original config disappears
61
- configSet.config = overrides[glob];
62
+ configSet.config = config;
62
63
  }
63
64
  }
64
65
  }
@@ -94,7 +95,7 @@ class ConfigProvider {
94
95
  }
95
96
  if (isPreset(filePath)) {
96
97
  const [, name] = filePath.match(/^markuplint:(.+)$/i) || [];
97
- const config = await (0, ml_core_1.getPreset)(name);
98
+ const config = await (0, ml_core_1.getPreset)(name !== null && name !== void 0 ? name : filePath);
98
99
  const pathResolvedConfig = this._pathResolve(config, filePath);
99
100
  tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").set(filePath, pathResolvedConfig);
100
101
  return pathResolvedConfig;
@@ -16,7 +16,11 @@ async function resolveParser(file, parserConfig, parserOptions) {
16
16
  if (parserConfig) {
17
17
  for (const pattern of Object.keys(parserConfig)) {
18
18
  if (path_1.default.basename(file.path).match((0, utils_1.toRegexp)(pattern))) {
19
- parserModName = parserConfig[pattern];
19
+ const modName = parserConfig[pattern];
20
+ if (!modName) {
21
+ continue;
22
+ }
23
+ parserModName = modName;
20
24
  matched = true;
21
25
  break;
22
26
  }
@@ -53,6 +53,9 @@ async function resolveSpecs(filePath, specConfig) {
53
53
  for (const pattern of Object.keys(specConfig)) {
54
54
  if (path_1.default.basename(filePath).match((0, utils_1.toRegexp)(pattern))) {
55
55
  const specModName = specConfig[pattern];
56
+ if (!specModName) {
57
+ continue;
58
+ }
56
59
  const spec = await importSpecs(specModName);
57
60
  extendedSpecs.push(spec);
58
61
  }
package/lib/utils.js CHANGED
@@ -20,7 +20,7 @@ function fileExists(filePath) {
20
20
  exports.fileExists = fileExists;
21
21
  function toRegexp(pattern) {
22
22
  const matched = pattern.match(/^\/(.+)\/([ig]*)$/i);
23
- if (matched) {
23
+ if (matched && matched[1]) {
24
24
  return new RegExp(matched[1], matched[2]);
25
25
  }
26
26
  return pattern;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/file-resolver",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
4
4
  "description": "The file resolver of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -24,16 +24,16 @@
24
24
  "@types/node": "latest"
25
25
  },
26
26
  "dependencies": {
27
- "@markuplint/html-parser": "3.3.1",
27
+ "@markuplint/html-parser": "3.4.0",
28
28
  "@markuplint/ml-ast": "3.0.0",
29
- "@markuplint/ml-config": "3.3.0",
30
- "@markuplint/ml-core": "3.3.1",
31
- "@markuplint/ml-spec": "3.3.0",
29
+ "@markuplint/ml-config": "3.4.0",
30
+ "@markuplint/ml-core": "3.4.0",
31
+ "@markuplint/ml-spec": "3.4.0",
32
32
  "cosmiconfig": "^8.0.0",
33
33
  "glob": "^8.0.3",
34
34
  "jsonc": "^2.0.0",
35
35
  "minimatch": "^5.1.1",
36
36
  "tslib": "^2.4.1"
37
37
  },
38
- "gitHead": "f19e7de726cf01d53342bc5513c30da75d28da63"
38
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
39
39
  }