prettier / eslint-plugin-prettier

ESLint plugin for Prettier formatting
https://npm.im/eslint-plugin-prettier
MIT License
3.31k stars 180 forks source link

Linebreak error when using with `nest new` project #641

Open Serpentarius13 opened 8 months ago

Serpentarius13 commented 8 months ago

What version of eslint are you using?

8.42.0

What version of prettier are you using?

3.0.0

What version of eslint-plugin-prettier are you using?

5.0.0

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    tsconfigRootDir: __dirname,
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin'],
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  rules: {
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    'prettier/prettier': ['error', { endOfLine: 'auto' }],
  },
};
{
  "singleQuote": true,
  "trailingComma": "all",
  "endOfLine": "auto"
}

What source code are you linting?

https://github.com/Serpentarius13/nest-eslint-error.

What did you expect to happen?

Linting for endOfLine choosing should turn itself off when providing such a setting. However (im using Webstorm) even after few reloads, cache clean, npm reinstall with node_modules removal, error still happens to me. Even with all possible fixes I've looked upon, its still happening: image

What actually happened?

Linting for EOL is not turning off and there's red underscores everywhere until I actually lint.

JounQin commented 8 months ago
  1. Can you reproduce it with cli
  2. Did you try to reload vscode or restart vscode-eslint extension
  3. Why you think it's an issue from this plugin instead of vscode-eslint extension
Serpentarius13 commented 8 months ago
  1. Can you reproduce it with cli
  2. Did you try to reload vscode or restart vscode-eslint extension
  3. Why you think it's an issue from this plugin instead of vscode-eslint extension
  1. It happened right after I set up the project
  2. Yes, multiple times
  3. It isnt tied to IDE, the same error happens in WebStorm and Vscode both
JounQin commented 8 months ago
  1. You didnt answer my question

closed accidentally.

Serpentarius13 commented 8 months ago
  1. You didnt answer my question

closed accidentally.

  1. Yes, it is reproducible with nest new command
JounQin commented 8 months ago

What is nest new? Please run eslint cli directly.

Serpentarius13 commented 8 months ago

nest is a cli for Nest.js, a Node framework. I've created a new node project with latest versions of packages and this config:

module.exports = {
    parser: '@typescript-eslint/parser',
    parserOptions: {
      project: 'tsconfig.json',
      tsconfigRootDir: __dirname,
      sourceType: 'module',
    },
    plugins: ['@typescript-eslint/eslint-plugin'],
    extends: [
      'plugin:@typescript-eslint/recommended',
      'plugin:prettier/recommended',
    ],
    root: true,
    env: {
      node: true,
      jest: true,
    },
    ignorePatterns: ['.eslintrc.js'],
    rules: {
      '@typescript-eslint/interface-name-prefix': 'off',
      '@typescript-eslint/explicit-function-return-type': 'off',
      '@typescript-eslint/explicit-module-boundary-types': 'off',
      '@typescript-eslint/no-explicit-any': 'off',
    },
  };

and .prettierrc:

{
    "endOfLine": "auto",
    "singleQuote": true,
    "trailingComma": "all"
}

With it, there's a lot of red trails in my code:

image

But when I set option of endOfLine setting to auto ('prettier/prettier': ['error', {"endOfLine": "auto"}]), I get it still, only on the last line:

image

CLI output:

image

JounQin commented 8 months ago

Don't paste codes here, how to reproduce in your reproduction repo?

Serpentarius13 commented 8 months ago

Don't paste codes here, how to reproduce in your reproduction repo?

Don't you have any errors when you open up the project and install dependencies?

JounQin commented 8 months ago

I need what commands to reproduce before involving.

Serpentarius13 commented 8 months ago

I need what commands to reproduce before involving.

npm i is enough I guess

JounQin commented 8 months ago

eslint. next?

Serpentarius13 commented 8 months ago

eslint. next?

Yep

CarlosRivera4726 commented 6 months ago

nest is a cli for Nest.js, a Node framework. I've created a new node project with latest versions of packages and this config:

module.exports = {
    parser: '@typescript-eslint/parser',
    parserOptions: {
      project: 'tsconfig.json',
      tsconfigRootDir: __dirname,
      sourceType: 'module',
    },
    plugins: ['@typescript-eslint/eslint-plugin'],
    extends: [
      'plugin:@typescript-eslint/recommended',
      'plugin:prettier/recommended',
    ],
    root: true,
    env: {
      node: true,
      jest: true,
    },
    ignorePatterns: ['.eslintrc.js'],
    rules: {
      '@typescript-eslint/interface-name-prefix': 'off',
      '@typescript-eslint/explicit-function-return-type': 'off',
      '@typescript-eslint/explicit-module-boundary-types': 'off',
      '@typescript-eslint/no-explicit-any': 'off',
    },
  };

and .prettierrc:

{
    "endOfLine": "auto",
    "singleQuote": true,
    "trailingComma": "all"
}

With it, there's a lot of red trails in my code:

image

But when I set option of endOfLine setting to auto ('prettier/prettier': ['error', {"endOfLine": "auto"}]), I get it still, only on the last line:

image

CLI output:

image

I solve this issue writing this in my .eslintrc.js file, I paste all code:

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    tsconfigRootDir: __dirname,
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin'],
  extends: [
    'plugin:@typescript-eslint/recommended',
    'plugin:prettier/recommended',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  rules: {
    '@typescript-eslint/interface-name-prefix': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    "prettier/prettier": ["error", {"endOfLine": "auto"}],
  },
};
ratishjain12 commented 2 months ago

this works perfectly