@definitelytyped/dtslint 0.0.168-next.0 → 0.0.168

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 (109) hide show
  1. package/dist/lint.js +1 -3
  2. package/dist/lint.js.map +1 -1
  3. package/dist/util.d.ts +0 -4
  4. package/dist/util.js +1 -23
  5. package/dist/util.js.map +1 -1
  6. package/package.json +6 -6
  7. package/src/lint.ts +1 -3
  8. package/src/util.ts +0 -25
  9. package/tsconfig.tsbuildinfo +1 -1
  10. package/dist/rules/dt-header.d.ts +0 -2
  11. package/dist/rules/dt-header.js +0 -62
  12. package/dist/rules/dt-header.js.map +0 -1
  13. package/dist/rules/export-just-namespace.d.ts +0 -2
  14. package/dist/rules/export-just-namespace.js +0 -70
  15. package/dist/rules/export-just-namespace.js.map +0 -1
  16. package/dist/rules/no-any-union.d.ts +0 -4
  17. package/dist/rules/no-any-union.js +0 -34
  18. package/dist/rules/no-any-union.js.map +0 -1
  19. package/dist/rules/no-bad-reference.d.ts +0 -2
  20. package/dist/rules/no-bad-reference.js +0 -55
  21. package/dist/rules/no-bad-reference.js.map +0 -1
  22. package/dist/rules/no-const-enum.d.ts +0 -4
  23. package/dist/rules/no-const-enum.js +0 -30
  24. package/dist/rules/no-const-enum.js.map +0 -1
  25. package/dist/rules/no-dead-reference.d.ts +0 -2
  26. package/dist/rules/no-dead-reference.js +0 -44
  27. package/dist/rules/no-dead-reference.js.map +0 -1
  28. package/dist/rules/no-declare-current-package.d.ts +0 -4
  29. package/dist/rules/no-declare-current-package.js +0 -43
  30. package/dist/rules/no-declare-current-package.js.map +0 -1
  31. package/dist/rules/no-import-default-of-export-equals.d.ts +0 -4
  32. package/dist/rules/no-import-default-of-export-equals.js +0 -87
  33. package/dist/rules/no-import-default-of-export-equals.js.map +0 -1
  34. package/dist/rules/no-outside-dependencies.d.ts +0 -2
  35. package/dist/rules/no-outside-dependencies.js +0 -41
  36. package/dist/rules/no-outside-dependencies.js.map +0 -1
  37. package/dist/rules/no-self-import.d.ts +0 -4
  38. package/dist/rules/no-self-import.js +0 -38
  39. package/dist/rules/no-self-import.js.map +0 -1
  40. package/dist/rules/no-single-element-tuple-type.d.ts +0 -5
  41. package/dist/rules/no-single-element-tuple-type.js +0 -30
  42. package/dist/rules/no-single-element-tuple-type.js.map +0 -1
  43. package/dist/rules/no-unnecessary-generics.d.ts +0 -8
  44. package/dist/rules/no-unnecessary-generics.js +0 -135
  45. package/dist/rules/no-unnecessary-generics.js.map +0 -1
  46. package/dist/rules/no-useless-files.d.ts +0 -2
  47. package/dist/rules/no-useless-files.js +0 -53
  48. package/dist/rules/no-useless-files.js.map +0 -1
  49. package/dist/rules/prefer-declare-function.d.ts +0 -5
  50. package/dist/rules/prefer-declare-function.js +0 -35
  51. package/dist/rules/prefer-declare-function.js.map +0 -1
  52. package/dist/rules/redundant-undefined.d.ts +0 -4
  53. package/dist/rules/redundant-undefined.js +0 -53
  54. package/dist/rules/redundant-undefined.js.map +0 -1
  55. package/dist/rules/trim-file.d.ts +0 -2
  56. package/dist/rules/trim-file.js +0 -43
  57. package/dist/rules/trim-file.js.map +0 -1
  58. package/docs/dt-header.md +0 -88
  59. package/docs/export-just-namespace.md +0 -29
  60. package/docs/no-any-union.md +0 -27
  61. package/docs/no-bad-reference.md +0 -28
  62. package/docs/no-const-enum.md +0 -16
  63. package/docs/no-dead-reference.md +0 -17
  64. package/docs/no-declare-current-package.md +0 -35
  65. package/docs/no-import-default-of-export-equals.md +0 -22
  66. package/docs/no-outside-dependencies.md +0 -23
  67. package/docs/no-self-import.md +0 -27
  68. package/docs/no-single-element-tuple-type.md +0 -15
  69. package/docs/no-unnecessary-generics.md +0 -69
  70. package/docs/no-useless-files.md +0 -14
  71. package/docs/prefer-declare-function.md +0 -15
  72. package/docs/redundant-undefined.md +0 -15
  73. package/docs/trim-file.md +0 -17
  74. package/src/rules/dt-header.ts +0 -74
  75. package/src/rules/export-just-namespace.ts +0 -83
  76. package/src/rules/no-any-union.ts +0 -34
  77. package/src/rules/no-bad-reference.ts +0 -62
  78. package/src/rules/no-const-enum.ts +0 -30
  79. package/src/rules/no-dead-reference.ts +0 -46
  80. package/src/rules/no-declare-current-package.ts +0 -45
  81. package/src/rules/no-import-default-of-export-equals.ts +0 -68
  82. package/src/rules/no-outside-dependencies.ts +0 -42
  83. package/src/rules/no-self-import.ts +0 -40
  84. package/src/rules/no-single-element-tuple-type.ts +0 -31
  85. package/src/rules/no-unnecessary-generics.ts +0 -126
  86. package/src/rules/no-useless-files.ts +0 -58
  87. package/src/rules/prefer-declare-function.ts +0 -37
  88. package/src/rules/redundant-undefined.ts +0 -62
  89. package/src/rules/trim-file.ts +0 -45
  90. package/test/dt-header.test.ts +0 -189
  91. package/test/export-just-namespace.test.ts +0 -70
  92. package/test/no-any-union.test.ts +0 -22
  93. package/test/no-bad-reference.test.ts +0 -66
  94. package/test/no-const-enum.test.ts +0 -22
  95. package/test/no-dead-reference.test.ts +0 -66
  96. package/test/no-declare-current-package.test.ts +0 -61
  97. package/test/no-import-default-of-export-equals.test.ts +0 -49
  98. package/test/no-self-import.test.ts +0 -47
  99. package/test/no-single-element-tuple-type.test.ts +0 -28
  100. package/test/no-unnecessary-generics.test.ts +0 -152
  101. package/test/no-useless-files.test.ts +0 -42
  102. package/test/prefer-declare-function.test.ts +0 -66
  103. package/test/redundant-undefined.test.ts +0 -39
  104. package/test/trim-file.test.ts +0 -46
  105. package/test/tsconfig.json +0 -10
  106. package/test/tsconfig.no-declare-current-package.json +0 -11
  107. package/test/tsconfig.no-declare-current-package2.json +0 -11
  108. package/test/tsconfig.no-import-default-of-export-equals.json +0 -11
  109. package/test/tsconfig.no-self-import.json +0 -7
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- const utils_1 = require("@typescript-eslint/utils");
26
- const ts = __importStar(require("typescript"));
27
- const util_1 = require("../util");
28
- const rule = (0, util_1.createRule)({
29
- defaultOptions: [],
30
- meta: {
31
- docs: {
32
- description: "Forbids signatures using a generic parameter only once.",
33
- recommended: "error",
34
- },
35
- messages: {
36
- never: "Type parameter {{name}} is never used.",
37
- sole: "Type parameter {{name}} is used only once.",
38
- },
39
- schema: [],
40
- type: "problem",
41
- },
42
- name: "no-relative-import-in-test",
43
- create(context) {
44
- return {
45
- [[
46
- "ArrowFunctionExpression[typeParameters]",
47
- "FunctionDeclaration[typeParameters]",
48
- "FunctionExpression[typeParameters]",
49
- "TSCallSignatureDeclaration[typeParameters]",
50
- "TSConstructorType[typeParameters]",
51
- "TSDeclareFunction[typeParameters]",
52
- "TSFunctionType[typeParameters]",
53
- "TSMethodSignature[typeParameters]",
54
- ].join(", ")](esNode) {
55
- const parserServices = utils_1.ESLintUtils.getParserServices(context);
56
- const tsNode = parserServices.esTreeNodeToTSNodeMap.get(esNode);
57
- if (!tsNode.typeParameters) {
58
- return;
59
- }
60
- const checker = parserServices.program.getTypeChecker();
61
- for (const typeParameter of tsNode.typeParameters) {
62
- const name = typeParameter.name.text;
63
- const res = getSoleUse(tsNode, assertDefined(checker.getSymbolAtLocation(typeParameter.name)), checker);
64
- switch (res.type) {
65
- case "sole":
66
- context.report({
67
- data: { name },
68
- messageId: "sole",
69
- node: parserServices.tsNodeToESTreeNodeMap.get(res.soleUse),
70
- });
71
- break;
72
- case "never":
73
- context.report({
74
- data: { name },
75
- messageId: "never",
76
- node: parserServices.tsNodeToESTreeNodeMap.get(typeParameter),
77
- });
78
- break;
79
- }
80
- }
81
- },
82
- };
83
- },
84
- });
85
- function getSoleUse(sig, typeParameterSymbol, checker) {
86
- const exit = {};
87
- let soleUse;
88
- try {
89
- if (sig.typeParameters) {
90
- for (const tp of sig.typeParameters) {
91
- if (tp.constraint) {
92
- recur(tp.constraint);
93
- }
94
- }
95
- }
96
- for (const param of sig.parameters) {
97
- if (param.type) {
98
- recur(param.type);
99
- }
100
- }
101
- if (sig.type) {
102
- recur(sig.type);
103
- }
104
- }
105
- catch (err) {
106
- if (err === exit) {
107
- return { type: "ok" };
108
- }
109
- throw err;
110
- }
111
- return soleUse ? { type: "sole", soleUse } : { type: "never" };
112
- function recur(node) {
113
- if (ts.isIdentifier(node)) {
114
- if (checker.getSymbolAtLocation(node) === typeParameterSymbol) {
115
- if (soleUse === undefined) {
116
- soleUse = node;
117
- }
118
- else {
119
- throw exit;
120
- }
121
- }
122
- }
123
- else {
124
- node.forEachChild(recur);
125
- }
126
- }
127
- }
128
- function assertDefined(value) {
129
- if (value === undefined) {
130
- throw new Error("unreachable");
131
- }
132
- return value;
133
- }
134
- module.exports = rule;
135
- //# sourceMappingURL=no-unnecessary-generics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"no-unnecessary-generics.js","sourceRoot":"","sources":["../../src/rules/no-unnecessary-generics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAiE;AACjE,+CAAiC;AAEjC,kCAAqC;AAUrC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,cAAc,EAAE,EAAE;IAClB,IAAI,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EAAE;YACzB,IAAI,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,mBAAmB,EAAE;gBAC7D,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,OAAO,GAAG,IAAI,CAAC;iBAChB;qBAAM;oBACL,MAAM,IAAI,CAAC;iBACZ;aACF;SACF;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;AACH,CAAC;AAID,SAAS,aAAa,CAAI,KAAoB;IAC5C,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;KAChC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,iBAAS,IAAI,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const rule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"noContent", never[], {}>;
2
- export = rule;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- const util_1 = require("../util");
3
- const rule = (0, util_1.createRule)({
4
- name: "no-useless-files",
5
- defaultOptions: [],
6
- meta: {
7
- type: "problem",
8
- docs: {
9
- description: "Forbids files with no content.",
10
- recommended: "error",
11
- },
12
- messages: {
13
- noContent: "File has no content.",
14
- },
15
- schema: [],
16
- },
17
- create(context) {
18
- var _a;
19
- const { ast: { tokens, comments }, } = context.getSourceCode();
20
- if (tokens.length === 0) {
21
- if (comments.length === 0) {
22
- reportNoContent();
23
- }
24
- else {
25
- const referenceRegExp = /^\/\s*<reference\s*(types|path)\s*=\s*["|'](.*)["|']/;
26
- let noReferenceFound = true;
27
- for (const comment of comments) {
28
- const referenceMatch = (_a = comment.value.match(referenceRegExp)) === null || _a === void 0 ? void 0 : _a[1];
29
- if (!referenceMatch) {
30
- continue;
31
- }
32
- noReferenceFound = false;
33
- break;
34
- }
35
- if (noReferenceFound) {
36
- reportNoContent();
37
- }
38
- }
39
- }
40
- return {};
41
- function reportNoContent() {
42
- context.report({
43
- messageId: "noContent",
44
- loc: {
45
- start: { line: 1, column: 0 },
46
- end: { line: 1, column: 0 },
47
- },
48
- });
49
- }
50
- },
51
- });
52
- module.exports = rule;
53
- //# sourceMappingURL=no-useless-files.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"no-useless-files.js","sourceRoot":"","sources":["../../src/rules/no-useless-files.ts"],"names":[],"mappings":";AAAA,kCAAqC;AAErC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,IAAI,EAAE,kBAAkB;IACxB,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,gCAAgC;YAC7C,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,SAAS,EAAE,sBAAsB;SAClC;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;;QACZ,MAAM,EACJ,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAC1B,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAE5B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzB,eAAe,EAAE,CAAC;aACnB;iBAAM;gBACL,MAAM,eAAe,GAAG,sDAAsD,CAAC;gBAC/E,IAAI,gBAAgB,GAAG,IAAI,CAAC;gBAE5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;oBAC9B,MAAM,cAAc,GAAG,MAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,0CAAG,CAAC,CAAC,CAAC;oBACjE,IAAI,CAAC,cAAc,EAAE;wBACnB,SAAS;qBACV;oBACD,gBAAgB,GAAG,KAAK,CAAC;oBACzB,MAAM;iBACP;gBAED,IAAI,gBAAgB,EAAE;oBACpB,eAAe,EAAE,CAAC;iBACnB;aACF;SACF;QAED,OAAO,EAAE,CAAC;QAEV,SAAS,eAAe;YACtB,OAAO,CAAC,MAAM,CAAC;gBACb,SAAS,EAAE,WAAW;gBACtB,GAAG,EAAE;oBACH,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;oBAC7B,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;iBAC5B;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,iBAAS,IAAI,CAAC"}
@@ -1,5 +0,0 @@
1
- import { TSESTree } from "@typescript-eslint/utils";
2
- declare const rule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"variableFunction", never[], {
3
- "VariableDeclaration > VariableDeclarator"(node: TSESTree.VariableDeclarator): void;
4
- }>;
5
- export = rule;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- const utils_1 = require("@typescript-eslint/utils");
3
- const util_1 = require("../util");
4
- const rule = (0, util_1.createRule)({
5
- defaultOptions: [],
6
- meta: {
7
- docs: {
8
- description: "Forbids `const x: () => void`.",
9
- recommended: "error",
10
- },
11
- messages: {
12
- variableFunction: "Use a function declaration instead of a variable of function type.",
13
- },
14
- schema: [],
15
- type: "problem",
16
- },
17
- name: "prefer-declare-function",
18
- create(context) {
19
- return {
20
- // eslint-disable-next-line @typescript-eslint/naming-convention
21
- "VariableDeclaration > VariableDeclarator"(node) {
22
- var _a;
23
- if (((_a = node.id.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation.type) === utils_1.AST_NODE_TYPES.TSFunctionType &&
24
- context.getFilename().endsWith(".d.ts")) {
25
- context.report({
26
- messageId: "variableFunction",
27
- node: node.id,
28
- });
29
- }
30
- },
31
- };
32
- },
33
- });
34
- module.exports = rule;
35
- //# sourceMappingURL=prefer-declare-function.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefer-declare-function.js","sourceRoot":"","sources":["../../src/rules/prefer-declare-function.ts"],"names":[],"mappings":";AAAA,oDAAoE;AAEpE,kCAAqC;AAErC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,gCAAgC;YAC7C,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,gBAAgB,EAAE,oEAAoE;SACvF;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAChB;IACD,IAAI,EAAE,yBAAyB;IAC/B,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gEAAgE;YAChE,0CAA0C,CAAC,IAAiC;;gBAC1E,IACE,CAAA,MAAA,IAAI,CAAC,EAAE,CAAC,cAAc,0CAAE,cAAc,CAAC,IAAI,MAAK,sBAAc,CAAC,cAAc;oBAC7E,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EACvC;oBACA,OAAO,CAAC,MAAM,CAAC;wBACb,SAAS,EAAE,kBAAkB;wBAC7B,IAAI,EAAE,IAAI,CAAC,EAAE;qBACd,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,iBAAS,IAAI,CAAC"}
@@ -1,4 +0,0 @@
1
- declare const rule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"redundantUndefined", never[], {
2
- TSUnionType(node: import("@typescript-eslint/types/dist/generated/ast-spec").TSUnionType): void;
3
- }>;
4
- export = rule;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- const util_1 = require("../util");
3
- const utils_1 = require("@typescript-eslint/utils");
4
- const rule = (0, util_1.createRule)({
5
- name: "redundant-undefined",
6
- defaultOptions: [],
7
- meta: {
8
- type: "problem",
9
- docs: {
10
- description: "Forbids optional parameters from including an explicit `undefined` in their type; requires it in optional properties.",
11
- recommended: "error",
12
- },
13
- messages: {
14
- redundantUndefined: `Parameter is optional, so no need to include \`undefined\` in the type.`,
15
- },
16
- schema: [],
17
- },
18
- create(context) {
19
- return {
20
- // eslint-disable-next-line @typescript-eslint/naming-convention
21
- TSUnionType(node) {
22
- const hasUndefinedType = node.types.some((t) => t.type === utils_1.AST_NODE_TYPES.TSUndefinedKeyword);
23
- if (node.parent.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation &&
24
- isParameter(node.parent.parent) &&
25
- node.parent.parent.optional &&
26
- isFunctionLike(node.parent.parent.parent) &&
27
- hasUndefinedType) {
28
- context.report({
29
- messageId: "redundantUndefined",
30
- node,
31
- });
32
- }
33
- },
34
- };
35
- },
36
- });
37
- function isFunctionLike(node) {
38
- return (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
39
- node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration ||
40
- node.type === utils_1.AST_NODE_TYPES.FunctionExpression ||
41
- node.type === utils_1.AST_NODE_TYPES.TSDeclareFunction ||
42
- node.type === utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression);
43
- }
44
- /** Note: Does not include parameter properties because those can't be optional */
45
- function isParameter(node) {
46
- return (node.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
47
- node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
48
- node.type === utils_1.AST_NODE_TYPES.Identifier ||
49
- node.type === utils_1.AST_NODE_TYPES.ObjectPattern ||
50
- node.type === utils_1.AST_NODE_TYPES.RestElement);
51
- }
52
- module.exports = rule;
53
- //# sourceMappingURL=redundant-undefined.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"redundant-undefined.js","sourceRoot":"","sources":["../../src/rules/redundant-undefined.ts"],"names":[],"mappings":";AAAA,kCAAqC;AACrC,oDAA0D;AAG1D,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,IAAI,EAAE,qBAAqB;IAC3B,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,uHAAuH;YACzH,WAAW,EAAE,O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,IAAI,KAAK,sBAAc,CAAC,UAAU;QACvC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,aAAa;QAC1C,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,WAAW,CACzC,CAAC;AACJ,CAAC;AAED,iBAAS,IAAI,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const rule: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"leadingBlankLine" | "trailingBlankLine", never[], {}>;
2
- export = rule;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- const util_1 = require("../util");
3
- const rule = (0, util_1.createRule)({
4
- name: "trim-file",
5
- defaultOptions: [],
6
- meta: {
7
- type: "layout",
8
- docs: {
9
- description: "Forbids leading/trailing blank lines in a file. Allows file to end in '\n'",
10
- recommended: "error",
11
- },
12
- messages: {
13
- leadingBlankLine: "File should not begin with a blank line.",
14
- trailingBlankLine: "File should not end with a blank line. (Ending in one newline OK, ending in two newlines not OK.)",
15
- },
16
- schema: [],
17
- },
18
- create(context) {
19
- const { lines, text } = context.getSourceCode();
20
- if (text.startsWith("\r") || text.startsWith("\n")) {
21
- context.report({
22
- messageId: "leadingBlankLine",
23
- loc: {
24
- start: { line: 1, column: 0 },
25
- end: { line: 1, column: 0 },
26
- },
27
- });
28
- }
29
- if (text.endsWith("\n\n") || text.endsWith("\r\n\r\n")) {
30
- const line = lines.length;
31
- context.report({
32
- messageId: "trailingBlankLine",
33
- loc: {
34
- start: { line, column: 0 },
35
- end: { line, column: 0 },
36
- },
37
- });
38
- }
39
- return {};
40
- },
41
- });
42
- module.exports = rule;
43
- //# sourceMappingURL=trim-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trim-file.js","sourceRoot":"","sources":["../../src/rules/trim-file.ts"],"names":[],"mappings":";AAAA,kCAAqC;AAErC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,IAAI,EAAE,WAAW;IACjB,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE;YACJ,WAAW,EAAE,4EAA4E;YACzF,WAAW,EAAE,OAAO;SACrB;QACD,QAAQ,EAAE;YACR,gBAAgB,EAAE,0CAA0C;YAC5D,iBAAiB,EACf,mGAAmG;SACtG;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAChD,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAClD,OAAO,CAAC,MAAM,CAAC;gBACb,SAAS,EAAE,kBAAkB;gBAC7B,GAAG,EAAE;oBACH,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;oBAC7B,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;iBAC5B;aACF,CAAC,CAAC;SACJ;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACtD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC;gBACb,SAAS,EAAE,mBAAmB;gBAC9B,GAAG,EAAE;oBACH,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;oBAC1B,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE;iBACzB;aACF,CAAC,CAAC;SACJ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC;AAEH,iBAAS,IAAI,CAAC"}
package/docs/dt-header.md DELETED
@@ -1,88 +0,0 @@
1
- # dt-header
2
-
3
- (This rule is specific to DefinitelyTyped.)
4
-
5
- Checks the format of DefinitelyTyped header comments.
6
-
7
- ---
8
-
9
- **Bad**:
10
-
11
- ```ts
12
- // Type definitions for foo v1.2.3
13
- ```
14
-
15
- * Don't include `v`
16
- * Don't include a patch version
17
-
18
- **Good**:
19
-
20
- ```ts
21
- // Type definitions for foo 1.2
22
- ```
23
-
24
- ---
25
-
26
- **Bad**:
27
-
28
- ```ts
29
- // Definitions by: My Name <http://geocities.com/myname>
30
- ```
31
-
32
- **Good**:
33
-
34
- ```ts
35
- // Definitions by: My Name <https://github.com/myname>
36
- ```
37
-
38
- * Prefer a GitHub username, not a personal web site.
39
-
40
- ---
41
-
42
- **Bad**:
43
-
44
- `foo/index.d.ts`:
45
-
46
- ```ts
47
- // Type definitions for abs 1.2
48
- // Project: https://github.com/foo/foo
49
- // Definitions by: My Name <https://github.com/myname>
50
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
51
- export { f } from "./subModule";
52
- ```
53
-
54
- `foo/subModule.d.ts`:
55
-
56
- ```ts
57
- // Type definitions for abs 1.2
58
- // Project: https://github.com/foo/foo
59
- // Definitions by: My Name <https://github.com/myname>
60
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
61
- export function f(): number;
62
- ```
63
-
64
- `foo/ts3.1/index.d.ts`:
65
- ```ts
66
- // Type definitions for abs 1.2
67
- // Project: https://github.com/foo/foo
68
- // Definitions by: My Name <https://github.com/myname>
69
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
70
- export function f(): number;
71
- ```
72
-
73
-
74
- **Good**:
75
-
76
- `foo/index.d.ts`: Same
77
-
78
- `foo/subModule.d.ts`:
79
- ```ts
80
- export function f(): number;
81
- ```
82
-
83
- `foo/ts3.1/index.d.ts`:
84
- ```ts
85
- export function f(): number;
86
- ```
87
-
88
- Don't repeat the header -- only do it in the index of the root.
@@ -1,29 +0,0 @@
1
- # export-just-namespace
2
-
3
- Declaring a namespace is unnecessary if that is the module's only content; just use ES6 export syntax instead.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- namespace MyLib {
9
- export function f(): number;
10
- }
11
- export = MyLib;
12
- ```
13
-
14
- **Good**:
15
-
16
- ```ts
17
- export function f(): number;
18
- ```
19
-
20
- **Also good**:
21
-
22
- ```ts
23
- namespace MyLib {
24
- export function f(): number;
25
- }
26
- function MyLib(): number;
27
- export = MyLib;
28
- ```
29
-
@@ -1,27 +0,0 @@
1
- # no-any-union
2
-
3
- Forbids to include `any` in a union. When `any` is used in a union type, the resulting type is still `any`.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- function f(x: string | any): void;
9
- ```
10
-
11
- **Good**:
12
-
13
- ```ts
14
- function f(x: string): void;
15
- ```
16
-
17
- Or:
18
- ```ts
19
- function f(x: any): void;
20
- ```
21
-
22
- Or:
23
- ```ts
24
- function f(x: string | object): void;
25
- ```
26
-
27
- While the `string` portion of this type annotation may _look_ useful, it in fact offers no additional typechecking over simply using `any`.
@@ -1,28 +0,0 @@
1
- # no-bad-reference
2
-
3
- (This rule is specific to DefinitelyTyped.)
4
- Avoid using `<reference path>`.
5
-
6
- **Bad**:
7
-
8
- ```ts
9
- /// <reference path="../node_modules/@types/foo/index.d.ts" />
10
- import * as foo from "foo";
11
- ```
12
-
13
- **Good**:
14
-
15
- If "foo" is written in external module style (see `no-single-declare-module`), the import alone should work thanks to [module resolution](http://www.typescriptlang.org/docs/handbook/module-resolution.html):
16
-
17
- ```ts
18
- // TypeScript will look for a definition for "foo" using module resolution
19
- import * as foo from "foo";
20
- ```
21
-
22
- If not, use `<reference types>` instead:
23
-
24
- ```ts
25
- /// <reference types="foo" />
26
- ```
27
-
28
- The only time `<reference path>` should be necessary if for global (not module) libraries that are separated into multiple files; the index file must include references to the others to bring them into the compilation.
@@ -1,16 +0,0 @@
1
- # no-const-enum
2
-
3
- Avoid using `const enum`s. These can't be used by JavaScript users or by TypeScript users with [`--isolatedModules`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) enabled.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- const enum Bit { Off, On }
9
- export function f(b: Bit): void;
10
- ```
11
-
12
- **Good**:
13
-
14
- ```ts
15
- export function f(b: 0 | 1): void;
16
- ```
@@ -1,17 +0,0 @@
1
- # no-dead-reference
2
-
3
- A `<reference>` comment should go at the top of a file -- otherwise it is just a normal comment.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- console.log("Hello world!");
9
- /// <reference types="jquery" />
10
- ```
11
-
12
- **Good**:
13
-
14
- ```ts
15
- /// <reference types="jquery" />
16
- console.log("Hello world!");
17
- ```
@@ -1,35 +0,0 @@
1
- # no-declare-current-package
2
-
3
- Avoid using `declare module`, and prefer to declare module contents in a file.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- // foo/index.d.ts
9
- declare module "foo" {
10
- export const x = 0;
11
- }
12
- ```
13
-
14
- **Good**:
15
-
16
- ```ts
17
- // foo/index.d.ts
18
- export const x = 0;
19
- ```
20
-
21
- **Bad**:
22
-
23
- ```ts
24
- // foo/index.d.ts
25
- declare module "foo/bar" {
26
- export const x = 0;
27
- }
28
- ```
29
-
30
- **Good**:
31
-
32
- ```ts
33
- // foo/bar.d.ts
34
- export const x = 0;
35
- ```
@@ -1,22 +0,0 @@
1
- # no-import-default-of-export-equals
2
-
3
- Don't use a default import of a package that uses `export =`.
4
- Users who do not have `--allowSyntheticDefaultExports` or `--esModuleInterop` will get different behavior.
5
- This rule only applies to definition files -- for test files you can use a default import if you prefer.
6
-
7
- **Bad**:
8
-
9
- ```ts
10
- // foo/index.d.ts
11
- declare interface I {}
12
- export = I;
13
-
14
- // bar/index.d.ts
15
- import I from "foo";
16
- ```
17
-
18
- **Good**:
19
-
20
- ```ts
21
- import I = require("foo");
22
- ```
@@ -1,23 +0,0 @@
1
- # no-outside-dependencies
2
-
3
- Don't import from `DefinitelyTyped/node_modules`.
4
-
5
- **Bad**:
6
-
7
- ```ts
8
- import * as x from "x";
9
- // where 'x' is defined only in `DefinitelyTyped/node_modules`
10
- ```
11
-
12
- **Good**:
13
-
14
- Add a `package.json`:
15
-
16
- ```ts
17
- {
18
- "private": true,
19
- "dependencies": {
20
- "x": "^1.2.3"
21
- }
22
- }
23
- ```