Skip to content

Lint to prevent additions of new non-TypeScript scripts#10496

Merged
aduth merged 1 commit intomainfrom
aduth-lint-typescript-files
Apr 24, 2024
Merged

Lint to prevent additions of new non-TypeScript scripts#10496
aduth merged 1 commit intomainfrom
aduth-lint-typescript-files

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Apr 24, 2024

🛠 Summary of changes

Adds a new lint step as part of continuous integration to prevent the addition of new non-TypeScript script files.

This follows from our documented convention that "all new code is expected to be written using TypeScript", and motivated by observations that we're not always consistent in following this guideline.

Listing legacy files should hopefully also provide some incentive to port legacy files to TypeScript equivalents.

📜 Testing Plan

make lint_new_typescript_files should pass.

Try adding a new .js or .jsx file within app/javascript, app/components, or spec/javascript, and observe that make lint_new_typescript_files fails.

changelog: Internal, Automated Testing, Add test to enforce TypeScript conventions
"name": "@18f/identity-assets",
"private": true,
"version": "1.0.0",
"exports": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some packages are intentionally written in JavaScript because we expect them to be loaded directly by Node.js without any pre/post-processing (e.g. Webpack plugins, Sass compilation, various configurations, etc.). The way I approached this was to check for a defined entrypoint, since this would describe how Node.js would be expected to resolve a package.

@aduth aduth merged commit 5b1b15e into main Apr 24, 2024
@aduth aduth deleted the aduth-lint-typescript-files branch April 24, 2024 15:07
lint_lockfiles: lint_gemfile_lock lint_yarn_lock ## Lints to ensure lockfiles are in sync

lint_new_typescript_files:
scripts/enforce-typescript-files.mjs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the irony of checking for new typescript files with a plain JS file! 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants