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

Angular: According to the configuration html will report an error #494

Closed
vnpp opened this issue Jul 4, 2022 · 8 comments
Closed

Angular: According to the configuration html will report an error #494

vnpp opened this issue Jul 4, 2022 · 8 comments

Comments

@vnpp
Copy link

vnpp commented Jul 4, 2022

.eslintrc.js

module.exports = {
  root: true,
  ignorePatterns: ['projects/**/*'],
  overrides: [
    {
      files: ['*.ts'],
      parserOptions: {
        project: ['tsconfig.json'],
        createDefaultProgram: true,
      },
      extends: [
        'plugin:@angular-eslint/recommended',
        'plugin:@angular-eslint/template/process-inline-templates',
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended',
      ],
      rules: {
        '@angular-eslint/directive-selector': [
          'error',
          {
            type: 'attribute',
            style: 'camelCase',
          },
        ],
        '@angular-eslint/component-selector': [
          'error',
          {
            type: 'element',
            prefix: '',
            style: 'kebab-case',
          },
        ],
        '@angular-eslint/no-input-rename': 'off',
        '@angular-eslint/no-empty-lifecycle': 'off',
        '@angular-eslint/no-empty-lifecycle-method': 'off',
        '@angular-eslint/directive-class-suffix': 'off',
        '@angular-eslint/component-class-suffix': 'off',
        '@angular-eslint/no-host-metadata-property': 'off',
        '@angular-eslint/no-output-on-prefix': 'off',
        '@angular-eslint/template/no-negated-async': 'off',
        '@angular-eslint/use-lifecycle-interface': 'off',
        '@angular-eslint/no-output-rename': 'off',
        '@angular-eslint/no-output-native': 'off',
        '@typescript-eslint/ban-ts-comment': 'off',
        '@typescript-eslint/no-explicit-any': 'off',
        '@typescript-eslint/no-empty-function': ['off' /*{ allow: ['constructors', 'arrowFunctions'] }*/],
        '@typescript-eslint/no-non-null-assertion': 'off',
        '@typescript-eslint/no-unused-vars': 'error',
      },
    },
    // NOTE: WE ARE NOT APPLYING PRETTIER IN THIS OVERRIDE, ONLY @ANGULAR-ESLINT/TEMPLATE
    {
      "files": ["*.html"],
      "extends": ["plugin:@angular-eslint/template/recommended"],
      "rules": {}
    },
    // NOTE: WE ARE NOT APPLYING @ANGULAR-ESLINT/TEMPLATE IN THIS OVERRIDE, ONLY PRETTIER
    {
      "files": ["*.html"],
      // "excludedFiles": ["*inline-template-*.component.html"],
      "extends": ["plugin:prettier/recommended"],
      "rules": {
        // NOTE: WE ARE OVERRIDING THE DEFAULT CONFIG TO ALWAYS SET THE PARSER TO ANGULAR (SEE BELOW)
        "prettier/prettier": ["error", { "parser": "angular" }]
      }
    }
  ],
};

image

image

vscode extends: eslint plugin use default config

@JounQin
Copy link
Member

JounQin commented Jul 4, 2022

@JounQin JounQin closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2022
@vnpp
Copy link
Author

vnpp commented Jul 4, 2022

Same thing happened when I tried using the provided config
image
image

resolved:
Add to endOfLine: 'auto'

image
image

why-do-i-keep-getting-delete-cr-prettier-prettier

@JounQin
Copy link
Member

JounQin commented Jul 4, 2022

It seems you're missing a .editorconfig with correct config, for example end_of_line = lf.

Take https://github.com/prettier/eslint-plugin-prettier/blob/master/.editorconfig as an example.

And you didn't follow angular-eslint/angular-eslint#1071 at all.

@vnpp
Copy link
Author

vnpp commented Jul 4, 2022

噢噢噢 thanks

@vnpp
Copy link
Author

vnpp commented Jul 4, 2022

hi @JounQin
The problem still occurs after adding
image

image

@JounQin
Copy link
Member

JounQin commented Jul 4, 2022

Reload VScode first, if it still occurs, that means you were using different end_of_line previously, so run prettier --write . on all files once would fix this.

@vnpp
Copy link
Author

vnpp commented Jul 4, 2022

npx prettier --write . resolved
thank you again

@JounQin
Copy link
Member

JounQin commented Jul 4, 2022

You'd better to have a .gitattributes with * text=auto eol=lf for git at the same time.

@JounQin JounQin pinned this issue Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants