Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using prettier-tslint together with prettier-eslint produces unexpected results #787

Closed
karol-majewski opened this issue Apr 7, 2019 · 3 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@karol-majewski
Copy link
Contributor

Hello and thank you for your work. I've noticed some unexpected behavior and I was wondering whether it was intentional or not.

In my project, ESLint is used to lint both JavaScript and TypeScript code.

Configuration

.eslintrc.js
module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'module'
  },
  plugins: ['@typescript-eslint'],
  rules: {
    quotes: [2, 'single', { avoidEscape: true }]
  }
};
.prettierrc
{
  "trailingComma": "all",
  "printWidth": 100,
  "tabWidth": 2
}
~/Library/Application Support/Code/User/settings.json
    ...
    "prettier.stylelintIntegration": true,
    "prettier.requireConfig": true,
    "prettier.tslintIntegration": true,
    "prettier.eslintIntegration": true,
    ...

Important: as you can see, I have both tslintIntegration and eslintIntegrationenabled in my global Visual Studio Code settings.

Problem

When I run the extension (either manually or by saving the file), all my single quotes are converted into double quotes, despite the ESLint config stating otherwise.

When I disable "prettier.tslintIntegration", the extension works as expected.

Question

My understanding is:

  1. prettier-tslint is prioritized over prettier-eslint.
  2. Since there is no tslint.json file present in the repository, prettier-tslint looks for .prettierrc.
  3. It finds .prettierrc, but because it doesn't override the default setting for singleQuote (which is false ≡ use double quotes), the default setting is used.

Is that intended? It was a bit problematic for me to find out about it. I had both integrations enabled in my global settings, and in this specific project, the extension started to behave in a weird way.

If it is intended indeed than perhaps it would be a good idea to make it explicit in the README (which I can do).

Please let me know what you think.

@CiGit
Copy link
Member

CiGit commented Apr 25, 2019

TSLint is prioritized for ts files. PR welcome :-)

CiGit pushed a commit that referenced this issue Apr 25, 2019
* Explain how to lint TypeScript code with ESLint

Solves #787

* Add the CHANGELOG entry
@ntotten
Copy link
Member

ntotten commented Aug 24, 2019

Due to the huge amount of bugs, linting support has been deprecated in version 2.0.0. See the documentation on the recommended configuration: https://github.com/prettier/prettier-vscode#vscode-eslint-and-tslint-integration

See #870 for more details.

@ntotten ntotten closed this as completed Aug 24, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants