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

Proposal: convert to TypeScript completely #338

Closed
orangain opened this issue Feb 10, 2024 · 2 comments · Fixed by #339
Closed

Proposal: convert to TypeScript completely #338

orangain opened this issue Feb 10, 2024 · 2 comments · Fixed by #339

Comments

@orangain
Copy link
Contributor

orangain commented Feb 10, 2024

Motivation

Currently, the code in this repository is written in JavaScript and TypeScript. I think it would be a good idea to convert the code to TypeScript completely. This would make the code more maintainable and easier to understand.

In addition, if the type definition of the configuration object, to be defined in the .schemalintrc.js file,
is exported as a part of the npm package, users can use it via JSDoc import types when writing their own config file in JavaScript.

If this proposal is acceptable, I would like to work on it.

Related issues

I found some past issues that tried to convert the JavaScript to TypeScript, but they seem to have been abandoned.

Concern

Since the code written in JavaScript is well-structured, it should be easy to convert it to TypeScript. My only concern is that the test cases written in JavaScript (nameCasing.test.js and nameInflection.test.js) use test.each function that takes a template string table as an argument, which leads to many anys when converted to TypeScript. Let me confirm, is there any problem with converting the template string table into an array of objects?

@kristiandupont
Copy link
Owner

Yes, this would be nice. It would also be nice to allow people writing rules and configuration in TS (people have requested that for Kanel as well), but that's a bit of a bigger step. Feel free to make this conversion if you please!

@orangain
Copy link
Contributor Author

@kristiandupont Thank you for the response. Yes, it would be nice to allow users to write rules and configuration in TypeScript. However, even if it remains in JavaScript, I believe that by providing type information, users can develop efficiently with editors that support TypeScript.

An example usage of the type information is as follows:

// .schemalintrc.js

/** @type {import('schemalint').Config} */
module.exports = {
  // ...
};
// customeRule.js

/** @type {import('schemalint').Rule} */
module.exports = {
  // ...
};

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 a pull request may close this issue.

2 participants