@tsslint/config 2.0.2 → 2.0.3

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from '@tsslint/types';
2
+ export { create as createCategoryPlugin } from './lib/plugins/category.js';
2
3
  export { create as createDiagnosticsPlugin } from './lib/plugins/diagnostics.js';
3
4
  export { create as createIgnorePlugin } from './lib/plugins/ignore.js';
4
5
  import type { Config, Plugin, Rule } from '@tsslint/types';
package/index.js CHANGED
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createIgnorePlugin = exports.createDiagnosticsPlugin = void 0;
17
+ exports.createIgnorePlugin = exports.createDiagnosticsPlugin = exports.createCategoryPlugin = void 0;
18
18
  exports.defineRule = defineRule;
19
19
  exports.definePlugin = definePlugin;
20
20
  exports.defineConfig = defineConfig;
21
21
  exports.isCLI = isCLI;
22
22
  __exportStar(require("@tsslint/types"), exports);
23
+ var category_js_1 = require("./lib/plugins/category.js");
24
+ Object.defineProperty(exports, "createCategoryPlugin", { enumerable: true, get: function () { return category_js_1.create; } });
23
25
  var diagnostics_js_1 = require("./lib/plugins/diagnostics.js");
24
26
  Object.defineProperty(exports, "createDiagnosticsPlugin", { enumerable: true, get: function () { return diagnostics_js_1.create; } });
25
27
  var ignore_js_1 = require("./lib/plugins/ignore.js");
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '@tsslint/types';
2
+ import type * as ts from 'typescript';
3
+ export declare function create(config: Record<string, ts.DiagnosticCategory>, source?: string): Plugin;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const minimatch = require("minimatch");
5
+ function create(config, source = 'tsslint') {
6
+ const matchCache = new Map();
7
+ return () => ({
8
+ resolveDiagnostics(_file, diagnostics) {
9
+ for (const diagnostic of diagnostics) {
10
+ if (diagnostic.source !== source) {
11
+ continue;
12
+ }
13
+ const category = match(diagnostic.code.toString());
14
+ if (category !== undefined) {
15
+ diagnostic.category = category;
16
+ }
17
+ }
18
+ return diagnostics;
19
+ }
20
+ });
21
+ function match(code) {
22
+ if (matchCache.has(code)) {
23
+ return matchCache.get(code);
24
+ }
25
+ for (const pattern in config) {
26
+ const category = config[pattern];
27
+ if (minimatch.minimatch(code, pattern, { dot: true })) {
28
+ matchCache.set(code, category);
29
+ return category;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ //# sourceMappingURL=category.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/config",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,8 +12,9 @@
12
12
  "directory": "packages/config"
13
13
  },
14
14
  "dependencies": {
15
- "@tsslint/types": "2.0.2",
15
+ "@tsslint/types": "2.0.3",
16
+ "minimatch": "^10.0.1",
16
17
  "ts-api-utils": "^2.0.0"
17
18
  },
18
- "gitHead": "3454b67099474212d2e6902c1b2c9292da080985"
19
+ "gitHead": "1950a26843ec8ca974ea4f10efa4b6ad36e2ffbf"
19
20
  }