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

Add support for linting .ts and .tsx files #7

Merged
2 commits merged into from
Dec 22, 2017
Merged

Conversation

LucianBuzzo
Copy link
Contributor

Connects to #3

change-type: minor

Copy link
Contributor

@CameronDiver CameronDiver left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@thgreasi thgreasi left a comment

Choose a reason for hiding this comment

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

👍
Mostly about the describe parts

scripts = findFiles(['ts', 'tsx'], paths)
errorReport = lintTsFiles(scripts, config)

console.log(errorReport.output)
Copy link
Contributor

@thgreasi thgreasi Dec 22, 2017

Choose a reason for hiding this comment

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

Do we need this?
On second thought, probably yes I guess...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep we need this, this is how we display the result of the linting process to the end user

.boolean('u', 'Run unused import check')

if options.argv._.length < 1 and not options.argv.p
options.showHelp()
process.exit(1)

configPath = if options.argv.typescript then TS_CONFIG_PATH else CS_CONFIG_PATH
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this can move closer to config = parseJSON(configPath)

process.exit(errorReport.getExitCode())

if options.argv.typescript
scripts = findFiles(['ts', 'tsx'], paths)
Copy link
Contributor

Choose a reason for hiding this comment

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

No string opinion on this, but would it make sense to abstract the content of the if & the else into separate functions?
I would find it great to have a single if statement for the linting mode (argv.typescript).
I'm thinking of having a runTsLint & a runCoffeeLint function that only accept paths & options.argv.i as options.

Internally they could call a getConfig(XS_CONFIG_PATH, 'Xlint.json', options.argv.i) method that would handle the loading, merging and config override.

This way it would be easier if at some point we decide to extend this to run on multiple targets as well.

linter.lint(file, source, parsedConfig)
return linter.getResult()


module.exports = (passed_params) ->
try
options = optimist(passed_params)
.usage('Usage: resin-lint [options] [...]')
.describe('f', 'Specify a coffeelint config file to override resin-lint rules')
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some occurrences of coffee in these describe statements.


CONFIG_PATH = path.join(__dirname, '../config/coffeelint.json')
CS_CONFIG_PATH = path.join(__dirname, '../config/coffeelint.json')
TS_CONFIG_PATH = path.join(__dirname, '../config/tslint.json')
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an idea: How about using an object, containing the config filename (& possibly the target file types as well)?

@LucianBuzzo
Copy link
Contributor Author

@thgreasi Thanks for the feedback. I've tightened up the code and I think it will be much better suited to adding more languages in the future

@LucianBuzzo LucianBuzzo requested a review from thgreasi December 22, 2017 10:04
Copy link
Contributor

@thgreasi thgreasi left a comment

Choose a reason for hiding this comment

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

👍 🎄 🎅 🎁

Connects to #3

change-type: minor
@ghost ghost merged commit 2935d09 into master Dec 22, 2017
@ghost ghost deleted the 3-typescript-support branch December 22, 2017 14:48
This pull request was closed.
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