saadq/lynt

Add an example to api docs where typescript is used

Open

#6 opened on 2018年5月17日

GitHub で見る
 (2 comments) (1 reaction) (0 assignees)TypeScript (6 forks)github user discovery
docsgood first issue

Repository metrics

Stars
 (383 stars)
PR merge metrics
 (PR metrics pending)

説明

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) 

コントリビューターガイド