@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.
- package/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/configs/all.ts +0 -189
- package/src/index.ts +0 -18
- package/src/rules/expect.ts +0 -556
- package/src/rules/export-just-namespace.ts +0 -82
- package/src/rules/index.ts +0 -43
- package/src/rules/no-any-union.ts +0 -33
- package/src/rules/no-bad-reference.ts +0 -199
- package/src/rules/no-const-enum.ts +0 -31
- package/src/rules/no-dead-reference.ts +0 -47
- package/src/rules/no-declare-current-package.ts +0 -45
- package/src/rules/no-import-default-of-export-equals.ts +0 -68
- package/src/rules/no-import-of-dev-dependencies.ts +0 -93
- package/src/rules/no-old-dt-header.ts +0 -40
- package/src/rules/no-relative-import-in-test.ts +0 -72
- package/src/rules/no-self-import.ts +0 -56
- package/src/rules/no-single-declare-module.ts +0 -57
- package/src/rules/no-single-element-tuple-type.ts +0 -30
- package/src/rules/no-unnecessary-generics.ts +0 -119
- package/src/rules/no-useless-files.ts +0 -51
- package/src/rules/npm-naming/types.ts +0 -14
- package/src/rules/npm-naming.ts +0 -211
- package/src/rules/prefer-declare-function.ts +0 -37
- package/src/rules/redundant-undefined.ts +0 -61
- package/src/rules/strict-export-declare-modifiers.ts +0 -195
- package/src/suggestions.ts +0 -75
- package/src/util.ts +0 -138
- package/test/__file_snapshots__/types/expect/expect-tests.ts.lint +0 -79
- package/test/__file_snapshots__/types/expect/index.d.ts.lint +0 -19
- package/test/__file_snapshots__/types/export-just-namespace/bad1.d.ts.lint +0 -11
- package/test/__file_snapshots__/types/export-just-namespace/bad2.d.ts.lint +0 -11
- package/test/__file_snapshots__/types/export-just-namespace/bad3.d.ts.lint +0 -12
- package/test/__file_snapshots__/types/export-just-namespace/export-just-namespace-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/export-just-namespace/good1.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good2.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good3.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good4.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good5.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good6.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/export-just-namespace/good7.d.ts.lint +0 -7
- package/test/__file_snapshots__/types/export-just-namespace/good8.d.ts.lint +0 -7
- package/test/__file_snapshots__/types/export-just-namespace/good9.d.ts.lint +0 -15
- package/test/__file_snapshots__/types/foo/foo-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/foo/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/foo/v1/foo-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/foo/v1/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-any-union/bad.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-any-union/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-any-union/no-any-union-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-bad-reference/index.d.ts.lint +0 -43
- package/test/__file_snapshots__/types/no-bad-reference/no-bad-reference-tests.ts.lint +0 -14
- package/test/__file_snapshots__/types/no-bad-reference/v0.1/index.d.ts.lint +0 -48
- package/test/__file_snapshots__/types/no-bad-reference/v0.1/no-bad-reference-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-bad-reference/v11/index.d.ts.lint +0 -48
- package/test/__file_snapshots__/types/no-bad-reference/v11/no-bad-reference-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-const-enum/bad.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-const-enum/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-const-enum/no-const-enum-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-dead-reference/bad.d.ts.lint +0 -18
- package/test/__file_snapshots__/types/no-dead-reference/bad2.d.ts.lint +0 -15
- package/test/__file_snapshots__/types/no-dead-reference/bad3.d.ts.lint +0 -17
- package/test/__file_snapshots__/types/no-dead-reference/index.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-dead-reference/no-dead-reference-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-declare-current-package/index.d.ts.lint +0 -13
- package/test/__file_snapshots__/types/no-declare-current-package/no-declare-current-package-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-declare-current-package/test/deep/import.d.ts.lint +0 -13
- package/test/__file_snapshots__/types/no-declare-current-package-other/index.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/bad.d.ts.lint +0 -17
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/index.d.ts.lint +0 -12
- package/test/__file_snapshots__/types/no-import-default-of-export-equals/no-import-default-of-export-equals-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/bad.d.ts.lint +0 -44
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/index.d.ts.lint +0 -25
- package/test/__file_snapshots__/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts.lint +0 -39
- package/test/__file_snapshots__/types/no-old-dt-header/index.d.ts.lint +0 -23
- package/test/__file_snapshots__/types/no-old-dt-header/index2.d.ts.lint +0 -14
- package/test/__file_snapshots__/types/no-old-dt-header/no-old-dt-header-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-old-dt-header/ok1.ts.lint +0 -11
- package/test/__file_snapshots__/types/no-old-dt-header/ok2.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-old-dt-header/ok3.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-old-dt-header/ok4.d.ts.lint +0 -12
- package/test/__file_snapshots__/types/no-relative-import-in-test/abc.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-relative-import-in-test/bad.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-relative-import-in-test/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test/abc.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts.lint +0 -7
- package/test/__file_snapshots__/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-relative-references/index.d.ts.lint +0 -51
- package/test/__file_snapshots__/types/no-relative-references/no-relative-references-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-relative-references/other/other.d.ts.lint +0 -31
- package/test/__file_snapshots__/types/no-relative-references/v1/index.d.ts.lint +0 -57
- package/test/__file_snapshots__/types/no-relative-references/v1/no-relative-references-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-relative-references/v1/other/other.d.ts.lint +0 -31
- package/test/__file_snapshots__/types/no-self-import/bad.d.ts.lint +0 -65
- package/test/__file_snapshots__/types/no-self-import/index.d.ts.lint +0 -19
- package/test/__file_snapshots__/types/no-self-import/no-self-import-tests.ts.lint +0 -39
- package/test/__file_snapshots__/types/no-single-declare-module/bad.d.ts.lint +0 -13
- package/test/__file_snapshots__/types/no-single-declare-module/index.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-single-declare-module/index2.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/no-single-declare-module/index3.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-single-declare-module/no-single-declare-module-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-single-element-tuple-type/bad.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-single-element-tuple-type/index.d.ts.lint +0 -9
- package/test/__file_snapshots__/types/no-single-element-tuple-type/no-single-element-tuple-type-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-unnecessary-generics/bad.d.ts.lint +0 -14
- package/test/__file_snapshots__/types/no-unnecessary-generics/index.d.ts.lint +0 -11
- package/test/__file_snapshots__/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts.lint +0 -44
- package/test/__file_snapshots__/types/no-useless-files/bad.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-useless-files/bad2.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-useless-files/bad3.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/no-useless-files/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-useless-files/index2.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-useless-files/index3.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/no-useless-files/no-useless-files-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/other/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/other/other-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/other/v1/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/other/v1/other-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/prefer-declare-function/bad.d.ts.lint +0 -33
- package/test/__file_snapshots__/types/prefer-declare-function/index.d.ts.lint +0 -14
- package/test/__file_snapshots__/types/prefer-declare-function/prefer-declare-function-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/redundant-undefined/bad.d.ts.lint +0 -15
- package/test/__file_snapshots__/types/redundant-undefined/index.d.ts.lint +0 -9
- package/test/__file_snapshots__/types/redundant-undefined/redundant-undefined-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__foo/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/scoped__foo/scoped__foo-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__foo/v1/index.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/scoped__foo/v1/scoped__foo-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/index.d.ts.lint +0 -13
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__no-declare-current-package/test/deep/import.d.ts.lint +0 -13
- package/test/__file_snapshots__/types/scoped__no-relative-references/index.d.ts.lint +0 -51
- package/test/__file_snapshots__/types/scoped__no-relative-references/no-relative-references-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__no-relative-references/other/other.d.ts.lint +0 -31
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/index.d.ts.lint +0 -57
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/no-relative-references-tests.ts.lint +0 -10
- package/test/__file_snapshots__/types/scoped__no-relative-references/v1/other/other.d.ts.lint +0 -31
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad1.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad2.d.ts.lint +0 -12
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad3.d.ts.lint +0 -10
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad4.d.ts.lint +0 -12
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad5.d.ts.lint +0 -11
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad6.d.ts.lint +0 -14
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/bad7.d.ts.lint +0 -14
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good1.ts.lint +0 -5
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good2.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good3.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good4.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good5.d.ts.lint +0 -5
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good6.ts.lint +0 -7
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good7.d.ts.lint +0 -6
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good8.d.ts.lint +0 -9
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/good9.d.ts.lint +0 -7
- package/test/__file_snapshots__/types/strict-export-declare-modifiers/strict-export-declare-modifiers-tests.ts.lint +0 -10
- package/test/__snapshots__/plugin.test.ts.snap +0 -262
- package/test/eslint.test.ts +0 -134
- package/test/fixtures/.eslintrc.cjs +0 -4
- package/test/fixtures/notNeededPackages.json +0 -3
- package/test/fixtures/package.json +0 -4
- package/test/fixtures/types/expect/expect-tests.ts +0 -49
- package/test/fixtures/types/expect/index.d.ts +0 -9
- package/test/fixtures/types/expect/package.json +0 -5
- package/test/fixtures/types/expect/tsconfig.json +0 -20
- package/test/fixtures/types/export-just-namespace/bad1.d.ts +0 -2
- package/test/fixtures/types/export-just-namespace/bad2.d.ts +0 -2
- package/test/fixtures/types/export-just-namespace/bad3.d.ts +0 -3
- package/test/fixtures/types/export-just-namespace/export-just-namespace-tests.ts +0 -0
- package/test/fixtures/types/export-just-namespace/good1.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good2.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good3.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good4.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good5.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good6.d.ts +0 -1
- package/test/fixtures/types/export-just-namespace/good7.d.ts +0 -3
- package/test/fixtures/types/export-just-namespace/good8.d.ts +0 -3
- package/test/fixtures/types/export-just-namespace/good9.d.ts +0 -3
- package/test/fixtures/types/export-just-namespace/package.json +0 -8
- package/test/fixtures/types/export-just-namespace/tsconfig.json +0 -31
- package/test/fixtures/types/foo/foo-tests.ts +0 -0
- package/test/fixtures/types/foo/index.d.ts +0 -1
- package/test/fixtures/types/foo/package.json +0 -5
- package/test/fixtures/types/foo/tsconfig.json +0 -20
- package/test/fixtures/types/foo/v1/foo-tests.ts +0 -0
- package/test/fixtures/types/foo/v1/index.d.ts +0 -1
- package/test/fixtures/types/foo/v1/package.json +0 -5
- package/test/fixtures/types/foo/v1/tsconfig.json +0 -20
- package/test/fixtures/types/no-any-union/bad.d.ts +0 -1
- package/test/fixtures/types/no-any-union/index.d.ts +0 -1
- package/test/fixtures/types/no-any-union/no-any-union-tests.ts +0 -1
- package/test/fixtures/types/no-any-union/package.json +0 -8
- package/test/fixtures/types/no-any-union/tsconfig.json +0 -21
- package/test/fixtures/types/no-bad-reference/index.d.ts +0 -16
- package/test/fixtures/types/no-bad-reference/no-bad-reference-tests.ts +0 -2
- package/test/fixtures/types/no-bad-reference/package.json +0 -5
- package/test/fixtures/types/no-bad-reference/tsconfig.json +0 -20
- package/test/fixtures/types/no-bad-reference/v0.1/index.d.ts +0 -15
- package/test/fixtures/types/no-bad-reference/v0.1/no-bad-reference-tests.ts +0 -0
- package/test/fixtures/types/no-bad-reference/v0.1/package.json +0 -5
- package/test/fixtures/types/no-bad-reference/v0.1/tsconfig.json +0 -20
- package/test/fixtures/types/no-bad-reference/v11/index.d.ts +0 -15
- package/test/fixtures/types/no-bad-reference/v11/no-bad-reference-tests.ts +0 -0
- package/test/fixtures/types/no-bad-reference/v11/package.json +0 -5
- package/test/fixtures/types/no-bad-reference/v11/tsconfig.json +0 -20
- package/test/fixtures/types/no-const-enum/bad.d.ts +0 -1
- package/test/fixtures/types/no-const-enum/index.d.ts +0 -1
- package/test/fixtures/types/no-const-enum/no-const-enum-tests.ts +0 -0
- package/test/fixtures/types/no-const-enum/package.json +0 -8
- package/test/fixtures/types/no-const-enum/tsconfig.json +0 -21
- package/test/fixtures/types/no-dead-reference/bad.d.ts +0 -6
- package/test/fixtures/types/no-dead-reference/bad2.d.ts +0 -3
- package/test/fixtures/types/no-dead-reference/bad3.d.ts +0 -5
- package/test/fixtures/types/no-dead-reference/index.d.ts +0 -2
- package/test/fixtures/types/no-dead-reference/no-dead-reference-tests.ts +0 -0
- package/test/fixtures/types/no-dead-reference/package.json +0 -8
- package/test/fixtures/types/no-dead-reference/tsconfig.json +0 -23
- package/test/fixtures/types/no-declare-current-package/index.d.ts +0 -1
- package/test/fixtures/types/no-declare-current-package/no-declare-current-package-tests.ts +0 -0
- package/test/fixtures/types/no-declare-current-package/package.json +0 -8
- package/test/fixtures/types/no-declare-current-package/test/deep/import.d.ts +0 -1
- package/test/fixtures/types/no-declare-current-package/tsconfig.json +0 -21
- package/test/fixtures/types/no-declare-current-package-other/index.d.ts +0 -2
- package/test/fixtures/types/no-declare-current-package-other/no-declare-current-package-other-tests.ts +0 -0
- package/test/fixtures/types/no-declare-current-package-other/package.json +0 -8
- package/test/fixtures/types/no-declare-current-package-other/tsconfig.json +0 -20
- package/test/fixtures/types/no-import-default-of-export-equals/bad.d.ts +0 -8
- package/test/fixtures/types/no-import-default-of-export-equals/index.d.ts +0 -8
- 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 +0 -8
- package/test/fixtures/types/no-import-default-of-export-equals/tsconfig.json +0 -21
- package/test/fixtures/types/no-import-of-dev-dependencies/bad.d.ts +0 -8
- package/test/fixtures/types/no-import-of-dev-dependencies/index.d.ts +0 -7
- package/test/fixtures/types/no-import-of-dev-dependencies/no-import-of-dev-dependencies-tests.ts +0 -15
- package/test/fixtures/types/no-import-of-dev-dependencies/package.json +0 -14
- package/test/fixtures/types/no-import-of-dev-dependencies/tsconfig.json +0 -21
- package/test/fixtures/types/no-old-dt-header/index.d.ts +0 -14
- package/test/fixtures/types/no-old-dt-header/index2.d.ts +0 -2
- 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 +0 -2
- package/test/fixtures/types/no-old-dt-header/ok2.d.ts +0 -1
- package/test/fixtures/types/no-old-dt-header/ok3.d.ts +0 -1
- package/test/fixtures/types/no-old-dt-header/ok4.d.ts +0 -3
- package/test/fixtures/types/no-old-dt-header/package.json +0 -8
- package/test/fixtures/types/no-old-dt-header/tsconfig.json +0 -25
- package/test/fixtures/types/no-relative-import-in-test/abc.d.ts +0 -2
- 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 +0 -1
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test/abc.d.ts +0 -2
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests.ts +0 -1
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests2.ts +0 -3
- package/test/fixtures/types/no-relative-import-in-test/no-relative-import-in-test-tests3.ts +0 -1
- package/test/fixtures/types/no-relative-import-in-test/package.json +0 -8
- package/test/fixtures/types/no-relative-import-in-test/tsconfig.json +0 -25
- package/test/fixtures/types/no-relative-references/index.d.ts +0 -12
- package/test/fixtures/types/no-relative-references/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/no-relative-references/other/other.d.ts +0 -7
- package/test/fixtures/types/no-relative-references/package.json +0 -5
- package/test/fixtures/types/no-relative-references/tsconfig.json +0 -21
- package/test/fixtures/types/no-relative-references/v1/index.d.ts +0 -15
- package/test/fixtures/types/no-relative-references/v1/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/no-relative-references/v1/other/other.d.ts +0 -7
- package/test/fixtures/types/no-relative-references/v1/package.json +0 -5
- package/test/fixtures/types/no-relative-references/v1/tsconfig.json +0 -21
- package/test/fixtures/types/no-self-import/bad.d.ts +0 -17
- package/test/fixtures/types/no-self-import/index.d.ts +0 -15
- package/test/fixtures/types/no-self-import/no-self-import-tests.ts +0 -15
- package/test/fixtures/types/no-self-import/package.json +0 -11
- package/test/fixtures/types/no-self-import/tsconfig.json +0 -21
- package/test/fixtures/types/no-single-declare-module/bad.d.ts +0 -4
- package/test/fixtures/types/no-single-declare-module/index.d.ts +0 -2
- package/test/fixtures/types/no-single-declare-module/index2.d.ts +0 -2
- package/test/fixtures/types/no-single-declare-module/index3.d.ts +0 -1
- 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 +0 -8
- package/test/fixtures/types/no-single-declare-module/tsconfig.json +0 -23
- package/test/fixtures/types/no-single-element-tuple-type/bad.d.ts +0 -1
- package/test/fixtures/types/no-single-element-tuple-type/index.d.ts +0 -5
- 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 +0 -8
- package/test/fixtures/types/no-single-element-tuple-type/tsconfig.json +0 -21
- package/test/fixtures/types/no-unnecessary-generics/bad.d.ts +0 -2
- package/test/fixtures/types/no-unnecessary-generics/index.d.ts +0 -7
- package/test/fixtures/types/no-unnecessary-generics/no-unnecessary-generics-tests.ts +0 -14
- package/test/fixtures/types/no-unnecessary-generics/package.json +0 -8
- package/test/fixtures/types/no-unnecessary-generics/tsconfig.json +0 -21
- package/test/fixtures/types/no-useless-files/bad.d.ts +0 -1
- package/test/fixtures/types/no-useless-files/bad2.d.ts +0 -0
- package/test/fixtures/types/no-useless-files/bad3.d.ts +0 -1
- package/test/fixtures/types/no-useless-files/index.d.ts +0 -1
- package/test/fixtures/types/no-useless-files/index2.d.ts +0 -1
- package/test/fixtures/types/no-useless-files/index3.d.ts +0 -1
- package/test/fixtures/types/no-useless-files/no-useless-files-tests.ts +0 -0
- package/test/fixtures/types/no-useless-files/package.json +0 -8
- package/test/fixtures/types/no-useless-files/tsconfig.json +0 -25
- package/test/fixtures/types/other/index.d.ts +0 -1
- package/test/fixtures/types/other/other-tests.ts +0 -0
- package/test/fixtures/types/other/package.json +0 -5
- package/test/fixtures/types/other/tsconfig.json +0 -20
- package/test/fixtures/types/other/v1/index.d.ts +0 -1
- package/test/fixtures/types/other/v1/other-tests.ts +0 -0
- package/test/fixtures/types/other/v1/package.json +0 -5
- package/test/fixtures/types/other/v1/tsconfig.json +0 -20
- package/test/fixtures/types/prefer-declare-function/bad.d.ts +0 -9
- package/test/fixtures/types/prefer-declare-function/index.d.ts +0 -2
- package/test/fixtures/types/prefer-declare-function/package.json +0 -8
- package/test/fixtures/types/prefer-declare-function/prefer-declare-function-tests.ts +0 -0
- package/test/fixtures/types/prefer-declare-function/tsconfig.json +0 -21
- package/test/fixtures/types/redundant-undefined/bad.d.ts +0 -3
- package/test/fixtures/types/redundant-undefined/index.d.ts +0 -5
- package/test/fixtures/types/redundant-undefined/package.json +0 -8
- package/test/fixtures/types/redundant-undefined/redundant-undefined-tests.ts +0 -1
- package/test/fixtures/types/redundant-undefined/tsconfig.json +0 -21
- package/test/fixtures/types/scoped__foo/index.d.ts +0 -1
- package/test/fixtures/types/scoped__foo/package.json +0 -5
- package/test/fixtures/types/scoped__foo/scoped__foo-tests.ts +0 -0
- package/test/fixtures/types/scoped__foo/tsconfig.json +0 -20
- package/test/fixtures/types/scoped__foo/v1/index.d.ts +0 -1
- package/test/fixtures/types/scoped__foo/v1/package.json +0 -5
- package/test/fixtures/types/scoped__foo/v1/scoped__foo-tests.ts +0 -0
- package/test/fixtures/types/scoped__foo/v1/tsconfig.json +0 -20
- package/test/fixtures/types/scoped__no-declare-current-package/index.d.ts +0 -1
- package/test/fixtures/types/scoped__no-declare-current-package/no-declare-current-package-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-declare-current-package/package.json +0 -8
- package/test/fixtures/types/scoped__no-declare-current-package/test/deep/import.d.ts +0 -1
- package/test/fixtures/types/scoped__no-declare-current-package/tsconfig.json +0 -21
- package/test/fixtures/types/scoped__no-relative-references/index.d.ts +0 -12
- package/test/fixtures/types/scoped__no-relative-references/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-relative-references/other/other.d.ts +0 -7
- package/test/fixtures/types/scoped__no-relative-references/package.json +0 -5
- package/test/fixtures/types/scoped__no-relative-references/tsconfig.json +0 -21
- package/test/fixtures/types/scoped__no-relative-references/v1/index.d.ts +0 -15
- package/test/fixtures/types/scoped__no-relative-references/v1/no-relative-references-tests.ts +0 -0
- package/test/fixtures/types/scoped__no-relative-references/v1/other/other.d.ts +0 -7
- package/test/fixtures/types/scoped__no-relative-references/v1/package.json +0 -5
- package/test/fixtures/types/scoped__no-relative-references/v1/tsconfig.json +0 -21
- package/test/fixtures/types/strict-export-declare-modifiers/bad1.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/bad2.d.ts +0 -3
- package/test/fixtures/types/strict-export-declare-modifiers/bad3.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/bad4.d.ts +0 -3
- package/test/fixtures/types/strict-export-declare-modifiers/bad5.d.ts +0 -2
- package/test/fixtures/types/strict-export-declare-modifiers/bad6.d.ts +0 -2
- package/test/fixtures/types/strict-export-declare-modifiers/bad7.d.ts +0 -2
- package/test/fixtures/types/strict-export-declare-modifiers/good1.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/good2.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/good3.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/good4.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/good5.d.ts +0 -1
- package/test/fixtures/types/strict-export-declare-modifiers/good6.ts +0 -3
- package/test/fixtures/types/strict-export-declare-modifiers/good7.d.ts +0 -2
- package/test/fixtures/types/strict-export-declare-modifiers/good8.d.ts +0 -5
- package/test/fixtures/types/strict-export-declare-modifiers/good9.d.ts +0 -3
- package/test/fixtures/types/strict-export-declare-modifiers/package.json +0 -8
- 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 +0 -35
- package/test/npm-naming.test.ts +0 -57
- package/test/plugin.test.ts +0 -14
- package/test/tsconfig.json +0 -13
- package/test/types/dts-critic/index.d.ts +0 -9
- package/test/types/dts-critic/package.json +0 -17
- package/test/types/wenceslas/index.d.ts +0 -0
- package/test/types/wenceslas/package.json +0 -17
- package/test/util.test.ts +0 -40
- package/test/util.ts +0 -3
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
import * as ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { createRule } from "../util";
|
|
5
|
-
|
|
6
|
-
const rule = createRule({
|
|
7
|
-
defaultOptions: [],
|
|
8
|
-
meta: {
|
|
9
|
-
docs: {
|
|
10
|
-
description: "Don't use an ambient module declaration if there's just one -- write it as a normal module.",
|
|
11
|
-
},
|
|
12
|
-
messages: {
|
|
13
|
-
oneModuleDeclaration:
|
|
14
|
-
"File has only 1 ambient module declaration. Move the contents outside the ambient module block, rename the file to match the ambient module name, and remove the block.",
|
|
15
|
-
},
|
|
16
|
-
schema: [],
|
|
17
|
-
type: "problem",
|
|
18
|
-
},
|
|
19
|
-
name: "no-single-declare-module",
|
|
20
|
-
create(context) {
|
|
21
|
-
const services = ESLintUtils.getParserServices(context);
|
|
22
|
-
const sourceFile = services.esTreeNodeToTSNodeMap.get(context.sourceCode.ast);
|
|
23
|
-
|
|
24
|
-
// If it's an external module, any module declarations inside are augmentations.
|
|
25
|
-
if (ts.isExternalModule(sourceFile)) {
|
|
26
|
-
return {};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let moduleDeclaration: ts.ModuleDeclaration | undefined;
|
|
30
|
-
for (const statement of sourceFile.statements) {
|
|
31
|
-
if (ts.isModuleDeclaration(statement) && ts.isStringLiteral(statement.name)) {
|
|
32
|
-
if (statement.name.text.indexOf("*") !== -1) {
|
|
33
|
-
// Ignore wildcard module declarations
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (moduleDeclaration === undefined) {
|
|
38
|
-
moduleDeclaration = statement;
|
|
39
|
-
} else {
|
|
40
|
-
// Has more than 1 declaration
|
|
41
|
-
return {};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (moduleDeclaration) {
|
|
47
|
-
context.report({
|
|
48
|
-
messageId: "oneModuleDeclaration",
|
|
49
|
-
node: services.tsNodeToESTreeNodeMap.get(moduleDeclaration.name),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {};
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export = rule;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../util";
|
|
2
|
-
import { TSESTree } from "@typescript-eslint/utils";
|
|
3
|
-
|
|
4
|
-
const rule = createRule({
|
|
5
|
-
name: "no-single-element-tuple-type",
|
|
6
|
-
defaultOptions: [],
|
|
7
|
-
meta: {
|
|
8
|
-
type: "problem",
|
|
9
|
-
docs: {
|
|
10
|
-
description: "Forbids `[T]`, which should be `T[]`.",
|
|
11
|
-
},
|
|
12
|
-
messages: {
|
|
13
|
-
singleElementTupleType: `Type [T] is a single-element tuple type. You probably meant T[].`,
|
|
14
|
-
},
|
|
15
|
-
schema: [],
|
|
16
|
-
},
|
|
17
|
-
create(context) {
|
|
18
|
-
return {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
20
|
-
"TSTupleType[elementTypes.length=1]"(node: TSESTree.TSTupleType) {
|
|
21
|
-
context.report({
|
|
22
|
-
messageId: "singleElementTupleType",
|
|
23
|
-
node,
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
export = rule;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
|
|
2
|
-
import * as ts from "typescript";
|
|
3
|
-
|
|
4
|
-
import { createRule } from "../util";
|
|
5
|
-
|
|
6
|
-
type ESTreeFunctionLikeWithTypeParameters = TSESTree.FunctionLike & {
|
|
7
|
-
typeParameters: {};
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type TSSignatureDeclarationWithTypeParameters = ts.SignatureDeclaration & {
|
|
11
|
-
typeParameters: {};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const rule = createRule({
|
|
15
|
-
defaultOptions: [],
|
|
16
|
-
meta: {
|
|
17
|
-
docs: {
|
|
18
|
-
description: "Forbids signatures using a generic parameter only once.",
|
|
19
|
-
},
|
|
20
|
-
messages: {
|
|
21
|
-
never: "Type parameter {{name}} is never used.",
|
|
22
|
-
sole: "Type parameter {{name}} is used only once.",
|
|
23
|
-
},
|
|
24
|
-
schema: [],
|
|
25
|
-
type: "problem",
|
|
26
|
-
},
|
|
27
|
-
name: "no-unnecessary-generics",
|
|
28
|
-
create(context) {
|
|
29
|
-
return {
|
|
30
|
-
[[
|
|
31
|
-
"ArrowFunctionExpression[typeParameters]",
|
|
32
|
-
"FunctionDeclaration[typeParameters]",
|
|
33
|
-
"FunctionExpression[typeParameters]",
|
|
34
|
-
"TSCallSignatureDeclaration[typeParameters]",
|
|
35
|
-
"TSConstructorType[typeParameters]",
|
|
36
|
-
"TSDeclareFunction[typeParameters]",
|
|
37
|
-
"TSFunctionType[typeParameters]",
|
|
38
|
-
"TSMethodSignature[typeParameters]",
|
|
39
|
-
].join(", ")](esNode: ESTreeFunctionLikeWithTypeParameters) {
|
|
40
|
-
const parserServices = ESLintUtils.getParserServices(context);
|
|
41
|
-
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(esNode) as TSSignatureDeclarationWithTypeParameters;
|
|
42
|
-
if (!tsNode.typeParameters) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const checker = parserServices.program.getTypeChecker();
|
|
47
|
-
|
|
48
|
-
for (const typeParameter of tsNode.typeParameters) {
|
|
49
|
-
const result = getSoleUse(tsNode, assertDefined(checker.getSymbolAtLocation(typeParameter.name)), checker);
|
|
50
|
-
|
|
51
|
-
if (result === "ok") {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
context.report({
|
|
56
|
-
data: { name: typeParameter.name.text },
|
|
57
|
-
messageId: result,
|
|
58
|
-
node: parserServices.tsNodeToESTreeNodeMap.get(typeParameter),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
type Result = "ok" | "never" | "sole";
|
|
67
|
-
|
|
68
|
-
function getSoleUse(sig: ts.SignatureDeclaration, typeParameterSymbol: ts.Symbol, checker: ts.TypeChecker): Result {
|
|
69
|
-
const exit = {};
|
|
70
|
-
let soleUse: ts.Identifier | undefined;
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
if (sig.typeParameters) {
|
|
74
|
-
for (const tp of sig.typeParameters) {
|
|
75
|
-
if (tp.constraint) {
|
|
76
|
-
recur(tp.constraint);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
for (const param of sig.parameters) {
|
|
81
|
-
if (param.type) {
|
|
82
|
-
recur(param.type);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (sig.type) {
|
|
86
|
-
recur(sig.type);
|
|
87
|
-
}
|
|
88
|
-
} catch (err) {
|
|
89
|
-
if (err === exit) {
|
|
90
|
-
return "ok";
|
|
91
|
-
}
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return soleUse ? "sole" : "never";
|
|
96
|
-
|
|
97
|
-
function recur(node: ts.Node): void {
|
|
98
|
-
if (ts.isIdentifier(node)) {
|
|
99
|
-
if (checker.getSymbolAtLocation(node) === typeParameterSymbol) {
|
|
100
|
-
if (soleUse === undefined) {
|
|
101
|
-
soleUse = node;
|
|
102
|
-
} else {
|
|
103
|
-
throw exit;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
node.forEachChild(recur);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export = rule;
|
|
113
|
-
|
|
114
|
-
function assertDefined<T>(value: T | undefined): T {
|
|
115
|
-
if (value === undefined) {
|
|
116
|
-
throw new Error("unreachable");
|
|
117
|
-
}
|
|
118
|
-
return value;
|
|
119
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { commentsMatching, createRule } from "../util";
|
|
2
|
-
|
|
3
|
-
const rule = createRule({
|
|
4
|
-
name: "no-useless-files",
|
|
5
|
-
defaultOptions: [],
|
|
6
|
-
meta: {
|
|
7
|
-
type: "problem",
|
|
8
|
-
docs: {
|
|
9
|
-
description: "Forbids files with no content.",
|
|
10
|
-
},
|
|
11
|
-
messages: {
|
|
12
|
-
noContent: "File has no content.",
|
|
13
|
-
},
|
|
14
|
-
schema: [],
|
|
15
|
-
},
|
|
16
|
-
create(context) {
|
|
17
|
-
const {
|
|
18
|
-
ast: { tokens, comments },
|
|
19
|
-
} = context.sourceCode;
|
|
20
|
-
|
|
21
|
-
if (tokens.length === 0) {
|
|
22
|
-
if (comments.length === 0) {
|
|
23
|
-
reportNoContent();
|
|
24
|
-
} else {
|
|
25
|
-
const referenceRegExp = /^\/\s*<reference\s*(types|path)\s*=\s*["|'](.*)["|']/;
|
|
26
|
-
let noReferenceFound = true;
|
|
27
|
-
commentsMatching(context.sourceCode, referenceRegExp, () => {
|
|
28
|
-
noReferenceFound = false;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (noReferenceFound) {
|
|
32
|
-
reportNoContent();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {};
|
|
38
|
-
|
|
39
|
-
function reportNoContent() {
|
|
40
|
-
context.report({
|
|
41
|
-
messageId: "noContent",
|
|
42
|
-
loc: {
|
|
43
|
-
start: { line: 1, column: 0 },
|
|
44
|
-
end: { line: 1, column: 0 },
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export = rule;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ExportErrorKind, Mode } from "@definitelytyped/dts-critic";
|
|
2
|
-
|
|
3
|
-
export type CodeRawOptionError = [ExportErrorKind, boolean];
|
|
4
|
-
|
|
5
|
-
export interface CodeRawOptions {
|
|
6
|
-
mode: Mode.Code;
|
|
7
|
-
errors: CodeRawOptionError[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface NameOnlyRawOptions {
|
|
11
|
-
mode: Mode.NameOnly;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type NpmNamingOptions = CodeRawOptions | NameOnlyRawOptions;
|
package/src/rules/npm-naming.ts
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckOptions as CriticOptions,
|
|
3
|
-
dtsCritic as critic,
|
|
4
|
-
ErrorKind,
|
|
5
|
-
ExportErrorKind,
|
|
6
|
-
Mode,
|
|
7
|
-
parseExportErrorKind,
|
|
8
|
-
CriticError,
|
|
9
|
-
} from "@definitelytyped/dts-critic";
|
|
10
|
-
|
|
11
|
-
import { addSuggestion } from "../suggestions";
|
|
12
|
-
import { createRule, isMainFile } from "../util";
|
|
13
|
-
import { CodeRawOptionError, NpmNamingOptions } from "./npm-naming/types";
|
|
14
|
-
|
|
15
|
-
function parseEnabledErrors(errors: CodeRawOptionError[]): [ExportErrorKind, boolean][] {
|
|
16
|
-
const enabledChecks: [ExportErrorKind, boolean][] = [];
|
|
17
|
-
for (const tuple of errors) {
|
|
18
|
-
const error = parseExportErrorKind(tuple[0]);
|
|
19
|
-
if (error) {
|
|
20
|
-
enabledChecks.push([error, tuple[1]]);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return enabledChecks;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function parseRawOptions(rawOptions: NpmNamingOptions): CriticOptions {
|
|
27
|
-
switch (rawOptions.mode) {
|
|
28
|
-
case Mode.Code:
|
|
29
|
-
return { ...rawOptions, errors: new Map(parseEnabledErrors(rawOptions.errors)) };
|
|
30
|
-
case Mode.NameOnly:
|
|
31
|
-
return rawOptions;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const enabledSuggestions: ExportErrorKind[] = [ErrorKind.JsPropertyNotInDts, ErrorKind.JsSignatureNotInDts];
|
|
36
|
-
|
|
37
|
-
function toOptionsWithSuggestions(options: CriticOptions): CriticOptions {
|
|
38
|
-
if (options.mode === Mode.NameOnly) {
|
|
39
|
-
return options;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const optionsWithSuggestions = { mode: options.mode, errors: new Map(options.errors) };
|
|
43
|
-
|
|
44
|
-
for (const err of enabledSuggestions) {
|
|
45
|
-
optionsWithSuggestions.errors.set(err, true);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return optionsWithSuggestions;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function eslintDisableOption(error: ErrorKind): string {
|
|
52
|
-
switch (error) {
|
|
53
|
-
case ErrorKind.NoMatchingNpmPackage:
|
|
54
|
-
case ErrorKind.NoMatchingNpmVersion:
|
|
55
|
-
case ErrorKind.NonNpmHasMatchingPackage:
|
|
56
|
-
return `"off"`;
|
|
57
|
-
case ErrorKind.NoDefaultExport:
|
|
58
|
-
case ErrorKind.NeedsExportEquals:
|
|
59
|
-
case ErrorKind.JsSignatureNotInDts:
|
|
60
|
-
case ErrorKind.JsPropertyNotInDts:
|
|
61
|
-
case ErrorKind.DtsSignatureNotInJs:
|
|
62
|
-
case ErrorKind.DtsPropertyNotInJs:
|
|
63
|
-
return JSON.stringify(["error", { mode: Mode.Code, errors: [[error, false]] }]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const rule = createRule<[NpmNamingOptions], "error">({
|
|
68
|
-
name: "npm-naming",
|
|
69
|
-
defaultOptions: [
|
|
70
|
-
{
|
|
71
|
-
mode: Mode.NameOnly,
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
meta: {
|
|
75
|
-
type: "problem",
|
|
76
|
-
docs: {
|
|
77
|
-
description: "Ensure that package name and DefinitelyTyped header match npm package info.",
|
|
78
|
-
},
|
|
79
|
-
messages: {
|
|
80
|
-
error: `{{ error }}
|
|
81
|
-
If you won't fix this error now or you think this error is wrong,
|
|
82
|
-
you can disable this check by adding the following options to your project's .eslintrc.json file under "rules":
|
|
83
|
-
|
|
84
|
-
"@definitelytyped/npm-naming": {{ option }}`,
|
|
85
|
-
},
|
|
86
|
-
schema: [
|
|
87
|
-
{
|
|
88
|
-
oneOf: [
|
|
89
|
-
{
|
|
90
|
-
additionalProperties: false,
|
|
91
|
-
properties: {
|
|
92
|
-
mode: {
|
|
93
|
-
type: "string",
|
|
94
|
-
enum: [Mode.NameOnly],
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
type: "object",
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
additionalProperties: false,
|
|
101
|
-
type: "object",
|
|
102
|
-
properties: {
|
|
103
|
-
mode: {
|
|
104
|
-
type: "string",
|
|
105
|
-
enum: [Mode.Code],
|
|
106
|
-
},
|
|
107
|
-
errors: {
|
|
108
|
-
type: "array",
|
|
109
|
-
items: {
|
|
110
|
-
type: "array",
|
|
111
|
-
items: [
|
|
112
|
-
{
|
|
113
|
-
description: "Name of the check.",
|
|
114
|
-
type: "string",
|
|
115
|
-
enum: [ErrorKind.NeedsExportEquals, ErrorKind.NoDefaultExport],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
description: "Whether the check is enabled or disabled.",
|
|
119
|
-
type: "boolean",
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
minItems: 2,
|
|
123
|
-
maxItems: 2,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
create(context, [rawOptions]) {
|
|
133
|
-
if (!isMainFile(context.filename, /*allowNested*/ false)) {
|
|
134
|
-
return {};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const options = parseRawOptions(rawOptions);
|
|
138
|
-
const optionsWithSuggestions = toOptionsWithSuggestions(options);
|
|
139
|
-
const diagnostics = critic(context.filename, /* sourcePath */ undefined, optionsWithSuggestions);
|
|
140
|
-
const errors = filterErrors(diagnostics);
|
|
141
|
-
|
|
142
|
-
for (const error of errors) {
|
|
143
|
-
switch (error.kind) {
|
|
144
|
-
case ErrorKind.NoMatchingNpmPackage:
|
|
145
|
-
case ErrorKind.NoMatchingNpmVersion:
|
|
146
|
-
case ErrorKind.NonNpmHasMatchingPackage:
|
|
147
|
-
case ErrorKind.DtsPropertyNotInJs:
|
|
148
|
-
case ErrorKind.DtsSignatureNotInJs:
|
|
149
|
-
case ErrorKind.JsPropertyNotInDts:
|
|
150
|
-
case ErrorKind.JsSignatureNotInDts:
|
|
151
|
-
case ErrorKind.NeedsExportEquals:
|
|
152
|
-
case ErrorKind.NoDefaultExport:
|
|
153
|
-
context.report({
|
|
154
|
-
data: {
|
|
155
|
-
error: error.message,
|
|
156
|
-
option: eslintDisableOption(error.kind),
|
|
157
|
-
},
|
|
158
|
-
loc: error.position
|
|
159
|
-
? {
|
|
160
|
-
start: context.sourceCode.getLocFromIndex(error.position.start),
|
|
161
|
-
end: context.sourceCode.getLocFromIndex(error.position.start + error.position.length),
|
|
162
|
-
}
|
|
163
|
-
: {
|
|
164
|
-
end: {
|
|
165
|
-
line: 2,
|
|
166
|
-
column: 0,
|
|
167
|
-
},
|
|
168
|
-
start: {
|
|
169
|
-
line: 1,
|
|
170
|
-
column: 0,
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
messageId: "error",
|
|
174
|
-
});
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {};
|
|
180
|
-
|
|
181
|
-
function filterErrors(diagnostics: CriticError[]): CriticError[] {
|
|
182
|
-
const errors: CriticError[] = [];
|
|
183
|
-
|
|
184
|
-
diagnostics.forEach((diagnostic) => {
|
|
185
|
-
if (isSuggestion(diagnostic)) {
|
|
186
|
-
addSuggestion(
|
|
187
|
-
context.filename,
|
|
188
|
-
"npm-naming",
|
|
189
|
-
diagnostic.message,
|
|
190
|
-
diagnostic.position?.start,
|
|
191
|
-
diagnostic.position?.length,
|
|
192
|
-
);
|
|
193
|
-
} else {
|
|
194
|
-
errors.push(diagnostic);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
return errors;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function isSuggestion(diagnostic: CriticError): boolean {
|
|
202
|
-
return (
|
|
203
|
-
options.mode === Mode.Code &&
|
|
204
|
-
enabledSuggestions.includes(diagnostic.kind as ExportErrorKind) &&
|
|
205
|
-
!(options.errors as Map<ErrorKind, boolean>).get(diagnostic.kind)
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
export = rule;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
|
-
import { createRule } from "../util";
|
|
4
|
-
import { isDeclarationPath } from "@definitelytyped/utils";
|
|
5
|
-
|
|
6
|
-
const rule = createRule({
|
|
7
|
-
defaultOptions: [],
|
|
8
|
-
meta: {
|
|
9
|
-
docs: {
|
|
10
|
-
description: "Forbids `const x: () => void`.",
|
|
11
|
-
},
|
|
12
|
-
messages: {
|
|
13
|
-
variableFunction: "Use a function declaration instead of a variable of function type.",
|
|
14
|
-
},
|
|
15
|
-
schema: [],
|
|
16
|
-
type: "problem",
|
|
17
|
-
},
|
|
18
|
-
name: "prefer-declare-function",
|
|
19
|
-
create(context) {
|
|
20
|
-
return {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
|
-
"VariableDeclaration > VariableDeclarator"(node: TSESTree.VariableDeclarator) {
|
|
23
|
-
if (
|
|
24
|
-
node.id.typeAnnotation?.typeAnnotation.type === AST_NODE_TYPES.TSFunctionType &&
|
|
25
|
-
isDeclarationPath(context.filename)
|
|
26
|
-
) {
|
|
27
|
-
context.report({
|
|
28
|
-
messageId: "variableFunction",
|
|
29
|
-
node: node.id,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export = rule;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { createRule } from "../util";
|
|
2
|
-
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
3
|
-
import { TSESTree } from "@typescript-eslint/types";
|
|
4
|
-
|
|
5
|
-
const rule = createRule({
|
|
6
|
-
name: "redundant-undefined",
|
|
7
|
-
defaultOptions: [],
|
|
8
|
-
meta: {
|
|
9
|
-
type: "problem",
|
|
10
|
-
docs: {
|
|
11
|
-
description:
|
|
12
|
-
"Forbids optional parameters from including an explicit `undefined` in their type; requires it in optional properties.",
|
|
13
|
-
},
|
|
14
|
-
messages: {
|
|
15
|
-
redundantUndefined: `Parameter is optional, so no need to include \`undefined\` in the type.`,
|
|
16
|
-
},
|
|
17
|
-
schema: [],
|
|
18
|
-
},
|
|
19
|
-
create(context) {
|
|
20
|
-
return {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
22
|
-
TSUnionType(node) {
|
|
23
|
-
const hasUndefinedType = node.types.some((t) => t.type === AST_NODE_TYPES.TSUndefinedKeyword);
|
|
24
|
-
if (
|
|
25
|
-
node.parent!.type === AST_NODE_TYPES.TSTypeAnnotation &&
|
|
26
|
-
isParameter(node.parent!.parent!) &&
|
|
27
|
-
node.parent.parent.optional &&
|
|
28
|
-
isFunctionLike(node.parent!.parent!.parent!) &&
|
|
29
|
-
hasUndefinedType
|
|
30
|
-
) {
|
|
31
|
-
context.report({
|
|
32
|
-
messageId: "redundantUndefined",
|
|
33
|
-
node,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
function isFunctionLike(node: TSESTree.Node): node is TSESTree.FunctionLike {
|
|
42
|
-
return (
|
|
43
|
-
node.type === AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
44
|
-
node.type === AST_NODE_TYPES.FunctionDeclaration ||
|
|
45
|
-
node.type === AST_NODE_TYPES.FunctionExpression ||
|
|
46
|
-
node.type === AST_NODE_TYPES.TSDeclareFunction ||
|
|
47
|
-
node.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
/** Note: Does not include parameter properties because those can't be optional */
|
|
51
|
-
function isParameter(node: TSESTree.Node): node is Exclude<TSESTree.Parameter, TSESTree.TSParameterProperty> {
|
|
52
|
-
return (
|
|
53
|
-
node.type === AST_NODE_TYPES.ArrayPattern ||
|
|
54
|
-
node.type === AST_NODE_TYPES.AssignmentPattern ||
|
|
55
|
-
node.type === AST_NODE_TYPES.Identifier ||
|
|
56
|
-
node.type === AST_NODE_TYPES.ObjectPattern ||
|
|
57
|
-
node.type === AST_NODE_TYPES.RestElement
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export = rule;
|