@definitelytyped/eslint-plugin 0.1.2 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @definitelytyped/eslint-plugin
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [31de5d3]
8
+ - Updated dependencies [9da3fc7]
9
+ - @definitelytyped/utils@0.1.2
10
+
11
+ ## 0.1.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 4216821: Add @arethetypeswrong/cli run
16
+
3
17
  ## 0.1.2
4
18
 
5
19
  ### Patch Changes
@@ -17,7 +17,6 @@ export declare const rules: {
17
17
  "no-single-declare-module": import("../util").RuleModule<never[], "oneModuleDeclaration">;
18
18
  "no-old-dt-header": import("../util").RuleModule<never[], "noOldDTHeader">;
19
19
  "no-import-of-dev-dependencies": import("../util").RuleModule<never[], "noImportOfDevDependencies" | "noReferenceOfDevDependencies">;
20
- "npm-naming": import("../util").RuleModule<[import("./npm-naming/types").NpmNamingOptions], "error">;
21
20
  expect: import("../util").RuleModule<[{
22
21
  versionsToTest?: {
23
22
  readonly versionName: string;
@@ -19,7 +19,6 @@ const strictExportDeclareModifiers = require("./strict-export-declare-modifiers"
19
19
  const noSingleDeclareModule = require("./no-single-declare-module");
20
20
  const noOldDTHeader = require("./no-old-dt-header");
21
21
  const noImportOfDevDependencies = require("./no-import-of-dev-dependencies");
22
- const npmNaming = require("./npm-naming");
23
22
  const expect = require("./expect");
24
23
  const noTypeOnlyPackages = require("./no-type-only-packages");
25
24
  exports.rules = {
@@ -41,7 +40,6 @@ exports.rules = {
41
40
  "no-single-declare-module": noSingleDeclareModule,
42
41
  "no-old-dt-header": noOldDTHeader,
43
42
  "no-import-of-dev-dependencies": noImportOfDevDependencies,
44
- "npm-naming": npmNaming,
45
43
  expect,
46
44
  "no-type-only-packages": noTypeOnlyPackages,
47
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;AAAA,+DAAgE;AAChE,6CAA8C;AAC9C,qDAAsD;AACtD,+CAAgD;AAChD,uDAAwD;AACxD,wEAAyE;AACzE,sFAAuF;AACvF,uEAAwE;AACxE,iDAAkD;AAClD,2EAA4E;AAC5E,mEAAoE;AACpE,qDAAsD;AACtD,mEAAoE;AACpE,4DAA6D;AAC7D,kFAAmF;AACnF,oEAAqE;AACrE,oDAAqD;AACrD,6EAA8E;AAC9E,0CAA2C;AAC3C,mCAAoC;AACpC,8DAA+D;AAElD,QAAA,KAAK,GAAG;IACnB,uBAAuB,EAAE,mBAAmB;IAC5C,cAAc,EAAE,UAAU;IAC1B,kBAAkB,EAAE,cAAc;IAClC,eAAe,EAAE,WAAW;IAC5B,mBAAmB,EAAE,eAAe;IACpC,4BAA4B,EAAE,uBAAuB;IACrD,oCAAoC,EAAE,6BAA6B;IACnE,4BAA4B,EAAE,sBAAsB;IACpD,gBAAgB,EAAE,YAAY;IAC9B,8BAA8B,EAAE,wBAAwB;IACxD,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,cAAc;IAClC,yBAAyB,EAAE,qBAAqB;IAChD,qBAAqB,EAAE,kBAAkB;IACzC,iCAAiC,EAAE,4BAA4B;IAC/D,0BAA0B,EAAE,qBAAqB;IACjD,kBAAkB,EAAE,aAAa;IACjC,+BAA+B,EAAE,yBAAyB;IAC1D,YAAY,EAAE,SAAS;IACvB,MAAM;IACN,uBAAuB,EAAE,kBAAkB;CAC5C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;AAAA,+DAAgE;AAChE,6CAA8C;AAC9C,qDAAsD;AACtD,+CAAgD;AAChD,uDAAwD;AACxD,wEAAyE;AACzE,sFAAuF;AACvF,uEAAwE;AACxE,iDAAkD;AAClD,2EAA4E;AAC5E,mEAAoE;AACpE,qDAAsD;AACtD,mEAAoE;AACpE,4DAA6D;AAC7D,kFAAmF;AACnF,oEAAqE;AACrE,oDAAqD;AACrD,6EAA8E;AAC9E,mCAAoC;AACpC,8DAA+D;AAElD,QAAA,KAAK,GAAG;IACnB,uBAAuB,EAAE,mBAAmB;IAC5C,cAAc,EAAE,UAAU;IAC1B,kBAAkB,EAAE,cAAc;IAClC,eAAe,EAAE,WAAW;IAC5B,mBAAmB,EAAE,eAAe;IACpC,4BAA4B,EAAE,uBAAuB;IACrD,oCAAoC,EAAE,6BAA6B;IACnE,4BAA4B,EAAE,sBAAsB;IACpD,gBAAgB,EAAE,YAAY;IAC9B,8BAA8B,EAAE,wBAAwB;IACxD,yBAAyB,EAAE,qBAAqB;IAChD,kBAAkB,EAAE,cAAc;IAClC,yBAAyB,EAAE,qBAAqB;IAChD,qBAAqB,EAAE,kBAAkB;IACzC,iCAAiC,EAAE,4BAA4B;IAC/D,0BAA0B,EAAE,qBAAqB;IACjD,kBAAkB,EAAE,aAAa;IACjC,+BAA+B,EAAE,yBAAyB;IAC1D,MAAM;IACN,uBAAuB,EAAE,kBAAkB;CAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@definitelytyped/eslint-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "ESLint rules for DefinitelyTyped",
5
5
  "main": "./dist/index.js",
6
6
  "publishConfig": {
@@ -20,8 +20,7 @@
20
20
  "dependencies": {
21
21
  "@typescript-eslint/types": "^6.19.0",
22
22
  "@typescript-eslint/utils": "^6.19.0",
23
- "@definitelytyped/dts-critic": "0.1.2",
24
- "@definitelytyped/utils": "0.1.1"
23
+ "@definitelytyped/utils": "0.1.2"
25
24
  },
26
25
  "peerDependencies": {
27
26
  "@typescript-eslint/eslint-plugin": "^6.11.0",
@@ -33,7 +32,6 @@
33
32
  "devDependencies": {
34
33
  "@definitelytyped/eslint-plugin": "link:",
35
34
  "@types/eslint": "^8.56.2",
36
- "@typescript-eslint/rule-tester": "^6.19.0",
37
35
  "glob": "^10.3.10",
38
36
  "jest-file-snapshot": "^0.5.0",
39
37
  "strip-ansi": "^6.0.1",
@@ -1,10 +0,0 @@
1
- import { ExportErrorKind, Mode } from "@definitelytyped/dts-critic";
2
- export type CodeRawOptionError = [ExportErrorKind, boolean];
3
- export interface CodeRawOptions {
4
- mode: Mode.Code;
5
- errors: CodeRawOptionError[];
6
- }
7
- export interface NameOnlyRawOptions {
8
- mode: Mode.NameOnly;
9
- }
10
- export type NpmNamingOptions = CodeRawOptions | NameOnlyRawOptions;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/rules/npm-naming/types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { NpmNamingOptions } from "./npm-naming/types";
2
- declare const rule: import("../util").RuleModule<[NpmNamingOptions], "error">;
3
- export = rule;
@@ -1,179 +0,0 @@
1
- "use strict";
2
- const dts_critic_1 = require("@definitelytyped/dts-critic");
3
- const suggestions_1 = require("../suggestions");
4
- const util_1 = require("../util");
5
- function parseEnabledErrors(errors) {
6
- const enabledChecks = [];
7
- for (const tuple of errors) {
8
- const error = (0, dts_critic_1.parseExportErrorKind)(tuple[0]);
9
- if (error) {
10
- enabledChecks.push([error, tuple[1]]);
11
- }
12
- }
13
- return enabledChecks;
14
- }
15
- function parseRawOptions(rawOptions) {
16
- switch (rawOptions.mode) {
17
- case dts_critic_1.Mode.Code:
18
- return { ...rawOptions, errors: new Map(parseEnabledErrors(rawOptions.errors)) };
19
- case dts_critic_1.Mode.NameOnly:
20
- return rawOptions;
21
- }
22
- }
23
- const enabledSuggestions = [dts_critic_1.ErrorKind.JsPropertyNotInDts, dts_critic_1.ErrorKind.JsSignatureNotInDts];
24
- function toOptionsWithSuggestions(options) {
25
- if (options.mode === dts_critic_1.Mode.NameOnly) {
26
- return options;
27
- }
28
- const optionsWithSuggestions = { mode: options.mode, errors: new Map(options.errors) };
29
- for (const err of enabledSuggestions) {
30
- optionsWithSuggestions.errors.set(err, true);
31
- }
32
- return optionsWithSuggestions;
33
- }
34
- function eslintDisableOption(error) {
35
- switch (error) {
36
- case dts_critic_1.ErrorKind.NoMatchingNpmPackage:
37
- case dts_critic_1.ErrorKind.NoMatchingNpmVersion:
38
- case dts_critic_1.ErrorKind.NonNpmHasMatchingPackage:
39
- return `"off"`;
40
- case dts_critic_1.ErrorKind.NoDefaultExport:
41
- case dts_critic_1.ErrorKind.NeedsExportEquals:
42
- case dts_critic_1.ErrorKind.JsSignatureNotInDts:
43
- case dts_critic_1.ErrorKind.JsPropertyNotInDts:
44
- case dts_critic_1.ErrorKind.DtsSignatureNotInJs:
45
- case dts_critic_1.ErrorKind.DtsPropertyNotInJs:
46
- return JSON.stringify(["error", { mode: dts_critic_1.Mode.Code, errors: [[error, false]] }]);
47
- }
48
- }
49
- const rule = (0, util_1.createRule)({
50
- name: "npm-naming",
51
- defaultOptions: [
52
- {
53
- mode: dts_critic_1.Mode.NameOnly,
54
- },
55
- ],
56
- meta: {
57
- type: "problem",
58
- docs: {
59
- description: "Ensure that package name and DefinitelyTyped header match npm package info.",
60
- },
61
- messages: {
62
- error: `{{ error }}
63
- If you won't fix this error now or you think this error is wrong,
64
- you can disable this check by adding the following options to your project's .eslintrc.json file under "rules":
65
-
66
- "@definitelytyped/npm-naming": {{ option }}`,
67
- },
68
- schema: [
69
- {
70
- oneOf: [
71
- {
72
- additionalProperties: false,
73
- properties: {
74
- mode: {
75
- type: "string",
76
- enum: [dts_critic_1.Mode.NameOnly],
77
- },
78
- },
79
- type: "object",
80
- },
81
- {
82
- additionalProperties: false,
83
- type: "object",
84
- properties: {
85
- mode: {
86
- type: "string",
87
- enum: [dts_critic_1.Mode.Code],
88
- },
89
- errors: {
90
- type: "array",
91
- items: {
92
- type: "array",
93
- items: [
94
- {
95
- description: "Name of the check.",
96
- type: "string",
97
- enum: [dts_critic_1.ErrorKind.NeedsExportEquals, dts_critic_1.ErrorKind.NoDefaultExport],
98
- },
99
- {
100
- description: "Whether the check is enabled or disabled.",
101
- type: "boolean",
102
- },
103
- ],
104
- minItems: 2,
105
- maxItems: 2,
106
- },
107
- },
108
- },
109
- },
110
- ],
111
- },
112
- ],
113
- },
114
- create(context, [rawOptions]) {
115
- if (!(0, util_1.isMainFile)(context.filename, /*allowNested*/ false)) {
116
- return {};
117
- }
118
- const options = parseRawOptions(rawOptions);
119
- const optionsWithSuggestions = toOptionsWithSuggestions(options);
120
- const diagnostics = (0, dts_critic_1.dtsCritic)(context.filename, /* sourcePath */ undefined, optionsWithSuggestions);
121
- const errors = filterErrors(diagnostics);
122
- for (const error of errors) {
123
- switch (error.kind) {
124
- case dts_critic_1.ErrorKind.NoMatchingNpmPackage:
125
- case dts_critic_1.ErrorKind.NoMatchingNpmVersion:
126
- case dts_critic_1.ErrorKind.NonNpmHasMatchingPackage:
127
- case dts_critic_1.ErrorKind.DtsPropertyNotInJs:
128
- case dts_critic_1.ErrorKind.DtsSignatureNotInJs:
129
- case dts_critic_1.ErrorKind.JsPropertyNotInDts:
130
- case dts_critic_1.ErrorKind.JsSignatureNotInDts:
131
- case dts_critic_1.ErrorKind.NeedsExportEquals:
132
- case dts_critic_1.ErrorKind.NoDefaultExport:
133
- context.report({
134
- data: {
135
- error: error.message,
136
- option: eslintDisableOption(error.kind),
137
- },
138
- loc: error.position
139
- ? {
140
- start: context.sourceCode.getLocFromIndex(error.position.start),
141
- end: context.sourceCode.getLocFromIndex(error.position.start + error.position.length),
142
- }
143
- : {
144
- end: {
145
- line: 2,
146
- column: 0,
147
- },
148
- start: {
149
- line: 1,
150
- column: 0,
151
- },
152
- },
153
- messageId: "error",
154
- });
155
- break;
156
- }
157
- }
158
- return {};
159
- function filterErrors(diagnostics) {
160
- const errors = [];
161
- diagnostics.forEach((diagnostic) => {
162
- if (isSuggestion(diagnostic)) {
163
- (0, suggestions_1.addSuggestion)(context.filename, "npm-naming", diagnostic.message, diagnostic.position?.start, diagnostic.position?.length);
164
- }
165
- else {
166
- errors.push(diagnostic);
167
- }
168
- });
169
- return errors;
170
- }
171
- function isSuggestion(diagnostic) {
172
- return (options.mode === dts_critic_1.Mode.Code &&
173
- enabledSuggestions.includes(diagnostic.kind) &&
174
- !options.errors.get(diagnostic.kind));
175
- }
176
- },
177
- });
178
- module.exports = rule;
179
- //# sourceMappingURL=npm-naming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"npm-naming.js","sourceRoot":"","sources":["../../src/rules/npm-naming.ts"],"names":[],"mappings":";AAAA,4DAQqC;AAErC,gDAA+C;AAC/C,kCAAiD;AAGjD,SAAS,kBAAkB,CAAC,MAA4B;IACtD,MAAM,aAAa,GAAiC,EAAE,CAAC;IACvD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAA,iCAAoB,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,KAAK,EAAE,CAAC;YACV,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,eAAe,CAAC,UAA4B;IACnD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,iBAAI,CAAC,IAAI;YACZ,OAAO,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,kBAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACnF,KAAK,iBAAI,CAAC,QAAQ;YAChB,OAAO,UAAU,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,kBAAkB,GAAsB,CAAC,sBAAS,CAAC,kBAAkB,EAAE,sBAAS,CAAC,mBAAmB,C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,MAAM,EAAE,CAAC;iCACV;6BACF;wBACL,SAAS,EAAE,OAAO;qBACnB,CAAC,CAAC;oBACH,MAAM;YACV,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;QAEV,SAAS,YAAY,CAAC,WAA0B;YAC9C,MAAM,MAAM,GAAkB,EAAE,CAAC;YAEjC,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACjC,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC7B,IAAA,2BAAa,EACX,OAAO,CAAC,QAAQ,EAChB,YAAY,EACZ,UAAU,CAAC,OAAO,EAClB,UAAU,CAAC,QAAQ,EAAE,KAAK,EAC1B,UAAU,CAAC,QAAQ,EAAE,MAAM,CAC5B,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,SAAS,YAAY,CAAC,UAAuB;YAC3C,OAAO,CACL,OAAO,CAAC,IAAI,KAAK,iBAAI,CAAC,IAAI;gBAC1B,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAuB,CAAC;gBAC/D,CAAE,OAAO,CAAC,MAAkC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAClE,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,iBAAS,IAAI,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
- ```