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 an example to api docs where typescript is used #6

Open
saadq opened this issue May 17, 2018 · 2 comments
Open

Add an example to api docs where typescript is used #6

saadq opened this issue May 17, 2018 · 2 comments
Labels
docs This issue is about adding or improving docs. good first issue Good for newcomers.

Comments

@saadq
Copy link
Owner

saadq commented May 17, 2018

The current API docs: https://github.com/saadq/lynt#api

There should be an example that shows how project works with the TypeScript flag. By default, if no project flag is passed and the files argument is an empty array, lynt will assume that project is in the current working directory . and will look for a tsconfig.json there.

import lynt from 'lynt'

const options = {
  typescript: true
}

const results = lynt([], options) // Will look for `./tsconfig.json` and use that to know which files to lint in the project.

A project option can be explicitly passed if tsconfig.json isn't in the current directory (like in ./config/tsconfig.json):

import lynt from 'lynt'

const options = {
  typescript: true,
  project: './config'
}

const results = lynt([], options) // Will look for `./config/tsconfig.json` and use that to know which files to lint in the project.

If files are given, a project flag should not be passed in (because it will just ignore the files and just use the tsconfig in the project to know which files to lint). However, passing files when using the typescript option will make you opt-out of some lint rules that require type information from the whole project, so passing in files is not recommended.

// Not recommended

import lynt from 'lynt'

const files = ['./foo.ts', './bar.ts']

const options = {
  typescript: true
}

const results = lynt(files, options) 
@saadq saadq added docs This issue is about adding or improving docs. good first issue Good for newcomers. labels May 17, 2018
@saadq saadq changed the title add an example to api docs where typescript is used Add an example to api docs where typescript is used May 17, 2018
@tunnckoCore
Copy link

Yea i was wondering about that option and know kinda understand what is about, so consider to rename it? Might make more sense to be such as tsroot, typescript-root, tsconfig-root or whatever.. don't know exactly.

@saadq
Copy link
Owner Author

saadq commented May 19, 2018

Those might be more explicit, but I want to keep the name project because it will be familiar to TSLint users. The flag for giving a path to your tsconfig.json with TSLint is also called --project https://palantir.github.io/tslint/usage/cli/#cli-usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is about adding or improving docs. good first issue Good for newcomers.
Projects
None yet
Development

No branches or pull requests

2 participants