@hint/parser-typescript
v1.0.26
Published
webhint parser needed to analyze TypeScript files
Downloads
76,648
Readme
TypeScript (@hint/parser-typescript
)
The typescript
parser emits the same events as @hint/parser-javascript
so existing hints targeting JavaScript files can analyze TypeScript files
without modification. Existing hints targeting HTML files can also analyze
TSX content without modification if @hint/parser-jsx
is active in addition
to this parser.
This package is installed automatically by webhint:
npm install hint --save-dev
To use it, activate it via the .hintrc
configuration file:
{
"connector": {...},
"formatters": [...],
"hints": {
...
},
"parsers": ["jsx", "typescript"],
...
}
Note: The recommended way of running webhint is as a devDependency
of
your project.
Events emitted
This parser
emits the following events:
parse::start::javascript
of typeEvent
which contains the following information:resource
: the resource we are going to parse.
parse::end::javascript
, of typeScriptParse
which contains the following information:ast
: anESTree
AST generated from the script.element
: anHTMLElement
reference if the source was inline in HTML;null
otherwise.resource
: the parsed resource. If the script is in ascript tag
and not a file, the value will refer to the HTML document containing the script.sourceCode
: the raw source code that was parsed.tokens
: a list of tokens generated from the source code.walk
: helper methods for walking the AST.