@definitelytyped/eslint-plugin 0.0.202 → 0.0.204

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 (366) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +2 -2
  3. package/src/configs/all.ts +0 -189
  4. package/src/index.ts +0 -18
  5. package/src/rules/expect.ts +0 -556
  6. package/src/rules/export-just-namespace.ts +0 -82
  7. package/src/rules/index.ts +0 -43
  8. package/src/rules/no-any-union.ts +0 -33
  9. package/src/rules/no-bad-reference.ts +0 -199
  10. package/src/rules/no-const-enum.ts +0 -31
  11. package/src/rules/no-dead-reference.ts +0 -47
  12. package/src/rules/no-declare-current-package.ts +0 -45
  13. package/src/rules/no-import-default-of-export-equals.ts +0 -68
  14. package/src/rules/no-import-of-dev-dependencies.ts +0 -93
  15. package/src/rules/no-old-dt-header.ts +0 -40
  16. package/src/rules/no-relative-import-in-test.ts +0 -72
  17. package/src/rules/no-self-import.ts +0 -56
  18. package/src/rules/no-single-declare-module.ts +0 -57
  19. package/src/rules/no-single-element-tuple-type.ts +0 -30
  20. package/src/rules/no-unnecessary-generics.ts +0 -119
  21. package/src/rules/no-useless-files.ts +0 -51
  22. package/src/rules/npm-naming/types.ts +0 -14
  23. package/src/rules/npm-naming.ts +0 -211
  24. package/src/rules/prefer-declare-function.ts +0 -37
  25. package/src/rules/redundant-undefined.ts +0 -61
  26. package/src/rules/strict-export-declare-modifiers.ts +0 -195
  27. package/src/suggestions.ts +0 -75
  28. package/src/util.ts +0 -138
  29. package/test/__file_snapshots__/types/expect/expect-tests.ts.lint +0 -79
  30. package/test/__file_snapshots__/types/expect/index.d.ts.lint +0 -19
  31. package/test/__file_snapshots__/types/export-just-namespace/bad1.d.ts.lint +0 -11
  32. package/test/__file_snapshots__/types/export-just-namespace/bad2.d.ts.lint +0 -11
  33. package/test/__file_snapshots__/types/export-just-namespace/bad3.d.ts.lint +0 -12
  34. package/test/__file_snapshots__/types/export-just-namespace/export-just-namespace-tests.ts.lint +0 -10
  35. package/test/__file_snapshots__/types/export-just-namespace/good1.d.ts.lint +0 -5
  36. package/test/__file_snapshots__/types/export-just-namespace/good2.d.ts.lint +0 -5
  37. package/test/__file_snapshots__/types/export-just-namespace/good3.d.ts.lint +0 -5
  38. package/test/__file_snapshots__/types/export-just-namespace/good4.d.ts.lint +0 -5
  39. package/test/__file_snapshots__/types/export-just-namespace/good5.d.ts.lint +0 -5
  40. package/test/__file_snapshots__/types/export-just-namespace/good6.d.ts.lint +0 -5
  41. package/test/__file_snapshots__/types/export-just-namespace/good7.d.ts.lint +0 -7
  42. package/test/__file_snapshots__/types/export-just-namespace/good8.d.ts.lint +0 -7
  43. package/test/__file_snapshots__/types/export-just-namespace/good9.d.ts.lint +0 -15
  44. package/test/__file_snapshots__/types/foo/foo-tests.ts.lint +0 -10
  45. package/test/__file_snapshots__/types/foo/index.d.ts.lint +0 -5
  46. package/test/__file_snapshots__/types/foo/v1/foo-tests.ts.lint +0 -10
  47. package/test/__file_snapshots__/types/foo/v1/index.d.ts.lint +0 -5
  48. package/test/__file_snapshots__/types/no-any-union/bad.d.ts.lint +0 -10
  49. package/test/__file_snapshots__/types/no-any-union/index.d.ts.lint +0 -5
  50. package/test/__file_snapshots__/types/no-any-union/no-any-union-tests.ts.lint +0 -10
  51. package/test/__file_snapshots__/types/no-bad-reference/index.d.ts.lint +0 -43
  52. package/test/__file_snapshots__/types/no-bad-reference/no-bad-reference-tests.ts.lint +0 -14
  53. package/test/__file_snapshots__/types/no-bad-reference/v0.1/index.d.ts.lint +0 -48
  54. package/test/__file_snapshots__/types/no-bad-reference/v0.1/no-bad-reference-tests.ts.lint +0 -10
  55. package/test/__file_snapshots__/types/no-bad-reference/v11/index.d.ts.lint +0 -48
  56. package/test/__file_snapshots__/types/no-bad-reference/v11/no-bad-reference-tests.ts.lint +0 -10
  57. package/test/__file_snapshots__/types/no-const-enum/bad.d.ts.lint +0 -10
  58. package/test/__file_snapshots__/types/no-const-enum/index.d.ts.lint +0 -5
  59. package/test/__file_snapshots__/types/no-const-enum/no-const-enum-tests.ts.lint +0 -10
  60. package/test/__file_snapshots__/types/no-dead-reference/bad.d.ts.lint +0 -18
  61. package/test/__file_snapshots__/types/no-dead-reference/bad2.d.ts.lint +0 -15
  62. package/test/__file_snapshots__/types/no-dead-reference/bad3.d.ts.lint +0 -17
  63. package/test/__file_snapshots__/types/no-dead-reference/index.d.ts.lint +0 -6
  64. package/test/__file_snapshots__/types/no-dead-reference/no-dead-reference-tests.ts.lint +0 -10
  65. package/test/__file_snapshots__/types/no-declare-current-package/index.d.ts.lint +0 -13
  66. package/test/__file_snapshots__/types/no-declare-current-package/no-declare-current-package-tests.ts.lint +0 -10
  67. package/test/__file_snapshots__/types/no-declare-current-package/test/deep/import.d.ts.lint +0 -13
  68. package/test/__file_snapshots__/types/no-declare-current-package-other/index.d.ts.lint +0 -6
  69. package/test/__file_snapshots__/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts.lint +0 -10
  70. package/test/__file_snapshots__/types/no-import-default-of-export-equals/bad.d.ts.lint +0 -17
  71. package/test/__file_snapshots__/types/no-import-default-of-export-equals/index.d.ts.lint +0 -12
  72. package/test/__file_snapshots__/types/no-import-default-of-export-equals/no-import-default-of-export-equals-tests.ts.lint +0 -10
  73. package/test/__file_snapshots__/types/no-import-of-dev-dependencies/bad.d.ts.lint +0 -44
  74. package/test/__file_snapshots__/types/no-import-of-dev-dependencies/index.d.ts.lint +0 -25
  75. package/test/__file_snapshots__/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts.lint +0 -39
  76. package/test/__file_snapshots__/types/no-old-dt-header/index.d.ts.lint +0 -23
  77. package/test/__file_snapshots__/types/no-old-dt-header/index2.d.ts.lint +0 -14
  78. package/test/__file_snapshots__/types/no-old-dt-header/no-old-dt-header-tests.ts.lint +0 -10
  79. package/test/__file_snapshots__/types/no-old-dt-header/ok1.ts.lint +0 -11
  80. package/test/__file_snapshots__/types/no-old-dt-header/ok2.d.ts.lint +0 -10
  81. package/test/__file_snapshots__/types/no-old-dt-header/ok3.d.ts.lint +0 -10
  82. package/test/__file_snapshots__/types/no-old-dt-header/ok4.d.ts.lint +0 -12
  83. package/test/__file_snapshots__/types/no-relative-import-in-test/abc.d.ts.lint +0 -6
  84. package/test/__file_snapshots__/types/no-relative-import-in-test/bad.d.ts.lint +0 -10
  85. package/test/__file_snapshots__/types/no-relative-import-in-test/index.d.ts.lint +0 -5
  86. package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test/abc.d.ts.lint +0 -6
  87. package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts.lint +0 -10
  88. package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts.lint +0 -7
  89. package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts.lint +0 -10
  90. package/test/__file_snapshots__/types/no-relative-references/index.d.ts.lint +0 -51
  91. package/test/__file_snapshots__/types/no-relative-references/no-relative-references-tests.ts.lint +0 -10
  92. package/test/__file_snapshots__/types/no-relative-references/other/other.d.ts.lint +0 -31
  93. package/test/__file_snapshots__/types/no-relative-references/v1/index.d.ts.lint +0 -57
  94. package/test/__file_snapshots__/types/no-relative-references/v1/no-relative-references-tests.ts.lint +0 -10
  95. package/test/__file_snapshots__/types/no-relative-references/v1/other/other.d.ts.lint +0 -31
  96. package/test/__file_snapshots__/types/no-self-import/bad.d.ts.lint +0 -65
  97. package/test/__file_snapshots__/types/no-self-import/index.d.ts.lint +0 -19
  98. package/test/__file_snapshots__/types/no-self-import/no-self-import-tests.ts.lint +0 -39
  99. package/test/__file_snapshots__/types/no-single-declare-module/bad.d.ts.lint +0 -13
  100. package/test/__file_snapshots__/types/no-single-declare-module/index.d.ts.lint +0 -6
  101. package/test/__file_snapshots__/types/no-single-declare-module/index2.d.ts.lint +0 -6
  102. package/test/__file_snapshots__/types/no-single-declare-module/index3.d.ts.lint +0 -5
  103. package/test/__file_snapshots__/types/no-single-declare-module/no-single-declare-module-tests.ts.lint +0 -10
  104. package/test/__file_snapshots__/types/no-single-element-tuple-type/bad.d.ts.lint +0 -10
  105. package/test/__file_snapshots__/types/no-single-element-tuple-type/index.d.ts.lint +0 -9
  106. package/test/__file_snapshots__/types/no-single-element-tuple-type/no-single-element-tuple-type-tests.ts.lint +0 -10
  107. package/test/__file_snapshots__/types/no-unnecessary-generics/bad.d.ts.lint +0 -14
  108. package/test/__file_snapshots__/types/no-unnecessary-generics/index.d.ts.lint +0 -11
  109. package/test/__file_snapshots__/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts.lint +0 -44
  110. package/test/__file_snapshots__/types/no-useless-files/bad.d.ts.lint +0 -10
  111. package/test/__file_snapshots__/types/no-useless-files/bad2.d.ts.lint +0 -10
  112. package/test/__file_snapshots__/types/no-useless-files/bad3.d.ts.lint +0 -10
  113. package/test/__file_snapshots__/types/no-useless-files/index.d.ts.lint +0 -5
  114. package/test/__file_snapshots__/types/no-useless-files/index2.d.ts.lint +0 -5
  115. package/test/__file_snapshots__/types/no-useless-files/index3.d.ts.lint +0 -5
  116. package/test/__file_snapshots__/types/no-useless-files/no-useless-files-tests.ts.lint +0 -10
  117. package/test/__file_snapshots__/types/other/index.d.ts.lint +0 -5
  118. package/test/__file_snapshots__/types/other/other-tests.ts.lint +0 -10
  119. package/test/__file_snapshots__/types/other/v1/index.d.ts.lint +0 -5
  120. package/test/__file_snapshots__/types/other/v1/other-tests.ts.lint +0 -10
  121. package/test/__file_snapshots__/types/prefer-declare-function/bad.d.ts.lint +0 -33
  122. package/test/__file_snapshots__/types/prefer-declare-function/index.d.ts.lint +0 -14
  123. package/test/__file_snapshots__/types/prefer-declare-function/prefer-declare-function-tests.ts.lint +0 -10
  124. package/test/__file_snapshots__/types/redundant-undefined/bad.d.ts.lint +0 -15
  125. package/test/__file_snapshots__/types/redundant-undefined/index.d.ts.lint +0 -9
  126. package/test/__file_snapshots__/types/redundant-undefined/redundant-undefined-tests.ts.lint +0 -10
  127. package/test/__file_snapshots__/types/scoped__foo/index.d.ts.lint +0 -5
  128. package/test/__file_snapshots__/types/scoped__foo/scoped__foo-tests.ts.lint +0 -10
  129. package/test/__file_snapshots__/types/scoped__foo/v1/index.d.ts.lint +0 -5
  130. package/test/__file_snapshots__/types/scoped__foo/v1/scoped__foo-tests.ts.lint +0 -10
  131. package/test/__file_snapshots__/types/scoped__no-declare-current-package/index.d.ts.lint +0 -13
  132. package/test/__file_snapshots__/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts.lint +0 -10
  133. package/test/__file_snapshots__/types/scoped__no-declare-current-package/test/deep/import.d.ts.lint +0 -13
  134. package/test/__file_snapshots__/types/scoped__no-relative-references/index.d.ts.lint +0 -51
  135. package/test/__file_snapshots__/types/scoped__no-relative-references/no-relative-references-tests.ts.lint +0 -10
  136. package/test/__file_snapshots__/types/scoped__no-relative-references/other/other.d.ts.lint +0 -31
  137. package/test/__file_snapshots__/types/scoped__no-relative-references/v1/index.d.ts.lint +0 -57
  138. package/test/__file_snapshots__/types/scoped__no-relative-references/v1/no-relative-references-tests.ts.lint +0 -10
  139. package/test/__file_snapshots__/types/scoped__no-relative-references/v1/other/other.d.ts.lint +0 -31
  140. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad1.d.ts.lint +0 -10
  141. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad2.d.ts.lint +0 -12
  142. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad3.d.ts.lint +0 -10
  143. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad4.d.ts.lint +0 -12
  144. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad5.d.ts.lint +0 -11
  145. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad6.d.ts.lint +0 -14
  146. package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad7.d.ts.lint +0 -14
  147. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good1.ts.lint +0 -5
  148. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good2.d.ts.lint +0 -5
  149. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good3.d.ts.lint +0 -5
  150. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good4.d.ts.lint +0 -5
  151. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good5.d.ts.lint +0 -5
  152. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good6.ts.lint +0 -7
  153. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good7.d.ts.lint +0 -6
  154. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good8.d.ts.lint +0 -9
  155. package/test/__file_snapshots__/types/strict-export-declare-modifiers/good9.d.ts.lint +0 -7
  156. package/test/__file_snapshots__/types/strict-export-declare-modifiers/strict-export-declare-modifiers-tests.ts.lint +0 -10
  157. package/test/__snapshots__/plugin.test.ts.snap +0 -262
  158. package/test/eslint.test.ts +0 -134
  159. package/test/fixtures/.eslintrc.cjs +0 -4
  160. package/test/fixtures/notNeededPackages.json +0 -3
  161. package/test/fixtures/package.json +0 -4
  162. package/test/fixtures/types/expect/expect-tests.ts +0 -49
  163. package/test/fixtures/types/expect/index.d.ts +0 -9
  164. package/test/fixtures/types/expect/package.json +0 -5
  165. package/test/fixtures/types/expect/tsconfig.json +0 -20
  166. package/test/fixtures/types/export-just-namespace/bad1.d.ts +0 -2
  167. package/test/fixtures/types/export-just-namespace/bad2.d.ts +0 -2
  168. package/test/fixtures/types/export-just-namespace/bad3.d.ts +0 -3
  169. package/test/fixtures/types/export-just-namespace/export-just-namespace-tests.ts +0 -0
  170. package/test/fixtures/types/export-just-namespace/good1.d.ts +0 -1
  171. package/test/fixtures/types/export-just-namespace/good2.d.ts +0 -1
  172. package/test/fixtures/types/export-just-namespace/good3.d.ts +0 -1
  173. package/test/fixtures/types/export-just-namespace/good4.d.ts +0 -1
  174. package/test/fixtures/types/export-just-namespace/good5.d.ts +0 -1
  175. package/test/fixtures/types/export-just-namespace/good6.d.ts +0 -1
  176. package/test/fixtures/types/export-just-namespace/good7.d.ts +0 -3
  177. package/test/fixtures/types/export-just-namespace/good8.d.ts +0 -3
  178. package/test/fixtures/types/export-just-namespace/good9.d.ts +0 -3
  179. package/test/fixtures/types/export-just-namespace/package.json +0 -8
  180. package/test/fixtures/types/export-just-namespace/tsconfig.json +0 -31
  181. package/test/fixtures/types/foo/foo-tests.ts +0 -0
  182. package/test/fixtures/types/foo/index.d.ts +0 -1
  183. package/test/fixtures/types/foo/package.json +0 -5
  184. package/test/fixtures/types/foo/tsconfig.json +0 -20
  185. package/test/fixtures/types/foo/v1/foo-tests.ts +0 -0
  186. package/test/fixtures/types/foo/v1/index.d.ts +0 -1
  187. package/test/fixtures/types/foo/v1/package.json +0 -5
  188. package/test/fixtures/types/foo/v1/tsconfig.json +0 -20
  189. package/test/fixtures/types/no-any-union/bad.d.ts +0 -1
  190. package/test/fixtures/types/no-any-union/index.d.ts +0 -1
  191. package/test/fixtures/types/no-any-union/no-any-union-tests.ts +0 -1
  192. package/test/fixtures/types/no-any-union/package.json +0 -8
  193. package/test/fixtures/types/no-any-union/tsconfig.json +0 -21
  194. package/test/fixtures/types/no-bad-reference/index.d.ts +0 -16
  195. package/test/fixtures/types/no-bad-reference/no-bad-reference-tests.ts +0 -2
  196. package/test/fixtures/types/no-bad-reference/package.json +0 -5
  197. package/test/fixtures/types/no-bad-reference/tsconfig.json +0 -20
  198. package/test/fixtures/types/no-bad-reference/v0.1/index.d.ts +0 -15
  199. package/test/fixtures/types/no-bad-reference/v0.1/no-bad-reference-tests.ts +0 -0
  200. package/test/fixtures/types/no-bad-reference/v0.1/package.json +0 -5
  201. package/test/fixtures/types/no-bad-reference/v0.1/tsconfig.json +0 -20
  202. package/test/fixtures/types/no-bad-reference/v11/index.d.ts +0 -15
  203. package/test/fixtures/types/no-bad-reference/v11/no-bad-reference-tests.ts +0 -0
  204. package/test/fixtures/types/no-bad-reference/v11/package.json +0 -5
  205. package/test/fixtures/types/no-bad-reference/v11/tsconfig.json +0 -20
  206. package/test/fixtures/types/no-const-enum/bad.d.ts +0 -1
  207. package/test/fixtures/types/no-const-enum/index.d.ts +0 -1
  208. package/test/fixtures/types/no-const-enum/no-const-enum-tests.ts +0 -0
  209. package/test/fixtures/types/no-const-enum/package.json +0 -8
  210. package/test/fixtures/types/no-const-enum/tsconfig.json +0 -21
  211. package/test/fixtures/types/no-dead-reference/bad.d.ts +0 -6
  212. package/test/fixtures/types/no-dead-reference/bad2.d.ts +0 -3
  213. package/test/fixtures/types/no-dead-reference/bad3.d.ts +0 -5
  214. package/test/fixtures/types/no-dead-reference/index.d.ts +0 -2
  215. package/test/fixtures/types/no-dead-reference/no-dead-reference-tests.ts +0 -0
  216. package/test/fixtures/types/no-dead-reference/package.json +0 -8
  217. package/test/fixtures/types/no-dead-reference/tsconfig.json +0 -23
  218. package/test/fixtures/types/no-declare-current-package/index.d.ts +0 -1
  219. package/test/fixtures/types/no-declare-current-package/no-declare-current-package-tests.ts +0 -0
  220. package/test/fixtures/types/no-declare-current-package/package.json +0 -8
  221. package/test/fixtures/types/no-declare-current-package/test/deep/import.d.ts +0 -1
  222. package/test/fixtures/types/no-declare-current-package/tsconfig.json +0 -21
  223. package/test/fixtures/types/no-declare-current-package-other/index.d.ts +0 -2
  224. package/test/fixtures/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts +0 -0
  225. package/test/fixtures/types/no-declare-current-package-other/package.json +0 -8
  226. package/test/fixtures/types/no-declare-current-package-other/tsconfig.json +0 -20
  227. package/test/fixtures/types/no-import-default-of-export-equals/bad.d.ts +0 -8
  228. package/test/fixtures/types/no-import-default-of-export-equals/index.d.ts +0 -8
  229. package/test/fixtures/types/no-import-default-of-export-equals/no-import-default-of-export-equals-tests.ts +0 -0
  230. package/test/fixtures/types/no-import-default-of-export-equals/package.json +0 -8
  231. package/test/fixtures/types/no-import-default-of-export-equals/tsconfig.json +0 -21
  232. package/test/fixtures/types/no-import-of-dev-dependencies/bad.d.ts +0 -8
  233. package/test/fixtures/types/no-import-of-dev-dependencies/index.d.ts +0 -7
  234. package/test/fixtures/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts +0 -15
  235. package/test/fixtures/types/no-import-of-dev-dependencies/package.json +0 -14
  236. package/test/fixtures/types/no-import-of-dev-dependencies/tsconfig.json +0 -21
  237. package/test/fixtures/types/no-old-dt-header/index.d.ts +0 -14
  238. package/test/fixtures/types/no-old-dt-header/index2.d.ts +0 -2
  239. package/test/fixtures/types/no-old-dt-header/no-old-dt-header-tests.ts +0 -0
  240. package/test/fixtures/types/no-old-dt-header/ok1.ts +0 -2
  241. package/test/fixtures/types/no-old-dt-header/ok2.d.ts +0 -1
  242. package/test/fixtures/types/no-old-dt-header/ok3.d.ts +0 -1
  243. package/test/fixtures/types/no-old-dt-header/ok4.d.ts +0 -3
  244. package/test/fixtures/types/no-old-dt-header/package.json +0 -8
  245. package/test/fixtures/types/no-old-dt-header/tsconfig.json +0 -25
  246. package/test/fixtures/types/no-relative-import-in-test/abc.d.ts +0 -2
  247. package/test/fixtures/types/no-relative-import-in-test/bad.d.ts +0 -0
  248. package/test/fixtures/types/no-relative-import-in-test/index.d.ts +0 -1
  249. package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test/abc.d.ts +0 -2
  250. package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts +0 -1
  251. package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts +0 -3
  252. package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts +0 -1
  253. package/test/fixtures/types/no-relative-import-in-test/package.json +0 -8
  254. package/test/fixtures/types/no-relative-import-in-test/tsconfig.json +0 -25
  255. package/test/fixtures/types/no-relative-references/index.d.ts +0 -12
  256. package/test/fixtures/types/no-relative-references/no-relative-references-tests.ts +0 -0
  257. package/test/fixtures/types/no-relative-references/other/other.d.ts +0 -7
  258. package/test/fixtures/types/no-relative-references/package.json +0 -5
  259. package/test/fixtures/types/no-relative-references/tsconfig.json +0 -21
  260. package/test/fixtures/types/no-relative-references/v1/index.d.ts +0 -15
  261. package/test/fixtures/types/no-relative-references/v1/no-relative-references-tests.ts +0 -0
  262. package/test/fixtures/types/no-relative-references/v1/other/other.d.ts +0 -7
  263. package/test/fixtures/types/no-relative-references/v1/package.json +0 -5
  264. package/test/fixtures/types/no-relative-references/v1/tsconfig.json +0 -21
  265. package/test/fixtures/types/no-self-import/bad.d.ts +0 -17
  266. package/test/fixtures/types/no-self-import/index.d.ts +0 -15
  267. package/test/fixtures/types/no-self-import/no-self-import-tests.ts +0 -15
  268. package/test/fixtures/types/no-self-import/package.json +0 -11
  269. package/test/fixtures/types/no-self-import/tsconfig.json +0 -21
  270. package/test/fixtures/types/no-single-declare-module/bad.d.ts +0 -4
  271. package/test/fixtures/types/no-single-declare-module/index.d.ts +0 -2
  272. package/test/fixtures/types/no-single-declare-module/index2.d.ts +0 -2
  273. package/test/fixtures/types/no-single-declare-module/index3.d.ts +0 -1
  274. package/test/fixtures/types/no-single-declare-module/no-single-declare-module-tests.ts +0 -0
  275. package/test/fixtures/types/no-single-declare-module/package.json +0 -8
  276. package/test/fixtures/types/no-single-declare-module/tsconfig.json +0 -23
  277. package/test/fixtures/types/no-single-element-tuple-type/bad.d.ts +0 -1
  278. package/test/fixtures/types/no-single-element-tuple-type/index.d.ts +0 -5
  279. package/test/fixtures/types/no-single-element-tuple-type/no-single-element-tuple-type-tests.ts +0 -0
  280. package/test/fixtures/types/no-single-element-tuple-type/package.json +0 -8
  281. package/test/fixtures/types/no-single-element-tuple-type/tsconfig.json +0 -21
  282. package/test/fixtures/types/no-unnecessary-generics/bad.d.ts +0 -2
  283. package/test/fixtures/types/no-unnecessary-generics/index.d.ts +0 -7
  284. package/test/fixtures/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts +0 -14
  285. package/test/fixtures/types/no-unnecessary-generics/package.json +0 -8
  286. package/test/fixtures/types/no-unnecessary-generics/tsconfig.json +0 -21
  287. package/test/fixtures/types/no-useless-files/bad.d.ts +0 -1
  288. package/test/fixtures/types/no-useless-files/bad2.d.ts +0 -0
  289. package/test/fixtures/types/no-useless-files/bad3.d.ts +0 -1
  290. package/test/fixtures/types/no-useless-files/index.d.ts +0 -1
  291. package/test/fixtures/types/no-useless-files/index2.d.ts +0 -1
  292. package/test/fixtures/types/no-useless-files/index3.d.ts +0 -1
  293. package/test/fixtures/types/no-useless-files/no-useless-files-tests.ts +0 -0
  294. package/test/fixtures/types/no-useless-files/package.json +0 -8
  295. package/test/fixtures/types/no-useless-files/tsconfig.json +0 -25
  296. package/test/fixtures/types/other/index.d.ts +0 -1
  297. package/test/fixtures/types/other/other-tests.ts +0 -0
  298. package/test/fixtures/types/other/package.json +0 -5
  299. package/test/fixtures/types/other/tsconfig.json +0 -20
  300. package/test/fixtures/types/other/v1/index.d.ts +0 -1
  301. package/test/fixtures/types/other/v1/other-tests.ts +0 -0
  302. package/test/fixtures/types/other/v1/package.json +0 -5
  303. package/test/fixtures/types/other/v1/tsconfig.json +0 -20
  304. package/test/fixtures/types/prefer-declare-function/bad.d.ts +0 -9
  305. package/test/fixtures/types/prefer-declare-function/index.d.ts +0 -2
  306. package/test/fixtures/types/prefer-declare-function/package.json +0 -8
  307. package/test/fixtures/types/prefer-declare-function/prefer-declare-function-tests.ts +0 -0
  308. package/test/fixtures/types/prefer-declare-function/tsconfig.json +0 -21
  309. package/test/fixtures/types/redundant-undefined/bad.d.ts +0 -3
  310. package/test/fixtures/types/redundant-undefined/index.d.ts +0 -5
  311. package/test/fixtures/types/redundant-undefined/package.json +0 -8
  312. package/test/fixtures/types/redundant-undefined/redundant-undefined-tests.ts +0 -1
  313. package/test/fixtures/types/redundant-undefined/tsconfig.json +0 -21
  314. package/test/fixtures/types/scoped__foo/index.d.ts +0 -1
  315. package/test/fixtures/types/scoped__foo/package.json +0 -5
  316. package/test/fixtures/types/scoped__foo/scoped__foo-tests.ts +0 -0
  317. package/test/fixtures/types/scoped__foo/tsconfig.json +0 -20
  318. package/test/fixtures/types/scoped__foo/v1/index.d.ts +0 -1
  319. package/test/fixtures/types/scoped__foo/v1/package.json +0 -5
  320. package/test/fixtures/types/scoped__foo/v1/scoped__foo-tests.ts +0 -0
  321. package/test/fixtures/types/scoped__foo/v1/tsconfig.json +0 -20
  322. package/test/fixtures/types/scoped__no-declare-current-package/index.d.ts +0 -1
  323. package/test/fixtures/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts +0 -0
  324. package/test/fixtures/types/scoped__no-declare-current-package/package.json +0 -8
  325. package/test/fixtures/types/scoped__no-declare-current-package/test/deep/import.d.ts +0 -1
  326. package/test/fixtures/types/scoped__no-declare-current-package/tsconfig.json +0 -21
  327. package/test/fixtures/types/scoped__no-relative-references/index.d.ts +0 -12
  328. package/test/fixtures/types/scoped__no-relative-references/no-relative-references-tests.ts +0 -0
  329. package/test/fixtures/types/scoped__no-relative-references/other/other.d.ts +0 -7
  330. package/test/fixtures/types/scoped__no-relative-references/package.json +0 -5
  331. package/test/fixtures/types/scoped__no-relative-references/tsconfig.json +0 -21
  332. package/test/fixtures/types/scoped__no-relative-references/v1/index.d.ts +0 -15
  333. package/test/fixtures/types/scoped__no-relative-references/v1/no-relative-references-tests.ts +0 -0
  334. package/test/fixtures/types/scoped__no-relative-references/v1/other/other.d.ts +0 -7
  335. package/test/fixtures/types/scoped__no-relative-references/v1/package.json +0 -5
  336. package/test/fixtures/types/scoped__no-relative-references/v1/tsconfig.json +0 -21
  337. package/test/fixtures/types/strict-export-declare-modifiers/bad1.d.ts +0 -1
  338. package/test/fixtures/types/strict-export-declare-modifiers/bad2.d.ts +0 -3
  339. package/test/fixtures/types/strict-export-declare-modifiers/bad3.d.ts +0 -1
  340. package/test/fixtures/types/strict-export-declare-modifiers/bad4.d.ts +0 -3
  341. package/test/fixtures/types/strict-export-declare-modifiers/bad5.d.ts +0 -2
  342. package/test/fixtures/types/strict-export-declare-modifiers/bad6.d.ts +0 -2
  343. package/test/fixtures/types/strict-export-declare-modifiers/bad7.d.ts +0 -2
  344. package/test/fixtures/types/strict-export-declare-modifiers/good1.ts +0 -1
  345. package/test/fixtures/types/strict-export-declare-modifiers/good2.d.ts +0 -1
  346. package/test/fixtures/types/strict-export-declare-modifiers/good3.d.ts +0 -1
  347. package/test/fixtures/types/strict-export-declare-modifiers/good4.d.ts +0 -1
  348. package/test/fixtures/types/strict-export-declare-modifiers/good5.d.ts +0 -1
  349. package/test/fixtures/types/strict-export-declare-modifiers/good6.ts +0 -3
  350. package/test/fixtures/types/strict-export-declare-modifiers/good7.d.ts +0 -2
  351. package/test/fixtures/types/strict-export-declare-modifiers/good8.d.ts +0 -5
  352. package/test/fixtures/types/strict-export-declare-modifiers/good9.d.ts +0 -3
  353. package/test/fixtures/types/strict-export-declare-modifiers/package.json +0 -8
  354. package/test/fixtures/types/strict-export-declare-modifiers/strict-export-declare-modifiers-tests.ts +0 -0
  355. package/test/fixtures/types/strict-export-declare-modifiers/tsconfig.json +0 -35
  356. package/test/npm-naming.test.ts +0 -57
  357. package/test/plugin.test.ts +0 -14
  358. package/test/tsconfig.json +0 -13
  359. package/test/types/dts-critic/index.d.ts +0 -9
  360. package/test/types/dts-critic/package.json +0 -17
  361. package/test/types/wenceslas/index.d.ts +0 -0
  362. package/test/types/wenceslas/package.json +0 -17
  363. package/test/util.test.ts +0 -40
  364. package/test/util.ts +0 -3
  365. package/tsconfig.json +0 -11
  366. package/tsconfig.tsbuildinfo +0 -1
@@ -1,33 +0,0 @@
1
- import { createRule } from "../util";
2
- import { AST_NODE_TYPES } from "@typescript-eslint/utils";
3
-
4
- const rule = createRule({
5
- name: "no-any-union",
6
- defaultOptions: [],
7
- meta: {
8
- type: "problem",
9
- docs: {
10
- description: "Forbid a union to contain `any`",
11
- },
12
- messages: {
13
- anyUnion: "Including `any` in a union will override all other members of the union.",
14
- },
15
- schema: [],
16
- },
17
- create(context) {
18
- return {
19
- // eslint-disable-next-line @typescript-eslint/naming-convention
20
- TSUnionType(node) {
21
- const hasAnyType = node.types.some((t) => t.type === AST_NODE_TYPES.TSAnyKeyword);
22
- if (hasAnyType) {
23
- context.report({
24
- messageId: "anyUnion",
25
- node,
26
- });
27
- }
28
- },
29
- };
30
- },
31
- });
32
-
33
- export = rule;
@@ -1,199 +0,0 @@
1
- import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
- import { createRule, findTypesPackage } from "../util";
3
- import * as ts from "typescript";
4
- import path from "path";
5
- import { isDeclarationPath } from "@definitelytyped/utils";
6
-
7
- interface Reference {
8
- kind: "path" | "import" | "types";
9
- text: string;
10
- range: ts.TextRange;
11
- }
12
-
13
- const rule = createRule({
14
- name: "no-bad-reference",
15
- defaultOptions: [],
16
- meta: {
17
- type: "problem",
18
- docs: {
19
- description:
20
- "Forbids bad references, including those that resolve outside of the package or path references in non-declaration files.",
21
- },
22
- messages: {
23
- importOutside:
24
- 'The import "{{text}}" resolves outside of the package. Use a bare import to reference other packages.',
25
- importLeaves: 'The import "{{text}}" resolves to the current package, but uses relative paths.',
26
- referenceOutside:
27
- 'The reference "{{text}}" resolves outside of the package. Use a global reference to reference other packages.',
28
- referenceLeaves: 'The reference "{{text}}" resolves to the current package, but uses relative paths.',
29
- testReference:
30
- 'The path reference "{{text}}" is disallowed outside declaration files. Use "<reference types>" or include the file in tsconfig instead.',
31
- backslashes: "Use forward slashes in paths.",
32
- },
33
- schema: [],
34
- },
35
- create(context) {
36
- const containingFileName = context.filename;
37
- const typesPackage = findTypesPackage(containingFileName);
38
- if (!typesPackage) {
39
- return {};
40
- }
41
-
42
- const containingDirectory = path.dirname(containingFileName);
43
-
44
- const realNamePlusSlash = typesPackage.realName + "/";
45
- function isRelativeOrSelf(name: string) {
46
- return name.startsWith(".") || name.startsWith(realNamePlusSlash);
47
- }
48
-
49
- const ast = context.sourceCode.ast;
50
- const parserServices = ESLintUtils.getParserServices(context, true);
51
- const sourceFile = parserServices.esTreeNodeToTSNodeMap.get(ast);
52
-
53
- const refs: Reference[] = [];
54
- for (const ref of sourceFile.referencedFiles) {
55
- if (isDeclarationPath(containingFileName)) {
56
- refs.push({ kind: "path", text: ref.fileName, range: ref });
57
- } else {
58
- context.report({
59
- messageId: "testReference",
60
- loc: tsRangeToESLintLocation(ref),
61
- data: { text: ref.fileName },
62
- });
63
- }
64
- }
65
- for (const ref of sourceFile.typeReferenceDirectives) {
66
- if (isRelativeOrSelf(ref.fileName)) {
67
- refs.push({ kind: "types", text: ref.fileName, range: ref });
68
- }
69
- }
70
- for (const ref of imports(sourceFile)) {
71
- if (isRelativeOrSelf(ref.text)) {
72
- refs.push({ kind: "import", text: ref.text, range: { pos: ref.getStart(), end: ref.getEnd() } });
73
- }
74
- }
75
-
76
- for (const ref of refs) {
77
- if (ref.text.includes("\\")) {
78
- context.report({
79
- messageId: "backslashes",
80
- loc: tsRangeToESLintLocation(ref.range),
81
- });
82
- }
83
-
84
- const p = ref.text.startsWith(realNamePlusSlash)
85
- ? path.posix.join(
86
- path.posix.relative(containingDirectory, typesPackage.dir),
87
- ref.text.slice(realNamePlusSlash.length),
88
- )
89
- : ref.text;
90
-
91
- const resolved = path.resolve(containingDirectory, p);
92
- const otherPackage = findTypesPackage(resolved);
93
-
94
- if (otherPackage && otherPackage.dir === typesPackage.dir) {
95
- // Perf trick; if a path doesn't have ".." anywhere, then it can't have resolved
96
- // up and out of a package dir so we can skip this work.
97
- if (p.includes("..")) {
98
- // If we resolved to something in the correct package, we still could have
99
- // gotten here by leaving the package (up into a parent, or down into a versioned dir).
100
- // Manually walk the path to see if that happened.
101
- const parts = p.split("/");
102
- let cwd = containingDirectory;
103
- for (const part of parts) {
104
- if (part === "" || part === ".") {
105
- continue;
106
- }
107
- if (part === "..") {
108
- cwd = path.posix.dirname(cwd);
109
- } else {
110
- cwd = path.posix.join(cwd, part);
111
- }
112
- const otherPackage = findTypesPackage(cwd);
113
- if (otherPackage && otherPackage.dir === typesPackage.dir) {
114
- continue;
115
- }
116
-
117
- context.report({
118
- messageId: ref.kind === "import" ? "importLeaves" : "referenceLeaves",
119
- loc: tsRangeToESLintLocation(ref.range),
120
- data: { text: ref.text },
121
- });
122
- }
123
- }
124
-
125
- continue;
126
- }
127
-
128
- context.report({
129
- messageId: ref.kind === "import" ? "importOutside" : "referenceOutside",
130
- loc: tsRangeToESLintLocation(ref.range),
131
- data: { text: ref.text },
132
- });
133
- }
134
-
135
- return {};
136
-
137
- function tsRangeToESLintLocation(range: ts.TextRange): TSESTree.SourceLocation {
138
- return {
139
- // line is 1 indexed, but column is 0 indexed. >.<
140
- start: context.sourceCode.getLocFromIndex(range.pos),
141
- end: context.sourceCode.getLocFromIndex(range.end),
142
- };
143
- }
144
- },
145
- });
146
-
147
- /**
148
- * All strings referenced in `import` statements.
149
- * Does *not* include <reference> directives.
150
- */
151
- function imports({ statements }: ts.SourceFile): Iterable<ts.StringLiteralLike> {
152
- const result: ts.StringLiteralLike[] = [];
153
- for (const node of statements) {
154
- recur(node);
155
- }
156
- return result;
157
-
158
- function recur(node: ts.Node) {
159
- switch (node.kind) {
160
- case ts.SyntaxKind.ImportDeclaration:
161
- case ts.SyntaxKind.ExportDeclaration: {
162
- const { moduleSpecifier } = node as ts.ImportDeclaration | ts.ExportDeclaration;
163
- if (moduleSpecifier && moduleSpecifier.kind === ts.SyntaxKind.StringLiteral) {
164
- result.push(moduleSpecifier as ts.StringLiteral);
165
- }
166
- break;
167
- }
168
-
169
- case ts.SyntaxKind.ImportEqualsDeclaration: {
170
- const { moduleReference } = node as ts.ImportEqualsDeclaration;
171
- if (moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) {
172
- result.push(parseRequire(moduleReference));
173
- }
174
- break;
175
- }
176
-
177
- case ts.SyntaxKind.ImportType: {
178
- const { argument } = node as ts.ImportTypeNode;
179
- if (ts.isLiteralTypeNode(argument) && ts.isStringLiteral(argument.literal)) {
180
- result.push(argument.literal);
181
- }
182
- break;
183
- }
184
-
185
- default:
186
- ts.forEachChild(node, recur);
187
- }
188
- }
189
- }
190
-
191
- function parseRequire(reference: ts.ExternalModuleReference): ts.StringLiteralLike {
192
- const { expression } = reference;
193
- if (!expression || !ts.isStringLiteral(expression)) {
194
- throw new Error(`Bad 'import =' reference: ${reference.getText()}`);
195
- }
196
- return expression;
197
- }
198
-
199
- export = rule;
@@ -1,31 +0,0 @@
1
- import { createRule } from "../util";
2
-
3
- const rule = createRule({
4
- name: "no-const-enum",
5
- defaultOptions: [],
6
- meta: {
7
- type: "problem",
8
- docs: {
9
- description: "Forbid `const enum`",
10
- },
11
- messages: {
12
- constEnum: "Use of `const enum` is forbidden.",
13
- },
14
- schema: [],
15
- },
16
- create(context) {
17
- return {
18
- // eslint-disable-next-line @typescript-eslint/naming-convention
19
- TSEnumDeclaration(node) {
20
- if (node.const) {
21
- context.report({
22
- messageId: "constEnum",
23
- node,
24
- });
25
- }
26
- },
27
- };
28
- },
29
- });
30
-
31
- export = rule;
@@ -1,47 +0,0 @@
1
- import { createRule } from "../util";
2
-
3
- const rule = createRule({
4
- name: "no-dead-reference",
5
- defaultOptions: [],
6
- meta: {
7
- type: "problem",
8
- docs: {
9
- description: "Ensures that all `/// <reference>` comments go at the top of the file.",
10
- },
11
- messages: {
12
- referenceAtTop: "`/// <reference>` directive must be at top of file to take effect.",
13
- },
14
- schema: [],
15
- },
16
- create(context) {
17
- const source = context.sourceCode;
18
- if (source.ast.body.length) {
19
- // 'm' flag makes it multiline, so `^` matches the beginning of any line.
20
- // 'g' flag lets us set rgx.lastIndex
21
- const rgx = /^\s*(\/\/\/ <reference.*)/gm;
22
-
23
- // Start search at the first statement. (`/// <reference>` before that is OK.)
24
- rgx.lastIndex = source.ast.body[0].range?.[0] ?? 0;
25
-
26
- while (true) {
27
- const match = rgx.exec(source.text);
28
- if (match === null) {
29
- break;
30
- }
31
-
32
- const length = match[1].length;
33
- const start = match.index + match[0].length - length;
34
- context.report({
35
- messageId: "referenceAtTop",
36
- loc: {
37
- start: source.getLocFromIndex(start),
38
- end: source.getLocFromIndex(start + match[1].length),
39
- },
40
- });
41
- }
42
- }
43
- return {};
44
- },
45
- });
46
-
47
- export = rule;
@@ -1,45 +0,0 @@
1
- import { createRule, getTypesPackageForDeclarationFile } from "../util";
2
- import { AST_NODE_TYPES } from "@typescript-eslint/utils";
3
-
4
- const rule = createRule({
5
- name: "no-declare-current-package",
6
- defaultOptions: [],
7
- meta: {
8
- type: "problem",
9
- docs: {
10
- description: "Don't use an ambient module declaration of the current package; use a normal module.",
11
- },
12
- messages: {
13
- noDeclareCurrentPackage:
14
- `Instead of declaring a module with \`declare module "{{ text }}"\`, ` +
15
- `write its contents in directly in {{ preferred }}.`,
16
- },
17
- schema: [],
18
- },
19
- create(context) {
20
- const packageName = getTypesPackageForDeclarationFile(context.filename);
21
- if (!packageName) {
22
- return {};
23
- }
24
-
25
- return {
26
- // eslint-disable-next-line @typescript-eslint/naming-convention
27
- TSModuleDeclaration(node) {
28
- if (
29
- node.id.type === AST_NODE_TYPES.Literal &&
30
- (node.id.value === packageName || node.id.value.startsWith(packageName + "/"))
31
- ) {
32
- const text = node.id.value;
33
- const preferred = text === packageName ? '"index.d.ts"' : `"${text}.d.ts" or "${text}/index.d.ts"`;
34
- context.report({
35
- messageId: "noDeclareCurrentPackage",
36
- data: { text, preferred },
37
- node: node.id,
38
- });
39
- }
40
- },
41
- };
42
- },
43
- });
44
-
45
- export = rule;
@@ -1,68 +0,0 @@
1
- import { isDeclarationPath } from "@definitelytyped/utils";
2
- import { createRule } from "../util";
3
- import { ESLintUtils } from "@typescript-eslint/utils";
4
- import * as ts from "typescript";
5
-
6
- const rule = createRule({
7
- name: "no-import-default-of-export-equals",
8
- defaultOptions: [],
9
- meta: {
10
- type: "problem",
11
- docs: {
12
- description: "Forbid a default import to reference an `export =` module.",
13
- },
14
- messages: {
15
- noImportDefaultOfExportEquals: `The module {{moduleName}} uses \`export = \`. Import with \`import {{importName}} = require({{moduleName}})\`.`,
16
- },
17
- schema: [],
18
- },
19
- create(context) {
20
- const parserServices = ESLintUtils.getParserServices(context);
21
- const checker = parserServices.program.getTypeChecker();
22
- if (isDeclarationPath(context.filename)) {
23
- return {
24
- // eslint-disable-next-line @typescript-eslint/naming-convention
25
- ImportDeclaration(node) {
26
- const defaultName = node.specifiers.find((spec) => spec.type === "ImportDefaultSpecifier")?.local;
27
- if (!defaultName) {
28
- return;
29
- }
30
- const importName = defaultName.name;
31
- const source = parserServices.esTreeNodeToTSNodeMap.get(node.source);
32
- const sym = checker.getSymbolAtLocation(source);
33
- if (
34
- sym?.declarations?.some(
35
- (d) => getStatements(d)?.some((s) => ts.isExportAssignment(s) && !!s.isExportEquals),
36
- )
37
- ) {
38
- context.report({
39
- messageId: "noImportDefaultOfExportEquals",
40
- data: { moduleName: node.source.value, importName },
41
- node: defaultName,
42
- });
43
- }
44
- },
45
- };
46
- } else {
47
- return {};
48
- }
49
- },
50
- });
51
-
52
- function getStatements(decl: ts.Declaration): readonly ts.Statement[] | undefined {
53
- return ts.isSourceFile(decl)
54
- ? decl.statements
55
- : ts.isModuleDeclaration(decl)
56
- ? getModuleDeclarationStatements(decl)
57
- : undefined;
58
- }
59
-
60
- function getModuleDeclarationStatements(node: ts.ModuleDeclaration): readonly ts.Statement[] | undefined {
61
- let { body } = node;
62
- while (body && body.kind === ts.SyntaxKind.ModuleDeclaration) {
63
- body = body.body;
64
- }
65
- return body && ts.isModuleBlock(body) ? body.statements : undefined;
66
- }
67
-
68
- export = rule;
@@ -1,93 +0,0 @@
1
- import { TSESTree } from "@typescript-eslint/utils";
2
- import { createRule, commentsMatching, findTypesPackage, getImportSource } from "../util";
3
- import { isDeclarationPath, isTypesPackageName, typesPackageNameToRealName } from "@definitelytyped/utils";
4
-
5
- type MessageId = "noImportOfDevDependencies" | "noReferenceOfDevDependencies";
6
- const rule = createRule({
7
- name: "no-import-of-dev-dependencies",
8
- defaultOptions: [],
9
- meta: {
10
- type: "problem",
11
- docs: {
12
- description: "Forbid imports and references to devDependencies inside .d.ts files.",
13
- },
14
- messages: {
15
- noImportOfDevDependencies: `.d.ts files may not import packages in devDependencies.`,
16
- noReferenceOfDevDependencies: `.d.ts files may not triple-slash reference packages in devDependencies.`,
17
- },
18
- schema: [],
19
- },
20
- create(context) {
21
- if (!isDeclarationPath(context.filename)) {
22
- return {};
23
- }
24
-
25
- const info = findTypesPackage(context.filename);
26
- if (!info) {
27
- return {};
28
- }
29
-
30
- const packageJson = info.packageJson;
31
- if (!packageJson.devDependencies) {
32
- return {};
33
- }
34
-
35
- const devDeps = Object.keys(packageJson.devDependencies)
36
- .map((dep) => {
37
- if (isTypesPackageName(dep)) {
38
- return typesPackageNameToRealName(dep);
39
- }
40
- return dep;
41
- })
42
- .filter((dep) => dep !== info.realName && packageJson.dependencies?.[dep] === undefined); // TODO(jakebailey): add test for this case from https://github.com/microsoft/DefinitelyTyped-tools/pull/773
43
-
44
- commentsMatching(context.sourceCode, /<reference\s+types\s*=\s*"(.+)"\s*\/>/, (ref, comment) => {
45
- if (devDeps.includes(ref)) {
46
- report(comment, "noReferenceOfDevDependencies");
47
- }
48
- });
49
-
50
- function lint(node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration) {
51
- const source = getImportSource(node);
52
- if (!source) {
53
- return;
54
- }
55
-
56
- if (devDeps.includes(source.value)) {
57
- context.report({
58
- messageId: "noImportOfDevDependencies",
59
- node,
60
- });
61
- }
62
- }
63
-
64
- return {
65
- // eslint-disable-next-line @typescript-eslint/naming-convention
66
- ImportDeclaration(node) {
67
- lint(node);
68
- },
69
- // eslint-disable-next-line @typescript-eslint/naming-convention
70
- TSImportEqualsDeclaration(node) {
71
- lint(node);
72
- },
73
- };
74
-
75
- function report(comment: TSESTree.Comment, messageId: MessageId) {
76
- context.report({
77
- loc: {
78
- end: {
79
- column: comment.value.lastIndexOf(`"`),
80
- line: comment.loc.end.line,
81
- },
82
- start: {
83
- column: comment.value.indexOf(`"`) + 1,
84
- line: comment.loc.start.line,
85
- },
86
- },
87
- messageId,
88
- });
89
- }
90
- },
91
- });
92
-
93
- export = rule;
@@ -1,40 +0,0 @@
1
- import { isDeclarationPath } from "@definitelytyped/utils";
2
- import { createRule } from "../util";
3
-
4
- const rule = createRule({
5
- name: "no-bad-reference",
6
- defaultOptions: [],
7
- meta: {
8
- type: "problem",
9
- docs: {
10
- description: `Forbids <reference path="./vNN"/> in all files, <reference path="../etc"/> in declaration files, and all <reference path> in test files.`,
11
- },
12
- messages: {
13
- noOldDTHeader:
14
- "Specify package metadata in package.json. Do not use a header like `// Type definitions for foo 1.2`",
15
- },
16
- schema: [],
17
- },
18
- create(context) {
19
- const text = context.sourceCode.text;
20
- if (
21
- isDeclarationPath(context.filename) &&
22
- text.indexOf("// Type definitions for ") === 0 &&
23
- text.indexOf("// Definitions by: ") > 0
24
- ) {
25
- context.report({
26
- messageId: "noOldDTHeader",
27
- loc: {
28
- start: { column: 0, line: 1 },
29
- end: {
30
- column: "// Type definitions for ".length,
31
- line: 1,
32
- },
33
- },
34
- });
35
- }
36
- return {};
37
- },
38
- });
39
-
40
- export = rule;
@@ -1,72 +0,0 @@
1
- import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
- import * as ts from "typescript";
3
- import { createRule, getImportSource } from "../util";
4
- import { isDeclarationPath } from "@definitelytyped/utils";
5
-
6
- const rule = createRule({
7
- name: "no-relative-import-in-test",
8
- defaultOptions: [],
9
- meta: {
10
- type: "problem",
11
- docs: {
12
- description: "Forbids test (non-declaration) files to use relative imports.",
13
- },
14
- messages: {
15
- useGlobalImport:
16
- "Test file should not use a relative import. Use a global import as if this were a user of the package.",
17
- },
18
- schema: [],
19
- },
20
- create(context) {
21
- if (isDeclarationPath(context.filename)) {
22
- return {};
23
- }
24
-
25
- const services = ESLintUtils.getParserServices(context);
26
- const checker = services.program.getTypeChecker();
27
-
28
- function lint(node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration) {
29
- const source = getImportSource(node);
30
- if (!source) {
31
- return;
32
- }
33
-
34
- if (!source.value.startsWith(".")) {
35
- return;
36
- }
37
-
38
- const moduleSymbol = checker.getSymbolAtLocation(services.esTreeNodeToTSNodeMap.get(source));
39
- if (!moduleSymbol) {
40
- // TODO(jakebailey): generally speaking, this should be an error; you can't import a non-module.
41
- return;
42
- }
43
-
44
- if (!moduleSymbol.declarations) {
45
- return;
46
- }
47
-
48
- for (const declaration of moduleSymbol.declarations) {
49
- if (ts.isSourceFile(declaration) && declaration.isDeclarationFile) {
50
- context.report({
51
- messageId: "useGlobalImport",
52
- node: source,
53
- });
54
- return;
55
- }
56
- }
57
- }
58
-
59
- return {
60
- // eslint-disable-next-line @typescript-eslint/naming-convention
61
- ImportDeclaration(node) {
62
- lint(node);
63
- },
64
- // eslint-disable-next-line @typescript-eslint/naming-convention
65
- TSImportEqualsDeclaration(node) {
66
- lint(node);
67
- },
68
- };
69
- },
70
- });
71
-
72
- export = rule;
@@ -1,56 +0,0 @@
1
- import { TSESTree } from "@typescript-eslint/utils";
2
- import { createRule, getImportSource, getTypesPackageForDeclarationFile } from "../util";
3
- const rule = createRule({
4
- name: "no-self-import",
5
- defaultOptions: [],
6
- meta: {
7
- type: "problem",
8
- docs: {
9
- description:
10
- "Forbids declaration files to import the current package using a global import or old versions with a relative import.",
11
- },
12
- messages: {
13
- useRelativeImport: "Declaration file should not use a global import of itself. Use a relative import.",
14
- useOnlyCurrentVersion: "Don't import an old version of the current package.",
15
- },
16
- schema: [],
17
- },
18
- create(context) {
19
- const packageName = getTypesPackageForDeclarationFile(context.filename);
20
- if (!packageName) {
21
- return {};
22
- }
23
-
24
- function lint(node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration) {
25
- const source = getImportSource(node);
26
- if (!source) {
27
- return;
28
- }
29
-
30
- if (source.value === packageName || source.value.startsWith(packageName + "/")) {
31
- context.report({
32
- messageId: "useRelativeImport",
33
- node,
34
- });
35
- } else if (source.value.match(/^\.\/v\d+(?:\.\d+)?(?:\/.*)?$/)) {
36
- context.report({
37
- messageId: "useOnlyCurrentVersion",
38
- node,
39
- });
40
- }
41
- }
42
-
43
- return {
44
- // eslint-disable-next-line @typescript-eslint/naming-convention
45
- ImportDeclaration(node) {
46
- lint(node);
47
- },
48
- // eslint-disable-next-line @typescript-eslint/naming-convention
49
- TSImportEqualsDeclaration(node) {
50
- lint(node);
51
- },
52
- };
53
- },
54
- });
55
-
56
- export = rule;