@definitelytyped/dtslint 0.0.199 → 0.0.200

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.
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addSuggestion = void 0;
4
- const fs = require("fs");
5
- const os = require("os");
6
- const path = require("path");
7
- const suggestionsDir = path.join(os.homedir(), ".dts", "suggestions");
8
- // Packages for which suggestions were already added in this run of dtslint.
9
- const existingPackages = new Set();
10
- /**
11
- * A rule should call this function to provide a suggestion instead of a lint failure.
12
- */
13
- function addSuggestion(ctx, message, start, width) {
14
- const suggestion = {
15
- fileName: ctx.sourceFile.fileName,
16
- ruleName: ctx.ruleName,
17
- message,
18
- start,
19
- width,
20
- };
21
- const packageName = dtPackageName(ctx.sourceFile.fileName);
22
- if (!packageName) {
23
- return;
24
- }
25
- let flag = "a";
26
- if (!existingPackages.has(packageName)) {
27
- flag = "w";
28
- existingPackages.add(packageName);
29
- }
30
- try {
31
- if (!fs.existsSync(suggestionsDir)) {
32
- fs.mkdirSync(suggestionsDir, { recursive: true });
33
- }
34
- fs.writeFileSync(path.join(suggestionsDir, packageName + ".txt"), flag === "a" ? "\n" + formatSuggestion(suggestion) : formatSuggestion(suggestion), { flag, encoding: "utf8" });
35
- }
36
- catch (e) {
37
- console.log(`Could not write suggestions for package ${packageName}. ${e.message || ""}`);
38
- }
39
- }
40
- exports.addSuggestion = addSuggestion;
41
- const dtPath = path.join("DefinitelyTyped", "types");
42
- function dtPackageName(filePath) {
43
- const dtIndex = filePath.indexOf(dtPath);
44
- if (dtIndex === -1) {
45
- return undefined;
46
- }
47
- const basePath = filePath.substr(dtIndex + dtPath.length);
48
- const dirs = basePath.split(path.sep).filter((dir) => dir !== "");
49
- if (dirs.length === 0) {
50
- return undefined;
51
- }
52
- const packageName = dirs[0];
53
- // Check if this is an old version of a package.
54
- if (dirs.length > 1 && /^v\d+(\.\d+)?$/.test(dirs[1])) {
55
- return packageName + dirs[1];
56
- }
57
- return packageName;
58
- }
59
- function formatSuggestion(suggestion) {
60
- return JSON.stringify(suggestion, /*replacer*/ undefined, 0);
61
- }
62
- //# sourceMappingURL=suggestions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../src/suggestions.ts"],"names":[],"mappings":";;;AAAA,yBAA0B;AAC1B,yBAA0B;AAC1B,6BAA8B;AAG9B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AAUtE,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;AAEnC;;GAEG;AACH,SAAgB,aAAa,CAAI,GAAmB,EAAE,OAAe,EAAE,KAAc,EAAE,KAAc;IACnG,MAAM,UAAU,GAAe;QAC7B,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ;QACjC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,OAAO;QACP,KAAK;QACL,KAAK;KACN,CAAC;IAEF,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3D,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO;KACR;IACD,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;QACtC,IAAI,GAAG,GAAG,CAAC;QACX,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KACnC;IACD,IAAI;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;YAClC,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;SACnD;QACD,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,MAAM,CAAC,EAC/C,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,EACjF,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAC3B,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,2CAA2C,WAAW,KAAM,CAAW,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC;KACtG;AACH,CAAC;AA9BD,sCA8BC;AAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAErD,SAAS,aAAa,CAAC,QAAgB;IACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,CAAC,CAAC,EAAE;QAClB,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;IAClE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,gDAAgD;IAChD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACrD,OAAO,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KAC9B;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAsB;IAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,137 +0,0 @@
1
- # npm-naming
2
-
3
- (This rule is specific to DefinitelyTyped.)
4
-
5
- ## Name checks
6
- In 'name-only' mode, checks that the name of the type package matches a source package on npm.
7
-
8
- ---
9
-
10
- **Bad**:
11
-
12
- ```ts
13
- // Type definitions for browser-only-package 1.2
14
- ```
15
-
16
- * If the package is really browser-only, you have to mark it with "non-npm package".
17
- * If the package actually has a matching npm package, you must use that name.
18
-
19
- **Good**:
20
-
21
- ```ts
22
- // Type definitions for non-npm package browser-only-package 1.2
23
- ```
24
-
25
- ---
26
-
27
- **Bad**:
28
-
29
- ```ts
30
- // Type definitions for some-package 101.1
31
- ```
32
-
33
- * The version number in the header must actually exist on npm for the source package.
34
-
35
- **Good**:
36
-
37
- ```ts
38
- // Type definitions for some-package 10.1
39
- ```
40
-
41
- ## Code checks
42
-
43
- In 'code' mode, in addition to the name checks, this rule also checks that the source JavaScript code matches the declaration file for npm packages.
44
-
45
- ---
46
-
47
- **Bad**:
48
-
49
- `foo/index.d.ts`:
50
-
51
- ```ts
52
- declare function f(): void;
53
- export default f;
54
- ```
55
-
56
- `foo/index.js`:
57
-
58
- ```js
59
- module.exports = function () {
60
- };
61
- ```
62
-
63
- * A CommonJs module.exports assignment is not really an export default, and the d.ts should use the [`export =`](https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require) syntax.
64
- * `export default` can only be used to export a CommonJs `module.exports =` when you have `esModuleInterop` turned on, which not everybody does.
65
-
66
- **Good**:
67
-
68
- `foo/index.d.ts`:
69
-
70
- ```ts
71
- declare function f(): void;
72
- export = f;
73
- ```
74
-
75
- ---
76
-
77
- **Bad**:
78
-
79
- `foo/index.d.ts`:
80
-
81
- ```ts
82
- export class C {}
83
- ```
84
-
85
- `foo/index.js`:
86
-
87
- ```js
88
- module.exports = class C {}
89
- ```
90
-
91
- * The CommonJs module is a class, which means it can be constructed, like this:
92
- ```js
93
- var C = require('foo');
94
- var x = new C();
95
- ```
96
- However, the way `class C` is exported in the d.ts file (using an export declaration) means it can only be used like this:
97
- ```ts
98
- var foo = require('foo');
99
- var x = new foo.C();
100
- ```
101
-
102
- * The d.ts should use [`export =`](https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require)
103
- syntax to match the CommonJs module behavior.
104
-
105
- **Good**:
106
-
107
- `foo/index.d.ts`:
108
-
109
- ```ts
110
- declare class C {}
111
- export = C;
112
- ```
113
-
114
- * If you need to use `export =` syntax as in the example above, and the source JavaScript also exports some properties,
115
- you might need to use [*declaration merging*](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-namespaces-with-classes-functions-and-enums) in your d.ts. Example:
116
-
117
- **JavaScript**:
118
-
119
- `foo/index.js`:
120
-
121
- ```js
122
- function foo() {};
123
- foo.bar = "Exported property";
124
- module.exports = foo; // module.exports is a function, but it also has a property called `bar`
125
- ```
126
-
127
- **Declaration**:
128
-
129
- `foo/index.d.ts`:
130
-
131
- ```ts
132
- declare function foo(): void;
133
- declare namespace foo {
134
- var bar: string;
135
- }
136
- export = foo;
137
- ```
@@ -1,311 +0,0 @@
1
- import {
2
- CheckOptions as CriticOptions,
3
- CriticError,
4
- defaultErrors,
5
- dtsCritic as critic,
6
- ErrorKind,
7
- ExportErrorKind,
8
- Mode,
9
- parseExportErrorKind,
10
- parseMode,
11
- } from "@definitelytyped/dts-critic";
12
- import * as Lint from "tslint";
13
- import * as ts from "typescript";
14
-
15
- import { addSuggestion } from "../suggestions";
16
- import { failure, isMainFile } from "../util";
17
-
18
- /** Options as parsed from the rule configuration. */
19
- type ConfigOptions =
20
- | {
21
- mode: Mode.NameOnly;
22
- singleLine?: boolean;
23
- }
24
- | {
25
- mode: Mode.Code;
26
- errors: [ExportErrorKind, boolean][];
27
- singleLine?: boolean;
28
- };
29
-
30
- type Options = CriticOptions & { singleLine?: boolean };
31
-
32
- const defaultOptions: ConfigOptions = {
33
- mode: Mode.NameOnly,
34
- };
35
-
36
- export class Rule extends Lint.Rules.AbstractRule {
37
- static metadata: Lint.IRuleMetadata = {
38
- ruleName: "npm-naming",
39
- description: "Ensure that package name and DefinitelyTyped header match npm package info.",
40
- optionsDescription: `An object with a \`mode\` property should be provided.
41
- If \`mode\` is '${Mode.Code}', then option \`errors\` can be provided.
42
- \`errors\` should be an array specifying which code checks should be enabled or disabled.`,
43
- options: {
44
- oneOf: [
45
- {
46
- type: "object",
47
- properties: {
48
- mode: {
49
- type: "string",
50
- enum: [Mode.NameOnly],
51
- },
52
- "single-line": {
53
- description: "Whether to print error messages in a single line. Used for testing.",
54
- type: "boolean",
55
- },
56
- required: ["mode"],
57
- },
58
- },
59
- {
60
- type: "object",
61
- properties: {
62
- mode: {
63
- type: "string",
64
- enum: [Mode.Code],
65
- },
66
- errors: {
67
- type: "array",
68
- items: {
69
- type: "array",
70
- items: [
71
- {
72
- description: "Name of the check.",
73
- type: "string",
74
- enum: [ErrorKind.NeedsExportEquals, ErrorKind.NoDefaultExport] as ExportErrorKind[],
75
- },
76
- {
77
- description: "Whether the check is enabled or disabled.",
78
- type: "boolean",
79
- },
80
- ],
81
- minItems: 2,
82
- maxItems: 2,
83
- },
84
- default: [],
85
- },
86
- "single-line": {
87
- description: "Whether to print error messages in a single line. Used for testing.",
88
- type: "boolean",
89
- },
90
- required: ["mode"],
91
- },
92
- },
93
- ],
94
- },
95
- optionExamples: [
96
- true,
97
- [true, { mode: Mode.NameOnly }],
98
- [
99
- true,
100
- {
101
- mode: Mode.Code,
102
- errors: [
103
- [ErrorKind.NeedsExportEquals, true],
104
- [ErrorKind.NoDefaultExport, false],
105
- ],
106
- },
107
- ],
108
- ],
109
- type: "functionality",
110
- typescriptOnly: true,
111
- };
112
-
113
- apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
114
- return this.applyWithFunction(sourceFile, walk, toCriticOptions(parseOptions(this.ruleArguments)));
115
- }
116
- }
117
-
118
- function parseOptions(args: unknown[]): ConfigOptions {
119
- if (args.length === 0) {
120
- return defaultOptions;
121
- }
122
-
123
- const arg = args[0] as { [prop: string]: unknown } | null | undefined;
124
- // eslint-disable-next-line eqeqeq
125
- if (arg == null) {
126
- return defaultOptions;
127
- }
128
-
129
- if (!arg.mode || typeof arg.mode !== "string") {
130
- return defaultOptions;
131
- }
132
-
133
- const mode = parseMode(arg.mode);
134
- if (!mode) {
135
- return defaultOptions;
136
- }
137
-
138
- const singleLine = !!arg["single-line"];
139
-
140
- switch (mode) {
141
- case Mode.NameOnly:
142
- return { mode, singleLine };
143
- case Mode.Code:
144
- if (!arg.errors || !Array.isArray(arg.errors)) {
145
- return { mode, errors: [], singleLine };
146
- }
147
- return { mode, errors: parseEnabledErrors(arg.errors), singleLine };
148
- }
149
- }
150
-
151
- function parseEnabledErrors(errors: unknown[]): [ExportErrorKind, boolean][] {
152
- const enabledChecks: [ExportErrorKind, boolean][] = [];
153
- for (const tuple of errors) {
154
- if (Array.isArray(tuple) && tuple.length === 2 && typeof tuple[0] === "string" && typeof tuple[1] === "boolean") {
155
- const error = parseExportErrorKind(tuple[0]);
156
- if (error) {
157
- enabledChecks.push([error, tuple[1]]);
158
- }
159
- }
160
- }
161
- return enabledChecks;
162
- }
163
-
164
- function toCriticOptions(options: ConfigOptions): Options {
165
- switch (options.mode) {
166
- case Mode.NameOnly:
167
- return options;
168
- case Mode.Code:
169
- return { ...options, errors: new Map(options.errors) };
170
- }
171
- }
172
-
173
- function walk(ctx: Lint.WalkContext<CriticOptions>): void {
174
- const { sourceFile } = ctx;
175
- if (isMainFile(sourceFile.fileName, /*allowNested*/ false)) {
176
- try {
177
- const optionsWithSuggestions = toOptionsWithSuggestions(ctx.options);
178
- const diagnostics = critic(sourceFile.fileName, /* sourcePath */ undefined, optionsWithSuggestions);
179
- const errors = filterErrors(diagnostics, ctx);
180
- for (const error of errors) {
181
- switch (error.kind) {
182
- case ErrorKind.NoMatchingNpmPackage:
183
- case ErrorKind.NoMatchingNpmVersion:
184
- case ErrorKind.NonNpmHasMatchingPackage:
185
- case ErrorKind.DtsPropertyNotInJs:
186
- case ErrorKind.DtsSignatureNotInJs:
187
- case ErrorKind.JsPropertyNotInDts:
188
- case ErrorKind.JsSignatureNotInDts:
189
- case ErrorKind.NeedsExportEquals:
190
- case ErrorKind.NoDefaultExport:
191
- if (error.position) {
192
- ctx.addFailureAt(
193
- error.position.start,
194
- error.position.length,
195
- failure(Rule.metadata.ruleName, errorMessage(error, ctx.options)),
196
- );
197
- } else {
198
- ctx.addFailure(0, 1, failure(Rule.metadata.ruleName, errorMessage(error, ctx.options)));
199
- }
200
- break;
201
- }
202
- }
203
- } catch (e) {
204
- // We're ignoring exceptions.
205
- }
206
- }
207
- // Don't recur, we're done.
208
- }
209
-
210
- const enabledSuggestions: ExportErrorKind[] = [ErrorKind.JsPropertyNotInDts, ErrorKind.JsSignatureNotInDts];
211
-
212
- function toOptionsWithSuggestions(options: CriticOptions): CriticOptions {
213
- if (options.mode === Mode.NameOnly) {
214
- return options;
215
- }
216
- const optionsWithSuggestions = { mode: options.mode, errors: new Map(options.errors) };
217
- enabledSuggestions.forEach((err) => optionsWithSuggestions.errors.set(err, true));
218
- return optionsWithSuggestions;
219
- }
220
-
221
- function filterErrors(diagnostics: CriticError[], ctx: Lint.WalkContext<Options>): CriticError[] {
222
- const errors: CriticError[] = [];
223
- diagnostics.forEach((diagnostic) => {
224
- if (isSuggestion(diagnostic, ctx.options)) {
225
- addSuggestion(ctx, diagnostic.message, diagnostic.position?.start, diagnostic.position?.length);
226
- } else {
227
- errors.push(diagnostic);
228
- }
229
- });
230
- return errors;
231
- }
232
-
233
- function isSuggestion(diagnostic: CriticError, options: Options): boolean {
234
- return (
235
- options.mode === Mode.Code &&
236
- (enabledSuggestions as ErrorKind[]).includes(diagnostic.kind) &&
237
- !(options.errors as Map<ErrorKind, boolean>).get(diagnostic.kind)
238
- );
239
- }
240
-
241
- function tslintDisableOption(error: ErrorKind): string {
242
- switch (error) {
243
- case ErrorKind.NoMatchingNpmPackage:
244
- case ErrorKind.NoMatchingNpmVersion:
245
- case ErrorKind.NonNpmHasMatchingPackage:
246
- return `false`;
247
- case ErrorKind.NoDefaultExport:
248
- case ErrorKind.NeedsExportEquals:
249
- case ErrorKind.JsSignatureNotInDts:
250
- case ErrorKind.JsPropertyNotInDts:
251
- case ErrorKind.DtsSignatureNotInJs:
252
- case ErrorKind.DtsPropertyNotInJs:
253
- return JSON.stringify([true, { mode: Mode.Code, errors: [[error, false]] }]);
254
- }
255
- }
256
-
257
- function errorMessage(error: CriticError, opts: Options): string {
258
- const message =
259
- error.message +
260
- `\nIf you won't fix this error now or you think this error is wrong,
261
- you can disable this check by adding the following options to your project's tslint.json file under "rules":
262
-
263
- "npm-naming": ${tslintDisableOption(error.kind)}
264
- `;
265
- if (opts.singleLine) {
266
- return message.replace(/(\r\n|\n|\r|\t)/gm, " ");
267
- }
268
-
269
- return message;
270
- }
271
-
272
- /**
273
- * Given npm-naming lint failures, returns a rule configuration that prevents such failures.
274
- */
275
- export function disabler(failures: Lint.IRuleFailureJson[]): false | [true, ConfigOptions] {
276
- const disabledErrors = new Set<ExportErrorKind>();
277
- for (const ruleFailure of failures) {
278
- if (ruleFailure.ruleName !== "npm-naming") {
279
- throw new Error(`Expected failures of rule "npm-naming", found failures of rule ${ruleFailure.ruleName}.`);
280
- }
281
- const message = ruleFailure.failure;
282
- // Name errors.
283
- if (
284
- message.includes("must have a matching npm package") ||
285
- message.includes("must match a version that exists on npm") ||
286
- message.includes("conflicts with the existing npm package")
287
- ) {
288
- return false;
289
- }
290
- // Code errors.
291
- if (message.includes("declaration should use 'export =' syntax")) {
292
- disabledErrors.add(ErrorKind.NeedsExportEquals);
293
- } else if (
294
- message.includes(
295
- "declaration specifies 'export default' but the JavaScript source \
296
- does not mention 'default' anywhere",
297
- )
298
- ) {
299
- disabledErrors.add(ErrorKind.NoDefaultExport);
300
- } else {
301
- return [true, { mode: Mode.NameOnly }];
302
- }
303
- }
304
-
305
- if ((defaultErrors as ExportErrorKind[]).every((error) => disabledErrors.has(error))) {
306
- return [true, { mode: Mode.NameOnly }];
307
- }
308
- const errors: [ExportErrorKind, boolean][] = [];
309
- disabledErrors.forEach((error) => errors.push([error, false]));
310
- return [true, { mode: Mode.Code, errors }];
311
- }
@@ -1,76 +0,0 @@
1
- import fs = require("fs");
2
- import os = require("os");
3
- import path = require("path");
4
- import { WalkContext } from "tslint";
5
-
6
- const suggestionsDir = path.join(os.homedir(), ".dts", "suggestions");
7
-
8
- interface Suggestion {
9
- fileName: string;
10
- ruleName: string;
11
- message: string;
12
- start?: number;
13
- width?: number;
14
- }
15
-
16
- // Packages for which suggestions were already added in this run of dtslint.
17
- const existingPackages = new Set();
18
-
19
- /**
20
- * A rule should call this function to provide a suggestion instead of a lint failure.
21
- */
22
- export function addSuggestion<T>(ctx: WalkContext<T>, message: string, start?: number, width?: number) {
23
- const suggestion: Suggestion = {
24
- fileName: ctx.sourceFile.fileName,
25
- ruleName: ctx.ruleName,
26
- message,
27
- start,
28
- width,
29
- };
30
-
31
- const packageName = dtPackageName(ctx.sourceFile.fileName);
32
- if (!packageName) {
33
- return;
34
- }
35
- let flag = "a";
36
- if (!existingPackages.has(packageName)) {
37
- flag = "w";
38
- existingPackages.add(packageName);
39
- }
40
- try {
41
- if (!fs.existsSync(suggestionsDir)) {
42
- fs.mkdirSync(suggestionsDir, { recursive: true });
43
- }
44
- fs.writeFileSync(
45
- path.join(suggestionsDir, packageName + ".txt"),
46
- flag === "a" ? "\n" + formatSuggestion(suggestion) : formatSuggestion(suggestion),
47
- { flag, encoding: "utf8" },
48
- );
49
- } catch (e) {
50
- console.log(`Could not write suggestions for package ${packageName}. ${(e as Error).message || ""}`);
51
- }
52
- }
53
-
54
- const dtPath = path.join("DefinitelyTyped", "types");
55
-
56
- function dtPackageName(filePath: string): string | undefined {
57
- const dtIndex = filePath.indexOf(dtPath);
58
- if (dtIndex === -1) {
59
- return undefined;
60
- }
61
- const basePath = filePath.substr(dtIndex + dtPath.length);
62
- const dirs = basePath.split(path.sep).filter((dir) => dir !== "");
63
- if (dirs.length === 0) {
64
- return undefined;
65
- }
66
- const packageName = dirs[0];
67
- // Check if this is an old version of a package.
68
- if (dirs.length > 1 && /^v\d+(\.\d+)?$/.test(dirs[1])) {
69
- return packageName + dirs[1];
70
- }
71
- return packageName;
72
- }
73
-
74
- function formatSuggestion(suggestion: Suggestion): string {
75
- return JSON.stringify(suggestion, /*replacer*/ undefined, 0);
76
- }
@@ -1,6 +0,0 @@
1
- {
2
- "rulesDirectory": ["../../../dist/rules"],
3
- "rules": {
4
- "npm-naming": [true, {"mode": "code", "errors": [["NeedsExportEquals", true]], "single-line": true }]
5
- }
6
- }
@@ -1 +0,0 @@
1
- export default dtsCritic();
@@ -1,8 +0,0 @@
1
- // Type definitions for package dts-critic 1.0
2
- ~ [0]
3
- // Project: https://https://github.com/DefinitelyTyped/dts-critic
4
- // Definitions by: Jane Doe <https://github.com/janedoe>
5
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
-
7
- export default dtsCritic();
8
- [0]: The declaration doesn't match the JavaScript module 'dts-critic'. Reason: The declaration should use 'export =' syntax because the JavaScript source uses 'module.exports =' syntax and 'module.exports' can be called or constructed. To learn more about 'export =' syntax, see https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require. If you won't fix this error now or you think this error is wrong, you can disable this check by adding the following options to your project's tslint.json file under "rules": "npm-naming": [true,{"mode":"code","errors":[["NeedsExportEquals",false]]}] See: https://github.com/microsoft/DefinitelyTyped-tools/blob/master/packages/dtslint/docs/npm-naming.md
@@ -1,17 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "@types/dts-critic",
4
- "version": "1.0.9999",
5
- "projects": [
6
- "https://github.com/microsoft/TypeScript"
7
- ],
8
- "devDependencies": {
9
- "@types/dts-critic": "workspace:."
10
- },
11
- "owners": [
12
- {
13
- "name": "Jane Doe",
14
- "githubUsername": "janedoe"
15
- }
16
- ]
17
- }
@@ -1,6 +0,0 @@
1
- {
2
- "rulesDirectory": ["../../../dist/rules"],
3
- "rules": {
4
- "npm-naming": [true, {"mode": "name-only", "single-line": true}]
5
- }
6
- }
@@ -1,2 +0,0 @@
1
- // hi
2
- ~ [Declaration file must have a matching npm package. To resolve this error, either: 1. Change the name to match an npm package. 2. Add `"nonNpm": true` to the package.json to indicate that this is not an npm package. Ensure the package name is descriptive enough to avoid conflicts with future npm packages. If you won't fix this error now or you think this error is wrong, you can disable this check by adding the following options to your project's tslint.json file under "rules": "npm-naming": false See: https://github.com/microsoft/DefinitelyTyped-tools/blob/master/packages/dtslint/docs/npm-naming.md]
@@ -1,17 +0,0 @@
1
- {
2
- "private": true,
3
- "name": "@types/wenceslas",
4
- "version": "0.0.9999",
5
- "projects": [
6
- "https://github.com/bobby-headers/dt-header"
7
- ],
8
- "devDependencies": {
9
- "@types/wenceslas": "workspace:."
10
- },
11
- "owners": [
12
- {
13
- "name": "Jane Doe",
14
- "githubUsername": "janedoe"
15
- }
16
- ]
17
- }