tslint-plugin-prettier
Runs Prettier as a TSLint rule and reports differences as individual TSLint issues.
NOTE: This project uses official reporter from eslint-plugin-prettier.
Changelog
Sample
a();;;
~~
;;;
~~~ [Delete `;;⏎;;;`]
var foo = ''
~~ [Replace `''` with `"";⏎`]
var foo= "";
~ [Insert `·`]
Install
npm install --save-dev tslint-plugin-prettier prettier
yarn add --dev tslint-plugin-prettier prettier
Usage
(tslint.json)
for tslint@5.0.0+
{
"extends": ["tslint-plugin-prettier"],
"rules": {
"prettier": true
}
}
for tslint@5.2.0+
{
"rulesDirectory": ["tslint-plugin-prettier"],
"rules": {
"prettier": true
}
}
NOTE: To use this plugin, it'd better to also use tslint-config-prettier to disable all prettier-related rules, so as to avoid conflicts between existed rules.
Options
If there is no option provided, it'll try to load config file if possible (require prettier@1.7.0+
), uses Prettier's default option if not found.
{
"extends": ["tslint-plugin-prettier"],
"rules": {
"prettier": true
}
}
If you'd like to specify where to find the config file, just put the search path (relative to process.cwd()
) in the second argument, the following example shows how to use the config file from <cwd>/configs/.prettierrc
:
{
"extends": ["tslint-plugin-prettier"],
"rules": {
"prettier": [true, "configs"]
}
}
If you'd like to specify options manually, just put Prettier Options in the second argument, for example:
{
"extends": ["tslint-plugin-prettier"],
"rules": {
"prettier": [true, { "singleQuote": true }]
}
}
Development
yarn run lint
yarn run build
yarn run test
Related
License
MIT © Ika