eslint-plugin-no-explicit-type-exports icon indicating copy to clipboard operation
eslint-plugin-no-explicit-type-exports copied to clipboard

Refactor and add full import export support

Open alexogeny opened this issue 4 years ago • 2 comments

What changed

  • Added support for detecting imports that use asType syntax
    • import {example as Example} -> import type { example as Example }
    • included two tests
  • Added support for detecting locally declared types/interfaces: type example = string; export type example
    • type example = string; export example -> type example = string; export type example
    • included two tests
  • Added more explicit type annotations (including LintContext type and return types that were missing)
  • Added a getTypeDeclarations.ts to support linting for locally declared types/interfaces
  • Added a helper function to avoid DRY badness when searching for aliased imports/exports in arrays/sets
  • Interfaces used in tests are now properly Pascal-cased
  • Some minor cleanups of files here and there

Why

  • The lint plugin had no support for types that are aliased using asType syntax
  • The plugin didn't support types that were locally declared and then not explicitly exported as types
  • There were multiple usages of any type annotations which is discouraged
  • Interfaces should be Pascal-cased

Todo:

  • [ ] Add Semantic Version Label
  • [x] Add tests
  • [ ] Add docs

alexogeny avatar Aug 09 '21 05:08 alexogeny

One more minor regression to fix before I can mark this as ready.

alexogeny avatar Aug 09 '21 23:08 alexogeny

Running through our codebase I missed another scenario. Marking as draft.

alexogeny avatar Aug 10 '21 01:08 alexogeny