TypeScript linter plugin for Gulp. Based on gulp-tslint by panuhorsmalahti but updated for 2018/2019 coding methods and packages
Gulp down that milk
Add milky-tslint with npm or yarn
yarn add -D milky-tslint
npm i --save-dev milky-tslint
Peer dependencies
The tslint
module is a peer dependency of milky-tslint
, which allows you to update tslint independently from milky-tslint. milky-tslint requires TypeScript version >=2 and tslint version >=4.
Usage:
const tslint = ;const ts = ;const milkyLint milkyReport = ; gulp;
TSLint Type Checking will work if you first use the createProgram
function as shown above. You should do this inside the gulp task, otherwise it will get cached and not function in consecutive runs of the task.
tslint.json is attempted to be read from near the input file. It must be available or supplied directly through the options.
The format in which failures are outputted may be controlled by specifying a TSLint formatter.
The default formatter is stylish
and the supported formatters are at least:
- checkstyle - Formats errors as though they were Checkstyle output.
- codeFrame - Framed formatter which creates a frame of error code.
- filesList - Lists files containing lint errors.
- json - Formats errors as simple JSON.
- junit - Formats errors as though they were JUnit output.
- msbuild - Formats errors for consumption by msbuild.
- pmd - Formats errors as though they were PMD output.
- prose - The default formatter which outputs simple human-readable messages.
- stylish - Human-readable formatter which creates stylish messages.
- tap - Formats output as TAP stream.
- verbose - The human-readable formatter which includes the rule name in messages.
- vso - Formats output as VSO/TFS logging commands.
For a full list of supported formatters please go to the TSLint core formatters documentation
Custom TSLint formatters may also be
used by specifying the formatter
and formattersDirectory
properties on the options passed to
milky-tslint
.
If there is at least one failure a PluginError is emitted after execution of the reporters:
gulp Error in plugin 'milky-tslint': Failed to lint: inputts
You can prevent editing the error by setting emitError in report options to false.
gulp;
tslint.json can be supplied as a parameter by setting the configuration property.
gulp;
You can also supply a file path to the configuration option, and the file name doesn't need to be tslint.json.
Report limits
You can optionally specify a report limit in the .report options that will turn off reporting for files after the limit has been reached. If the limit is 0 or less, the limit is ignored, which is the default setting.
gulp;
Allowing Warnings
TSLint 5.0 introduced support for a "warning" severity for linting errors. By default, warnings cause milky-tslint
to emit an error to maintain backwards-compatibility with previous versions. To let the build succeed in the presence of warnings, use the allowWarnings
report option.
gulp;
All default tslint options
const tslintOptions = configuration: {} fix: false formatter: 'stylish' formattersDirectory: null rulesDirectory: null tslint: null program: null;
All default report options
const reportOptions = emitError: false reportLimit: 0 summarizeFailureOutput: true allowWarnings: false;
Development
- Fork this repository
- Install dependencies with
yarn
- Make changes
- Compile to JS with
gulp build
- Confirm linting is correct with
gulp lint
- Send pull requests
Buy me a donut
This project is open source and always will be, even if I don't get donations. That said, I know there are people out there that may still want to donate just to show their appreciation so this is for you guys. Thanks in advance!
I accept donations through PayPal, BitCoin, Ethereum and LiteCoin. You can use the buttons below to donate through your method of choice
Donate With | QR | Address |
---|---|---|
Donate with PayPal | ||
1E643TNif2MTh75rugepmXuq35Tck4TnE5 | ||
0xF653F666903cd8739030D2721bF01095896F5D6E | ||
LZHvBkaJqKJRa8N7Dyu41Jd1PDBAofCik6 |