@definitelytyped/eslint-plugin 0.0.191 → 0.0.193
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 +16 -0
- package/dist/configs/all.js +29 -2
- package/dist/configs/all.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/rules/export-just-namespace.js +1 -1
- package/dist/rules/export-just-namespace.js.map +1 -1
- package/dist/rules/no-bad-reference.js +6 -5
- package/dist/rules/no-bad-reference.js.map +1 -1
- package/dist/rules/no-dead-reference.js +6 -3
- package/dist/rules/no-dead-reference.js.map +1 -1
- package/dist/rules/no-declare-current-package.js +2 -2
- package/dist/rules/no-declare-current-package.js.map +1 -1
- package/dist/rules/no-import-default-of-export-equals.js +1 -1
- package/dist/rules/no-import-default-of-export-equals.js.map +1 -1
- package/dist/rules/no-import-of-dev-dependencies.js +20 -9
- package/dist/rules/no-import-of-dev-dependencies.js.map +1 -1
- package/dist/rules/no-old-dt-header.js +2 -2
- package/dist/rules/no-old-dt-header.js.map +1 -1
- package/dist/rules/no-relative-import-in-test.js +32 -18
- package/dist/rules/no-relative-import-in-test.js.map +1 -1
- package/dist/rules/no-self-import.js +24 -13
- package/dist/rules/no-self-import.js.map +1 -1
- package/dist/rules/no-single-declare-module.js +2 -2
- package/dist/rules/no-single-declare-module.js.map +1 -1
- package/dist/rules/no-useless-files.js +2 -2
- package/dist/rules/no-useless-files.js.map +1 -1
- package/dist/rules/prefer-declare-function.js +1 -1
- package/dist/rules/prefer-declare-function.js.map +1 -1
- package/dist/rules/strict-export-declare-modifiers.js +1 -1
- package/dist/rules/strict-export-declare-modifiers.js.map +1 -1
- package/dist/util.d.ts +1 -0
- package/dist/util.js +13 -1
- package/dist/util.js.map +1 -1
- package/package.json +7 -4
- package/src/configs/all.ts +28 -1
- package/src/index.ts +17 -5
- package/src/rules/export-just-namespace.ts +1 -1
- package/src/rules/no-bad-reference.ts +6 -5
- package/src/rules/no-dead-reference.ts +6 -3
- package/src/rules/no-declare-current-package.ts +2 -2
- package/src/rules/no-import-default-of-export-equals.ts +1 -1
- package/src/rules/no-import-of-dev-dependencies.ts +23 -10
- package/src/rules/no-old-dt-header.ts +2 -2
- package/src/rules/no-relative-import-in-test.ts +38 -21
- package/src/rules/no-self-import.ts +27 -13
- package/src/rules/no-single-declare-module.ts +2 -2
- package/src/rules/no-useless-files.ts +2 -2
- package/src/rules/prefer-declare-function.ts +1 -1
- package/src/rules/strict-export-declare-modifiers.ts +1 -1
- package/src/util.ts +18 -0
- package/test/__file_snapshots__/types/export-just-namespace/bad1.d.ts.lint +11 -0
- package/test/__file_snapshots__/types/export-just-namespace/bad2.d.ts.lint +11 -0
- package/test/__file_snapshots__/types/export-just-namespace/bad3.d.ts.lint +12 -0
- package/test/__file_snapshots__/types/export-just-namespace/export-just-namespace-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/export-just-namespace/good1.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good2.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good3.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good4.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good5.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good6.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/export-just-namespace/good7.d.ts.lint +7 -0
- package/test/__file_snapshots__/types/export-just-namespace/good8.d.ts.lint +7 -0
- package/test/__file_snapshots__/types/export-just-namespace/good9.d.ts.lint +15 -0
- package/test/__file_snapshots__/types/foo/foo-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/foo/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/foo/v1/foo-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/foo/v1/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-any-union/bad.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-any-union/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-any-union/no-any-union-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-bad-reference/index.d.ts.lint +43 -0
- package/test/__file_snapshots__/types/no-bad-reference/no-bad-reference-tests.ts.lint +14 -0
- package/test/__file_snapshots__/types/no-bad-reference/v0.1/index.d.ts.lint +48 -0
- package/test/__file_snapshots__/types/no-bad-reference/v0.1/no-bad-reference-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-bad-reference/v11/index.d.ts.lint +48 -0
- package/test/__file_snapshots__/types/no-bad-reference/v11/no-bad-reference-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-const-enum/bad.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-const-enum/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-const-enum/no-const-enum-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-dead-reference/bad.d.ts.lint +18 -0
- package/test/__file_snapshots__/types/no-dead-reference/bad2.d.ts.lint +15 -0
- package/test/__file_snapshots__/types/no-dead-reference/bad3.d.ts.lint +17 -0
- package/test/__file_snapshots__/types/no-dead-reference/index.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-dead-reference/no-dead-reference-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-declare-current-package/index.d.ts.lint +13 -0
- package/test/__file_snapshots__/types/no-declare-current-package/no-declare-current-package-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-declare-current-package/test/deep/import.d.ts.lint +13 -0
- package/test/__file_snapshots__/types/no-declare-current-package-other/index.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/bad.d.ts.lint +17 -0
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/index.d.ts.lint +12 -0
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/no-import-default-of-export-equals-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/bad.d.ts.lint +44 -0
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/index.d.ts.lint +25 -0
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts.lint +39 -0
- package/test/__file_snapshots__/types/no-old-dt-header/index.d.ts.lint +23 -0
- package/test/__file_snapshots__/types/no-old-dt-header/index2.d.ts.lint +14 -0
- package/test/__file_snapshots__/types/no-old-dt-header/no-old-dt-header-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-old-dt-header/ok1.ts.lint +11 -0
- package/test/__file_snapshots__/types/no-old-dt-header/ok2.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-old-dt-header/ok3.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-old-dt-header/ok4.d.ts.lint +12 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/abc.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/bad.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test/abc.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts.lint +7 -0
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-relative-references/index.d.ts.lint +51 -0
- package/test/__file_snapshots__/types/no-relative-references/no-relative-references-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-relative-references/other/other.d.ts.lint +31 -0
- package/test/__file_snapshots__/types/no-relative-references/v1/index.d.ts.lint +57 -0
- package/test/__file_snapshots__/types/no-relative-references/v1/no-relative-references-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-relative-references/v1/other/other.d.ts.lint +31 -0
- package/test/__file_snapshots__/types/no-self-import/bad.d.ts.lint +65 -0
- package/test/__file_snapshots__/types/no-self-import/index.d.ts.lint +19 -0
- package/test/__file_snapshots__/types/no-self-import/no-self-import-tests.ts.lint +39 -0
- package/test/__file_snapshots__/types/no-single-declare-module/bad.d.ts.lint +13 -0
- package/test/__file_snapshots__/types/no-single-declare-module/index.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-single-declare-module/index2.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/no-single-declare-module/index3.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-single-declare-module/no-single-declare-module-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-single-element-tuple-type/bad.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-single-element-tuple-type/index.d.ts.lint +9 -0
- package/test/__file_snapshots__/types/no-single-element-tuple-type/no-single-element-tuple-type-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-unnecessary-generics/bad.d.ts.lint +14 -0
- package/test/__file_snapshots__/types/no-unnecessary-generics/index.d.ts.lint +11 -0
- package/test/__file_snapshots__/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts.lint +44 -0
- package/test/__file_snapshots__/types/no-useless-files/bad.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-useless-files/bad2.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-useless-files/bad3.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/no-useless-files/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-useless-files/index2.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-useless-files/index3.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/no-useless-files/no-useless-files-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/other/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/other/other-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/other/v1/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/other/v1/other-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/prefer-declare-function/bad.d.ts.lint +33 -0
- package/test/__file_snapshots__/types/prefer-declare-function/index.d.ts.lint +14 -0
- package/test/__file_snapshots__/types/prefer-declare-function/prefer-declare-function-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/redundant-undefined/bad.d.ts.lint +15 -0
- package/test/__file_snapshots__/types/redundant-undefined/index.d.ts.lint +9 -0
- package/test/__file_snapshots__/types/redundant-undefined/redundant-undefined-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__foo/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/scoped__foo/scoped__foo-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__foo/v1/index.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/scoped__foo/v1/scoped__foo-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/index.d.ts.lint +13 -0
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/test/deep/import.d.ts.lint +13 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/index.d.ts.lint +51 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/no-relative-references-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/other/other.d.ts.lint +31 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/index.d.ts.lint +57 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/no-relative-references-tests.ts.lint +10 -0
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/other/other.d.ts.lint +31 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad1.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad2.d.ts.lint +12 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad3.d.ts.lint +10 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad4.d.ts.lint +12 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad5.d.ts.lint +11 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad6.d.ts.lint +14 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad7.d.ts.lint +14 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good1.ts.lint +5 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good2.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good3.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good4.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good5.d.ts.lint +5 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good6.ts.lint +7 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good7.d.ts.lint +6 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good8.d.ts.lint +9 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good9.d.ts.lint +7 -0
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/strict-export-declare-modifiers-tests.ts.lint +10 -0
- package/test/eslint.test.ts +134 -0
- package/test/fixtures/.eslintrc.cjs +4 -0
- package/test/fixtures/types/export-just-namespace/bad1.d.ts +2 -0
- package/test/fixtures/types/export-just-namespace/bad2.d.ts +2 -0
- package/test/fixtures/types/export-just-namespace/bad3.d.ts +3 -0
- package/test/fixtures/types/export-just-namespace/export-just-namespace-tests.ts +0 -0
- package/test/fixtures/types/export-just-namespace/good1.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good2.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good3.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good4.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good5.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good6.d.ts +1 -0
- package/test/fixtures/types/export-just-namespace/good7.d.ts +3 -0
- package/test/fixtures/types/export-just-namespace/good8.d.ts +3 -0
- package/test/fixtures/types/export-just-namespace/good9.d.ts +3 -0
- package/test/fixtures/types/export-just-namespace/package.json +8 -0
- package/test/fixtures/types/export-just-namespace/tsconfig.json +31 -0
- package/test/fixtures/types/no-any-union/bad.d.ts +1 -0
- package/test/fixtures/types/no-any-union/index.d.ts +1 -0
- package/test/fixtures/types/no-any-union/no-any-union-tests.ts +1 -0
- package/test/fixtures/types/no-any-union/package.json +8 -0
- package/test/fixtures/types/no-any-union/tsconfig.json +21 -0
- package/test/fixtures/types/no-bad-reference/tsconfig.json +1 -1
- package/test/fixtures/types/no-bad-reference/v0.1/tsconfig.json +1 -1
- package/test/fixtures/types/no-bad-reference/v11/tsconfig.json +1 -1
- package/test/fixtures/types/no-const-enum/bad.d.ts +1 -0
- package/test/fixtures/types/no-const-enum/index.d.ts +1 -0
- package/test/fixtures/types/no-const-enum/no-const-enum-tests.ts +0 -0
- package/test/fixtures/types/no-const-enum/package.json +8 -0
- package/test/fixtures/types/no-const-enum/tsconfig.json +21 -0
- package/test/fixtures/types/no-dead-reference/bad.d.ts +6 -0
- package/test/fixtures/types/no-dead-reference/bad2.d.ts +3 -0
- package/test/fixtures/types/no-dead-reference/bad3.d.ts +5 -0
- package/test/fixtures/types/no-dead-reference/index.d.ts +2 -0
- package/test/fixtures/types/no-dead-reference/no-dead-reference-tests.ts +0 -0
- package/test/fixtures/types/no-dead-reference/package.json +8 -0
- package/test/fixtures/types/no-dead-reference/tsconfig.json +23 -0
- package/test/fixtures/types/no-declare-current-package/tsconfig.json +2 -1
- package/test/fixtures/types/no-declare-current-package-other/tsconfig.json +1 -1
- package/test/fixtures/types/no-import-default-of-export-equals/bad.d.ts +8 -0
- package/test/fixtures/types/no-import-default-of-export-equals/index.d.ts +8 -0
- package/test/fixtures/types/no-import-default-of-export-equals/no-import-default-of-export-equals-tests.ts +0 -0
- package/test/fixtures/types/no-import-default-of-export-equals/package.json +8 -0
- package/test/fixtures/types/no-import-default-of-export-equals/tsconfig.json +21 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/bad.d.ts +3 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/index.d.ts +3 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts +6 -0
- package/test/fixtures/types/no-import-of-dev-dependencies/tsconfig.json +1 -0
- package/test/fixtures/types/no-old-dt-header/index.d.ts +14 -0
- package/test/fixtures/types/no-old-dt-header/index2.d.ts +2 -0
- package/test/fixtures/types/no-old-dt-header/no-old-dt-header-tests.ts +0 -0
- package/test/fixtures/types/no-old-dt-header/ok1.ts +2 -0
- package/test/fixtures/types/no-old-dt-header/ok2.d.ts +1 -0
- package/test/fixtures/types/no-old-dt-header/ok3.d.ts +1 -0
- package/test/fixtures/types/no-old-dt-header/ok4.d.ts +3 -0
- package/test/fixtures/types/no-old-dt-header/package.json +8 -0
- package/test/fixtures/types/no-old-dt-header/tsconfig.json +25 -0
- package/test/fixtures/types/no-relative-import-in-test/bad.d.ts +0 -0
- package/test/fixtures/types/no-relative-import-in-test/index.d.ts +1 -0
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts +1 -0
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts +3 -0
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts +1 -0
- package/test/fixtures/types/no-relative-import-in-test/package.json +8 -0
- package/test/fixtures/types/no-relative-import-in-test/tsconfig.json +25 -0
- package/test/fixtures/types/no-relative-references/tsconfig.json +1 -0
- package/test/fixtures/types/no-relative-references/v1/tsconfig.json +1 -0
- package/test/fixtures/types/no-self-import/bad.d.ts +9 -0
- package/test/fixtures/types/no-self-import/index.d.ts +8 -0
- package/test/fixtures/types/no-self-import/no-self-import-tests.ts +6 -0
- package/test/fixtures/types/no-self-import/tsconfig.json +2 -1
- package/test/fixtures/types/no-single-declare-module/bad.d.ts +4 -0
- package/test/fixtures/types/no-single-declare-module/index.d.ts +2 -0
- package/test/fixtures/types/no-single-declare-module/index2.d.ts +2 -0
- package/test/fixtures/types/no-single-declare-module/index3.d.ts +1 -0
- package/test/fixtures/types/no-single-declare-module/no-single-declare-module-tests.ts +0 -0
- package/test/fixtures/types/no-single-declare-module/package.json +8 -0
- package/test/fixtures/types/no-single-declare-module/tsconfig.json +23 -0
- package/test/fixtures/types/no-single-element-tuple-type/bad.d.ts +1 -0
- package/test/fixtures/types/no-single-element-tuple-type/index.d.ts +5 -0
- package/test/fixtures/types/no-single-element-tuple-type/no-single-element-tuple-type-tests.ts +0 -0
- package/test/fixtures/types/no-single-element-tuple-type/package.json +8 -0
- package/test/fixtures/types/no-single-element-tuple-type/tsconfig.json +21 -0
- package/test/fixtures/types/no-unnecessary-generics/bad.d.ts +2 -0
- package/test/fixtures/types/no-unnecessary-generics/index.d.ts +7 -0
- package/test/fixtures/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts +14 -0
- package/test/fixtures/types/no-unnecessary-generics/package.json +8 -0
- package/test/fixtures/types/no-unnecessary-generics/tsconfig.json +21 -0
- package/test/fixtures/types/no-useless-files/bad.d.ts +1 -0
- package/test/fixtures/types/no-useless-files/bad2.d.ts +0 -0
- package/test/fixtures/types/no-useless-files/bad3.d.ts +1 -0
- package/test/fixtures/types/no-useless-files/index.d.ts +1 -0
- package/test/fixtures/types/no-useless-files/index2.d.ts +1 -0
- package/test/fixtures/types/no-useless-files/index3.d.ts +1 -0
- package/test/fixtures/types/no-useless-files/no-useless-files-tests.ts +0 -0
- package/test/fixtures/types/no-useless-files/package.json +8 -0
- package/test/fixtures/types/no-useless-files/tsconfig.json +25 -0
- package/test/fixtures/types/other/tsconfig.json +1 -1
- package/test/fixtures/types/other/v1/tsconfig.json +1 -1
- package/test/fixtures/types/prefer-declare-function/bad.d.ts +9 -0
- package/test/fixtures/types/prefer-declare-function/index.d.ts +2 -0
- package/test/fixtures/types/prefer-declare-function/package.json +8 -0
- package/test/fixtures/types/prefer-declare-function/prefer-declare-function-tests.ts +0 -0
- package/test/fixtures/types/prefer-declare-function/tsconfig.json +21 -0
- package/test/fixtures/types/redundant-undefined/bad.d.ts +3 -0
- package/test/fixtures/types/redundant-undefined/index.d.ts +5 -0
- package/test/fixtures/types/redundant-undefined/package.json +8 -0
- package/test/fixtures/types/redundant-undefined/redundant-undefined-tests.ts +1 -0
- package/test/fixtures/types/redundant-undefined/tsconfig.json +21 -0
- package/test/fixtures/types/scoped__foo/tsconfig.json +1 -1
- package/test/fixtures/types/scoped__foo/v1/tsconfig.json +1 -1
- package/test/fixtures/types/scoped__no-declare-current-package/tsconfig.json +2 -1
- package/test/fixtures/types/scoped__no-relative-references/tsconfig.json +1 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/tsconfig.json +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad1.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad2.d.ts +3 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad3.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad4.d.ts +3 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad5.d.ts +2 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad6.d.ts +2 -0
- package/test/fixtures/types/strict-export-declare-modifiers/bad7.d.ts +2 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good1.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good2.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good3.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good4.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good5.d.ts +1 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good6.ts +3 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good7.d.ts +2 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good8.d.ts +5 -0
- package/test/fixtures/types/strict-export-declare-modifiers/good9.d.ts +3 -0
- package/test/fixtures/types/strict-export-declare-modifiers/package.json +8 -0
- package/test/fixtures/types/strict-export-declare-modifiers/strict-export-declare-modifiers-tests.ts +0 -0
- package/test/fixtures/types/strict-export-declare-modifiers/tsconfig.json +35 -0
- package/test/util.test.ts +6 -1
- package/test/util.ts +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/test/export-just-namespace.test.ts +0 -68
- package/test/fixtureTester.ts +0 -63
- package/test/no-any-union.test.ts +0 -20
- package/test/no-bad-reference.test.ts +0 -127
- package/test/no-const-enum.test.ts +0 -20
- package/test/no-dead-reference.test.ts +0 -64
- package/test/no-declare-current-package.test.ts +0 -59
- package/test/no-import-default-of-export-equals.test.ts +0 -49
- package/test/no-import-of-dev-dependencies.test.ts +0 -27
- package/test/no-old-dt-header.test.ts +0 -69
- package/test/no-relative-import-in-test.test.ts +0 -27
- package/test/no-self-import.test.ts +0 -30
- package/test/no-single-declare-module.test.ts +0 -49
- package/test/no-single-element-tuple-type.test.ts +0 -26
- package/test/no-unnecessary-generics.test.ts +0 -152
- package/test/no-useless-files.test.ts +0 -40
- package/test/prefer-declare-function.test.ts +0 -64
- package/test/redundant-undefined.test.ts +0 -37
- package/test/strict-export-declare-modifiers.test.ts +0 -156
- package/test/tsconfig.no-declare-current-package.json +0 -11
- package/test/tsconfig.no-declare-current-package2.json +0 -11
- package/test/tsconfig.no-import-default-of-export-equals.json +0 -11
- package/test/tsconfig.no-relative-import-in-test.json +0 -14
- package/test/tsconfig.no-self-import.json +0 -7
- package/test/tsconfig.no-single-declare-module.json +0 -7
- package/test/tsconfig.test.json +0 -10
- /package/test/{abc.d.ts → fixtures/types/no-relative-import-in-test/abc.d.ts} +0 -0
- /package/test/{no-relative-import-in-test → fixtures/types/no-relative-import-in-test/no-relative-import-in-test}/abc.d.ts +0 -0
|
@@ -51,7 +51,7 @@ const rule = (0, util_1.createRule)({
|
|
|
51
51
|
// to switch it to using TSESTree nodes like other ESLint rules.
|
|
52
52
|
create(context) {
|
|
53
53
|
const services = utils_1.ESLintUtils.getParserServices(context, true);
|
|
54
|
-
const sourceCode = context.
|
|
54
|
+
const sourceCode = context.sourceCode;
|
|
55
55
|
const sourceFile = services.esTreeNodeToTSNodeMap.get(sourceCode.ast);
|
|
56
56
|
const isExternal = sourceFile.isDeclarationFile &&
|
|
57
57
|
!sourceFile.statements.some((s) => s.kind === ts.SyntaxKind.ExportAssignment ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-export-declare-modifiers.js","sourceRoot":"","sources":["../../src/rules/strict-export-declare-modifiers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;AACvD,+CAAiC;AACjC,kCAAqC;AAErC,MAAM,IAAI,GAAG,IAAA,iBAAU,EAAC;IACtB,IAAI,EAAE,iCAAiC;IACvC,cAAc,EAAE,EAAE;IAClB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,oFAAoF;SAClG;QACD,QAAQ,EAAE;YACR,qBAAqB,EACnB,8DAA8D;gBAC9D,mDAAmD;gBACnD,4DAA4D;gBAC5D,gEAAgE;YAClE,gBAAgB,EAAE,sCAAsC;YACxD,eAAe,EACb,6CAA6C;gBAC7C,8DAA8D;gBAC9D,wEAAwE;gBACxE,gEAAgE;SACnE;QACD,MAAM,EAAE,EAAE;KACX;IACD,gEAAgE;IAChE,gEAAgE;IAChE,gEAAgE;IAChE,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAG,mBAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC9D,MAAM,UAAU,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"strict-export-declare-modifiers.js","sourceRoot":"","sources":["../../src/rules/strict-export-declare-modifiers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;AACvD,+CAAiC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;AACf,CAAC;AAED,SAAS,iBAAiB,CAAC,IAA0C;IACnE,0EAA0E;IAC1E,wEAAwE;IACxE,EAAE;IACF,0EAA0E;IAC1E,cAAc;IACd,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED,iBAAS,IAAI,CAAC"}
|
package/dist/util.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export interface PackageJSON {
|
|
|
18
18
|
devDependencies?: Record<string, string | undefined>;
|
|
19
19
|
}
|
|
20
20
|
export declare function findTypesPackage(file: string): TypesPackageInfo | undefined;
|
|
21
|
+
export declare function getImportSource(node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration): TSESTree.StringLiteral | undefined;
|
package/dist/util.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.findTypesPackage = exports.commentsMatching = exports.getTypesPackageForDeclarationFile = exports.createRule = void 0;
|
|
6
|
+
exports.getImportSource = exports.findTypesPackage = exports.commentsMatching = exports.getTypesPackageForDeclarationFile = exports.createRule = void 0;
|
|
7
7
|
const utils_1 = require("@definitelytyped/utils");
|
|
8
8
|
const utils_2 = require("@typescript-eslint/utils");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -66,4 +66,16 @@ function findTypesPackage(file) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
exports.findTypesPackage = findTypesPackage;
|
|
69
|
+
function getImportSource(node) {
|
|
70
|
+
if (node.type === "ImportDeclaration") {
|
|
71
|
+
return node.source;
|
|
72
|
+
}
|
|
73
|
+
if (node.moduleReference.type === "TSExternalModuleReference" &&
|
|
74
|
+
node.moduleReference.expression.type === "Literal" &&
|
|
75
|
+
typeof node.moduleReference.expression.value === "string") {
|
|
76
|
+
return node.moduleReference.expression;
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
exports.getImportSource = getImportSource;
|
|
69
81
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAuF;AACvF,oDAA2E;AAC3E,gDAAwB;AACxB,4CAAoB;AASP,QAAA,UAAU,GAEkB,mBAAW,CAAC,WAAW,CAC9D,CAAC,IAAI,EAAE,EAAE,CACP,oGAAoG,IAAI,KAAK,CAChH,CAAC;AAEF,SAAgB,iCAAiC,CAAC,IAAY;;IAC5D,IAAI,CAAC,IAAA,yBAAiB,EAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,MAAA,gBAAgB,CAAC,IAAI,CAAC,0CAAE,QAAQ,CAAC;AAC1C,CAAC;AALD,8EAKC;AAED,SAAgB,gBAAgB,CAC9B,UAAyC,EACzC,KAAa,EACb,CAA+C;IAE/C,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE;QAC7C,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC;YAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;KACzB;AACH,CAAC;AATD,4CASC;AAED,SAAS,MAAM,CAAe,CAAS,EAAE,EAAgC;IACvE,CAAC,GAAG,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,IAAI,GAAG,cAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAEhC,OAAO,IAAI,EAAE;QACX,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,KAAK,SAAS,E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C;AACnB,CAAC;AAhBD,0CAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@definitelytyped/eslint-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.193",
|
|
4
4
|
"description": "ESLint rules for DefinitelyTyped",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,15 +23,18 @@
|
|
|
23
23
|
"@definitelytyped/utils": "0.0.187"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
27
|
-
"@typescript-eslint/parser": "^
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
27
|
+
"@typescript-eslint/parser": "^6.11.0",
|
|
28
28
|
"eslint": "^8.0.0",
|
|
29
29
|
"eslint-plugin-jsdoc": "^44.0.0",
|
|
30
30
|
"typescript": ">= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev || >=5.0.0-dev"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@definitelytyped/eslint-plugin": "link:./",
|
|
33
34
|
"@types/eslint": "^8.44.7",
|
|
34
|
-
"
|
|
35
|
+
"glob": "^10.3.10",
|
|
36
|
+
"jest-file-snapshot": "^0.5.0",
|
|
37
|
+
"strip-ansi": "^6.0.1",
|
|
35
38
|
"typescript": "^5.2.2"
|
|
36
39
|
},
|
|
37
40
|
"engines": {
|
package/src/configs/all.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rules } from "../rules
|
|
1
|
+
import { rules } from "../rules";
|
|
2
2
|
import { Linter } from "eslint";
|
|
3
3
|
|
|
4
4
|
export const all: Linter.BaseConfig = {
|
|
@@ -146,7 +146,34 @@ export const all: Linter.BaseConfig = {
|
|
|
146
146
|
"ts-check": false,
|
|
147
147
|
},
|
|
148
148
|
],
|
|
149
|
+
// ported from tslint builtin rules
|
|
150
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
151
|
+
"@typescript-eslint/ban-types": [
|
|
152
|
+
"error",
|
|
153
|
+
{
|
|
154
|
+
types: { "{}": false },
|
|
155
|
+
extendDefaults: true,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
149
158
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
159
|
+
"@typescript-eslint/triple-slash-reference": ["error", { types: "prefer-import", path: "always" }],
|
|
160
|
+
"@typescript-eslint/no-empty-interface": "error",
|
|
161
|
+
"no-duplicate-imports": "error",
|
|
162
|
+
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
|
|
163
|
+
"@typescript-eslint/naming-convention": [
|
|
164
|
+
"error",
|
|
165
|
+
{
|
|
166
|
+
selector: "interface",
|
|
167
|
+
format: [],
|
|
168
|
+
custom: {
|
|
169
|
+
regex: "^I[A-Z]",
|
|
170
|
+
match: false,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
|
|
175
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
176
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
150
177
|
},
|
|
151
178
|
},
|
|
152
179
|
],
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ESLint } from "eslint";
|
|
2
|
+
import { all } from "./configs/all";
|
|
3
|
+
import { rules } from "./rules/index";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const packageJson = require("../package.json");
|
|
6
|
+
|
|
7
|
+
const plugin = {
|
|
8
|
+
meta: {
|
|
9
|
+
name: packageJson.name,
|
|
10
|
+
version: packageJson.version,
|
|
11
|
+
},
|
|
12
|
+
configs: {
|
|
13
|
+
all,
|
|
14
|
+
},
|
|
15
|
+
rules: rules as any,
|
|
16
|
+
} satisfies ESLint.Plugin;
|
|
17
|
+
|
|
18
|
+
export = plugin;
|
|
@@ -33,7 +33,7 @@ const rule = createRule({
|
|
|
33
33
|
schema: [],
|
|
34
34
|
},
|
|
35
35
|
create(context) {
|
|
36
|
-
const containingFileName = context.
|
|
36
|
+
const containingFileName = context.filename;
|
|
37
37
|
const typesPackage = findTypesPackage(containingFileName);
|
|
38
38
|
if (!typesPackage) {
|
|
39
39
|
return {};
|
|
@@ -46,7 +46,7 @@ const rule = createRule({
|
|
|
46
46
|
return name.startsWith(".") || name.startsWith(realNamePlusSlash);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const ast = context.
|
|
49
|
+
const ast = context.sourceCode.ast;
|
|
50
50
|
const parserServices = ESLintUtils.getParserServices(context, true);
|
|
51
51
|
const sourceFile = parserServices.esTreeNodeToTSNodeMap.get(ast);
|
|
52
52
|
|
|
@@ -69,7 +69,7 @@ const rule = createRule({
|
|
|
69
69
|
}
|
|
70
70
|
for (const ref of imports(sourceFile)) {
|
|
71
71
|
if (isRelativeOrSelf(ref.text)) {
|
|
72
|
-
refs.push({ kind: "import", text: ref.text, range: ref });
|
|
72
|
+
refs.push({ kind: "import", text: ref.text, range: { pos: ref.getStart(), end: ref.getEnd() } });
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -140,8 +140,9 @@ function tsRangeToESLintLocation(range: ts.TextRange, sourceFile: ts.SourceFile)
|
|
|
140
140
|
const pos = sourceFile.getLineAndCharacterOfPosition(range.pos);
|
|
141
141
|
const end = sourceFile.getLineAndCharacterOfPosition(range.end);
|
|
142
142
|
return {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
// line is 1 indexed, but column is 0 indexed. >.<
|
|
144
|
+
start: { line: pos.line + 1, column: pos.character },
|
|
145
|
+
end: { line: end.line + 1, column: end.character },
|
|
145
146
|
};
|
|
146
147
|
}
|
|
147
148
|
|
|
@@ -14,11 +14,11 @@ const rule = createRule({
|
|
|
14
14
|
schema: [],
|
|
15
15
|
},
|
|
16
16
|
create(context) {
|
|
17
|
-
const source = context.
|
|
17
|
+
const source = context.sourceCode;
|
|
18
18
|
if (source.ast.body.length) {
|
|
19
19
|
// 'm' flag makes it multiline, so `^` matches the beginning of any line.
|
|
20
20
|
// 'g' flag lets us set rgx.lastIndex
|
|
21
|
-
const rgx = /^\s*(\/\/\/ <reference)/gm;
|
|
21
|
+
const rgx = /^\s*(\/\/\/ <reference.*)/gm;
|
|
22
22
|
|
|
23
23
|
// Start search at the first statement. (`/// <reference>` before that is OK.)
|
|
24
24
|
rgx.lastIndex = source.ast.body[0].range?.[0] ?? 0;
|
|
@@ -33,7 +33,10 @@ const rule = createRule({
|
|
|
33
33
|
const start = match.index + match[0].length - length;
|
|
34
34
|
context.report({
|
|
35
35
|
messageId: "referenceAtTop",
|
|
36
|
-
loc:
|
|
36
|
+
loc: {
|
|
37
|
+
start: source.getLocFromIndex(start),
|
|
38
|
+
end: source.getLocFromIndex(start + match[1].length),
|
|
39
|
+
},
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
}
|
|
@@ -17,7 +17,7 @@ const rule = createRule({
|
|
|
17
17
|
schema: [],
|
|
18
18
|
},
|
|
19
19
|
create(context) {
|
|
20
|
-
const packageName = getTypesPackageForDeclarationFile(context.
|
|
20
|
+
const packageName = getTypesPackageForDeclarationFile(context.filename);
|
|
21
21
|
if (!packageName) {
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
@@ -34,7 +34,7 @@ const rule = createRule({
|
|
|
34
34
|
context.report({
|
|
35
35
|
messageId: "noDeclareCurrentPackage",
|
|
36
36
|
data: { text, preferred },
|
|
37
|
-
node,
|
|
37
|
+
node: node.id,
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
},
|
|
@@ -19,7 +19,7 @@ const rule = createRule({
|
|
|
19
19
|
create(context) {
|
|
20
20
|
const parserServices = ESLintUtils.getParserServices(context);
|
|
21
21
|
const checker = parserServices.program.getTypeChecker();
|
|
22
|
-
if (isDeclarationPath(context.
|
|
22
|
+
if (isDeclarationPath(context.filename)) {
|
|
23
23
|
return {
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
25
|
ImportDeclaration(node) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TSESTree } from "@typescript-eslint/utils";
|
|
2
|
-
import { createRule, commentsMatching, findTypesPackage } from "../util";
|
|
2
|
+
import { createRule, commentsMatching, findTypesPackage, getImportSource } from "../util";
|
|
3
3
|
import { isDeclarationPath, isTypesPackageName, typesPackageNameToRealName } from "@definitelytyped/utils";
|
|
4
4
|
|
|
5
5
|
type MessageId = "noImportOfDevDependencies" | "noReferenceOfDevDependencies";
|
|
@@ -18,11 +18,11 @@ const rule = createRule({
|
|
|
18
18
|
schema: [],
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
if (!isDeclarationPath(context.
|
|
21
|
+
if (!isDeclarationPath(context.filename)) {
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const info = findTypesPackage(context.
|
|
25
|
+
const info = findTypesPackage(context.filename);
|
|
26
26
|
if (!info) {
|
|
27
27
|
return {};
|
|
28
28
|
}
|
|
@@ -41,21 +41,34 @@ const rule = createRule({
|
|
|
41
41
|
})
|
|
42
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
43
|
|
|
44
|
-
commentsMatching(context.
|
|
44
|
+
commentsMatching(context.sourceCode, /<reference\s+types\s*=\s*"(.+)"\s*\/>/, (ref, comment) => {
|
|
45
45
|
if (devDeps.includes(ref)) {
|
|
46
46
|
report(comment, "noReferenceOfDevDependencies");
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
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
|
+
|
|
50
64
|
return {
|
|
51
65
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
52
66
|
ImportDeclaration(node) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
67
|
+
lint(node);
|
|
68
|
+
},
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
70
|
+
TSImportEqualsDeclaration(node) {
|
|
71
|
+
lint(node);
|
|
59
72
|
},
|
|
60
73
|
};
|
|
61
74
|
|
|
@@ -16,9 +16,9 @@ const rule = createRule({
|
|
|
16
16
|
schema: [],
|
|
17
17
|
},
|
|
18
18
|
create(context) {
|
|
19
|
-
const text = context.
|
|
19
|
+
const text = context.sourceCode.text;
|
|
20
20
|
if (
|
|
21
|
-
isDeclarationPath(context.
|
|
21
|
+
isDeclarationPath(context.filename) &&
|
|
22
22
|
text.indexOf("// Type definitions for ") === 0 &&
|
|
23
23
|
text.indexOf("// Definitions by: ") > 0
|
|
24
24
|
) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
1
|
+
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
|
|
2
2
|
import * as ts from "typescript";
|
|
3
|
-
import { createRule } from "../util";
|
|
3
|
+
import { createRule, getImportSource } from "../util";
|
|
4
4
|
import { isDeclarationPath } from "@definitelytyped/utils";
|
|
5
5
|
|
|
6
6
|
const rule = createRule({
|
|
@@ -18,35 +18,52 @@ const rule = createRule({
|
|
|
18
18
|
schema: [],
|
|
19
19
|
},
|
|
20
20
|
create(context) {
|
|
21
|
-
if (isDeclarationPath(context.
|
|
21
|
+
if (isDeclarationPath(context.filename)) {
|
|
22
22
|
return {};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const services = ESLintUtils.getParserServices(context);
|
|
26
26
|
const checker = services.program.getTypeChecker();
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
}
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
if (
|
|
48
|
+
for (const declaration of moduleSymbol.declarations) {
|
|
49
|
+
if (ts.isSourceFile(declaration) && declaration.isDeclarationFile) {
|
|
50
|
+
context.report({
|
|
51
|
+
messageId: "useGlobalImport",
|
|
52
|
+
node: source,
|
|
53
|
+
});
|
|
38
54
|
return;
|
|
39
55
|
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
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);
|
|
50
67
|
},
|
|
51
68
|
};
|
|
52
69
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TSESTree } from "@typescript-eslint/utils";
|
|
2
|
+
import { createRule, getImportSource, getTypesPackageForDeclarationFile } from "../util";
|
|
2
3
|
const rule = createRule({
|
|
3
4
|
name: "no-self-import",
|
|
4
5
|
defaultOptions: [],
|
|
@@ -15,25 +16,38 @@ const rule = createRule({
|
|
|
15
16
|
schema: [],
|
|
16
17
|
},
|
|
17
18
|
create(context) {
|
|
18
|
-
const packageName = getTypesPackageForDeclarationFile(context.
|
|
19
|
+
const packageName = getTypesPackageForDeclarationFile(context.filename);
|
|
19
20
|
if (!packageName) {
|
|
20
21
|
return {};
|
|
21
22
|
}
|
|
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
|
+
|
|
23
43
|
return {
|
|
24
44
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
45
|
ImportDeclaration(node) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} else if (node.source.value.match(/^\.\/v\d+(?:\.\d+)?(?:\/.*)?$/)) {
|
|
32
|
-
context.report({
|
|
33
|
-
messageId: "useOnlyCurrentVersion",
|
|
34
|
-
node,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
46
|
+
lint(node);
|
|
47
|
+
},
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
49
|
+
TSImportEqualsDeclaration(node) {
|
|
50
|
+
lint(node);
|
|
37
51
|
},
|
|
38
52
|
};
|
|
39
53
|
},
|
|
@@ -19,7 +19,7 @@ const rule = createRule({
|
|
|
19
19
|
name: "no-single-declare-module",
|
|
20
20
|
create(context) {
|
|
21
21
|
const services = ESLintUtils.getParserServices(context);
|
|
22
|
-
const sourceFile = services.esTreeNodeToTSNodeMap.get(context.
|
|
22
|
+
const sourceFile = services.esTreeNodeToTSNodeMap.get(context.sourceCode.ast);
|
|
23
23
|
|
|
24
24
|
// If it's an external module, any module declarations inside are augmentations.
|
|
25
25
|
if (ts.isExternalModule(sourceFile)) {
|
|
@@ -46,7 +46,7 @@ const rule = createRule({
|
|
|
46
46
|
if (moduleDeclaration) {
|
|
47
47
|
context.report({
|
|
48
48
|
messageId: "oneModuleDeclaration",
|
|
49
|
-
node: services.tsNodeToESTreeNodeMap.get(moduleDeclaration),
|
|
49
|
+
node: services.tsNodeToESTreeNodeMap.get(moduleDeclaration.name),
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -16,7 +16,7 @@ const rule = createRule({
|
|
|
16
16
|
create(context) {
|
|
17
17
|
const {
|
|
18
18
|
ast: { tokens, comments },
|
|
19
|
-
} = context.
|
|
19
|
+
} = context.sourceCode;
|
|
20
20
|
|
|
21
21
|
if (tokens.length === 0) {
|
|
22
22
|
if (comments.length === 0) {
|
|
@@ -24,7 +24,7 @@ const rule = createRule({
|
|
|
24
24
|
} else {
|
|
25
25
|
const referenceRegExp = /^\/\s*<reference\s*(types|path)\s*=\s*["|'](.*)["|']/;
|
|
26
26
|
let noReferenceFound = true;
|
|
27
|
-
commentsMatching(context.
|
|
27
|
+
commentsMatching(context.sourceCode, referenceRegExp, () => {
|
|
28
28
|
noReferenceFound = false;
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -22,7 +22,7 @@ const rule = createRule({
|
|
|
22
22
|
"VariableDeclaration > VariableDeclarator"(node: TSESTree.VariableDeclarator) {
|
|
23
23
|
if (
|
|
24
24
|
node.id.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES.TSFunctionType &&
|
|
25
|
-
isDeclarationPath(context.
|
|
25
|
+
isDeclarationPath(context.filename)
|
|
26
26
|
) {
|
|
27
27
|
context.report({
|
|
28
28
|
messageId: "variableFunction",
|
|
@@ -30,7 +30,7 @@ const rule = createRule({
|
|
|
30
30
|
// to switch it to using TSESTree nodes like other ESLint rules.
|
|
31
31
|
create(context) {
|
|
32
32
|
const services = ESLintUtils.getParserServices(context, true);
|
|
33
|
-
const sourceCode = context.
|
|
33
|
+
const sourceCode = context.sourceCode;
|
|
34
34
|
const sourceFile = services.esTreeNodeToTSNodeMap.get(sourceCode.ast);
|
|
35
35
|
|
|
36
36
|
const isExternal =
|
package/src/util.ts
CHANGED
|
@@ -98,3 +98,21 @@ export function findTypesPackage(file: string): TypesPackageInfo | undefined {
|
|
|
98
98
|
};
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
export function getImportSource(
|
|
103
|
+
node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration,
|
|
104
|
+
): TSESTree.StringLiteral | undefined {
|
|
105
|
+
if (node.type === "ImportDeclaration") {
|
|
106
|
+
return node.source;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
node.moduleReference.type === "TSExternalModuleReference" &&
|
|
111
|
+
node.moduleReference.expression.type === "Literal" &&
|
|
112
|
+
typeof node.moduleReference.expression.value === "string"
|
|
113
|
+
) {
|
|
114
|
+
return node.moduleReference.expression;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
types/export-just-namespace/bad1.d.ts
|
|
2
|
+
1:1 error Instead of `export =`-ing a namespace, use the body of the namespace as the module body @definitelytyped/export-just-namespace
|
|
3
|
+
|
|
4
|
+
✖ 1 problem (1 error, 0 warnings)
|
|
5
|
+
|
|
6
|
+
==== types/export-just-namespace/bad1.d.ts ====
|
|
7
|
+
|
|
8
|
+
export = Stuff;
|
|
9
|
+
~~~~~~~~~~~~~~~
|
|
10
|
+
!!! @definitelytyped/export-just-namespace: Instead of `export =`-ing a namespace, use the body of the namespace as the module body.
|
|
11
|
+
namespace Stuff {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
types/export-just-namespace/bad2.d.ts
|
|
2
|
+
2:1 error Instead of `export =`-ing a namespace, use the body of the namespace as the module body @definitelytyped/export-just-namespace
|
|
3
|
+
|
|
4
|
+
✖ 1 problem (1 error, 0 warnings)
|
|
5
|
+
|
|
6
|
+
==== types/export-just-namespace/bad2.d.ts ====
|
|
7
|
+
|
|
8
|
+
namespace Stuff {}
|
|
9
|
+
export = Stuff;
|
|
10
|
+
~~~~~~~~~~~~~~~
|
|
11
|
+
!!! @definitelytyped/export-just-namespace: Instead of `export =`-ing a namespace, use the body of the namespace as the module body.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
types/export-just-namespace/bad3.d.ts
|
|
2
|
+
3:1 error Instead of `export =`-ing a namespace, use the body of the namespace as the module body @definitelytyped/export-just-namespace
|
|
3
|
+
|
|
4
|
+
✖ 1 problem (1 error, 0 warnings)
|
|
5
|
+
|
|
6
|
+
==== types/export-just-namespace/bad3.d.ts ====
|
|
7
|
+
|
|
8
|
+
namespace Stuff {}
|
|
9
|
+
const other = "code";
|
|
10
|
+
export = Stuff;
|
|
11
|
+
~~~~~~~~~~~~~~~
|
|
12
|
+
!!! @definitelytyped/export-just-namespace: Instead of `export =`-ing a namespace, use the body of the namespace as the module body.
|
package/test/__file_snapshots__/types/export-just-namespace/export-just-namespace-tests.ts.lint
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
types/export-just-namespace/export-just-namespace-tests.ts
|
|
2
|
+
1:1 error File has no content @definitelytyped/no-useless-files
|
|
3
|
+
|
|
4
|
+
✖ 1 problem (1 error, 0 warnings)
|
|
5
|
+
|
|
6
|
+
==== types/export-just-namespace/export-just-namespace-tests.ts ====
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
~
|
|
10
|
+
!!! @definitelytyped/no-useless-files: File has no content.
|