Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find unused exports #3178

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Find unused exports #3178

merged 2 commits into from
Jun 6, 2023

Conversation

himdel
Copy link
Collaborator

@himdel himdel commented Jan 13, 2023

Using https://github.com/jaydenseric/find-unused-exports to find dead exports/dead code, and cleaning up.

Except it doesn't know about our src/ alias.

So adding tasks to undo/redo the src convert .. and making this a draft, the way to run it now is...

npm run imports-to-relative
npm run find-unused-exports
# manually fix any problems
npm run imports-to-src
npm run prettier

Cleanup of unused exports happened in #3176

tooling maybe https://github.com/jaydenseric/find-unused-exports/issues/4?

Or switch to https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unused-modules.md ?

Or just add "lint:exports": "npm-run-all imports-to-relative find-unused-exports imports-to-src prettier" ?

@github-actions github-actions bot added backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) labels Jan 13, 2023
@himdel himdel added cleanup Dead code removal, etc and removed backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) labels Jan 13, 2023
@himdel himdel force-pushed the find-unused-exports branch from 24a2216 to 8d10e47 Compare January 17, 2023 04:15
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Feb 7, 2023
… forth for find-unused-exports

    $ npm run imports-to-relative ; npm run find-unused-exports ; npm run imports-to-src

    > ansible-hub-ui@0.1.0 imports-to-relative
    > perl -i -pe 's#from '\''src/#from '\''../#' src/*/*.* ; perl -i -pe 's#from '\''src/#from '\''../../#' src/*/*/*.* ; perl -i -pe 's#from '\''src/#from '\''../../../#' src/*/*/*/*.*

    > ansible-hub-ui@0.1.0 find-unused-exports
    > npx find-unused-exports --module-glob 'src/**/*.{js,ts,jsx,tsx}' --resolve-file-extensions 'tsx,ts,jsx,js' --resolve-index-files

    src/containers/token/token-insights.tsx
      default

    1 unused export in 1 module.

    > ansible-hub-ui@0.1.0 imports-to-src
    > perl -i -pe 's#from '\''\.\./#from '\''src/#' src/*/*.* ; perl -i -pe 's#from '\''\.\./\.\./#from '\''src/#' src/*/*/*.* ; perl -i -pe 's#from '\''\.\./\.\./\.\./#from '\''src/#' src/*/*/*/*.*

(ansible#3178)
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Feb 7, 2023
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Feb 7, 2023
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Feb 7, 2023
himdel added a commit to himdel/ansible-hub-ui that referenced this pull request Feb 7, 2023
himdel added a commit that referenced this pull request Feb 8, 2023
* Drop more insights-related code

No-Issue

* npm run imports-to-relative, find-unused-exports, imports-to-src

and clean up unused exports

(#3178, #319)

* prettier: add plugin to sort imports

sort external imports first, then src/, then any relative paths
sort imports by source name, sort specifiers

bump prettier to 2.8
ensure app.scss goes before patternfly.scss

(#3198)

* npm run prettier

* sort index.ts exports

    perl -i -npe 's/^export/import/' src/**/index.ts
    npm run prettier
    perl -i -npe 's/^import/export/' src/**/index.ts
himdel added a commit that referenced this pull request Feb 8, 2023
* Drop more insights-related code

No-Issue

* npm run imports-to-relative, find-unused-exports, imports-to-src

and clean up unused exports

(#3178)

* prettier: add plugin to sort imports

sort external imports first, then src/, then any relative paths
sort imports by source name, sort specifiers

bump prettier to 2.8
ensure app.scss goes before patternfly.scss

(#3198)

* npm run prettier

* sort index.ts exports

    perl -i -npe 's/^export/import/' src/**/index.ts
    npm run prettier
    perl -i -npe 's/^import/export/' src/**/index.ts
himdel added a commit that referenced this pull request Feb 8, 2023
* Drop more insights-related code

No-Issue

* npm run imports-to-relative, find-unused-exports, imports-to-src

and clean up unused exports

(#3178)

* prettier: add plugin to sort imports

sort external imports first, then src/, then any relative paths
sort imports by source name, sort specifiers

bump prettier to 2.8
ensure app.scss goes before patternfly.scss

(#3198)

* npm run prettier

* sort index.ts exports

    perl -i -npe 's/^export/import/' src/**/index.ts
    npm run prettier
    perl -i -npe 's/^import/export/' src/**/index.ts
himdel added a commit that referenced this pull request Feb 8, 2023
* Drop more insights-related code

No-Issue

* npm run imports-to-relative, find-unused-exports, imports-to-src

and clean up unused exports

(#3178)

* prettier: add plugin to sort imports

sort external imports first, then src/, then any relative paths
sort imports by source name, sort specifiers

bump prettier to 2.8
ensure app.scss goes before patternfly.scss

(#3198)

* npm run prettier

* sort index.ts exports

    perl -i -npe 's/^export/import/' src/**/index.ts
    npm run prettier
    perl -i -npe 's/^import/export/' src/**/index.ts
@himdel himdel marked this pull request as ready for review June 6, 2023 18:46
https://github.com/jaydenseric/find-unused-exports

Note: the task doesn't work, as it will ignore any import from 'src/...'

No-Issues
@himdel himdel force-pushed the find-unused-exports branch from 8d10e47 to 9337720 Compare June 6, 2023 18:47
… forth for find-unused-exports

    $ npm run imports-to-relative ; npm run find-unused-exports ; npm run imports-to-src

    > ansible-hub-ui@0.1.0 imports-to-relative
    > perl -i -pe 's#from '\''src/#from '\''../#' src/*/*.* ; perl -i -pe 's#from '\''src/#from '\''../../#' src/*/*/*.* ; perl -i -pe 's#from '\''src/#from '\''../../../#' src/*/*/*/*.*

    > ansible-hub-ui@0.1.0 find-unused-exports
    > npx find-unused-exports --module-glob 'src/**/*.{js,ts,jsx,tsx}' --resolve-file-extensions 'tsx,ts,jsx,js' --resolve-index-files

    src/containers/token/token-insights.tsx
      default

    1 unused export in 1 module.

    > ansible-hub-ui@0.1.0 imports-to-src
    > perl -i -pe 's#from '\''\.\./#from '\''src/#' src/*/*.* ; perl -i -pe 's#from '\''\.\./\.\./#from '\''src/#' src/*/*/*.* ; perl -i -pe 's#from '\''\.\./\.\./\.\./#from '\''src/#' src/*/*/*/*.*

No-Issue
@himdel himdel force-pushed the find-unused-exports branch from 9337720 to e233166 Compare June 6, 2023 19:24
@himdel himdel merged commit 11d6200 into ansible:master Jun 6, 2023
@himdel himdel deleted the find-unused-exports branch June 6, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Dead code removal, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant