2.3.0 • Published 3 years ago

tslint-plugin-prettier v2.3.0

Weekly downloads
172,678
License
MIT
Repository
github
Last release
3 years ago

tslint-plugin-prettier

npm build coverage

Runs Prettier as a TSLint rule and reports differences as individual TSLint issues.

Changelog

Sample

a();;;
    ~~
;;;
~~~ [Delete `;;⏎;;;`]
var foo = ''
          ~~ [Replace `''` with `"";⏎`]
var foo= "";
       ~ [Insert `·`]

Install

# using npm
npm install --save-dev tslint-plugin-prettier prettier

# using yarn
yarn add --dev tslint-plugin-prettier prettier

(require prettier@^1.9.0)

Usage

(tslint.json)

for tslint@^5.2.0

{
  "rulesDirectory": ["tslint-plugin-prettier"],
  "rules": {
    "prettier": true
  }
}

for tslint@^5.0.0

{
  "extends": ["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 and/or .editorconfig if possible, uses Prettier's default option if not found.

    {
      "extends": ["tslint-plugin-prettier"],
      "rules": {
        "prettier": true
      }
    }

    If you don't want to load .editorconfig, disable it in the third argument.

    {
      "extends": ["tslint-plugin-prettier"],
      "rules": {
        "prettier": [true, null, { "editorconfig": false }]
      }
    }
  • If you'd like to specify which config file to use, just put its path (relative to process.cwd()) in the second argument, the following example shows how to load the config file from <cwd>/configs/.prettierrc:

    {
      "extends": ["tslint-plugin-prettier"],
      "rules": {
        "prettier": [true, "configs/.prettierrc"]
      }
    }
  • 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 }]
      }
    }

Ignoring files

  • It will respect your .prettierignore file in your project root ( process.cwd() ) but if you would like to use a different file you can provide it in the third argument, for example:

    {
      "extends": ["tslint-plugin-prettier"],
      "rules": {
        "prettier": [true, null, { "ignorePath": "otherDirectory/.prettierignore" }]
      }
    }

Development

# lint
yarn run lint

# build
yarn run build

# test
yarn run test

Related

License

MIT © Ika

@katalabut/react-scripts@piratuks/lint-code-styletslint-slick@radar/tslint-config@wisekingdom/tslint-config@wx-fc/tslint-config@xobotyi/presetsajustor-phaser-cli-scripts@yandex-lms-ext/tslint-config-base@yiluhub/tslint-config@wynd/tslint-config-wynd@teachers/tslint-config-tptantique-ui@eth-optimism/dev@esyoil-gmbh/config-tslint@dvhb/tslint-config@urbandoor/lint@vermilion/tslint-config@verticalstrategy/tslint-configawesome-code-stylebdd-eliseu@scalio-oss/tslint-config@screamz/aurora@somo/tslint-preset@springworks/tslint-config@socialgouv/tslint-config-recommendedcvmodule-webcodeclimate-tslintedrc-backendeslint-config-akkadugraphql-web-hooklbglisting-cliirstea-typescript-configitalia-tslint-rulesgoodpoint.jsgrpc-exception@straw-hat/cli@trapts/core@trapts/route-decorator@trapts/schedule@tira/tira-deps-dev@tomblcode/cfgmgr-typescript@recore/tslint-config@privacycloud/linter@privacycloud/tslint-config@radarrelay/tslint-config@shoplo/tour-vue@skyrpex/tslint-config-base@symfoni/buidler-react@symfoni/buidler-storageneutrino-preset-bestylednestin-plugin-restfulmonowebjpreact-redux-express-template-emptyseus-scriptsshared-tslint-config-wpicpay-tslint-rules@1stg/tslint-config@advinans/tslint-configtheme-creativeshop@alwaysai/tslint-config@andrevargas/tslint-config-reactwerk85-tslint-rulesvue-starter-servicerecommended-tslint-rulestue-tue-clits-goodeggstslint-config-fishbraintslint-config-gitbooktslint-config-activepipetslint-config-aroundustslint-config-visibacaretslint-config-nineyitslint-config-nokatslint-config-radiosilencetslint-config-crowdrifftslint-config-dawntslint-config-slytrunktslint-config-stoplighttslint-config-suiyobitslint-config-lemontslint-config-levitslint-config-lmltslint-config-macklinureact-coat-dev-pkgreact-bootjs@j.u.p.iter/jupiter-scripts@icelandair/tslint-config@hellroot/tslint-config@jsapp/preset-apollo@jsapp/preset-apollo-ts@ikscodes/tslint-config@kurosame/tslint-config-react@kurosame/tslint-config-vue@limina/tslint-config@lingua-franca/interfaces@lego/tslint-config-prettier@mrmartineau/scripts@nauto/web-apps-archetype@navch/scaffold
3.0.0-beta.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago