Skip to content

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

Closed as not planned

Description

@vnpp

.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

Activity

  1. JounQin commented on Jul 4, 2022

    @JounQin
    Member
  2. vnpp commented on Jul 4, 2022

    @vnpp
    Author

    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

  3. JounQin commented on Jul 4, 2022

    @JounQin
    Member

    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.

  4. vnpp commented on Jul 4, 2022

    @vnpp
    Author

    噢噢噢 thanks

  5. vnpp commented on Jul 4, 2022

    @vnpp
    Author

    hi @JounQin
    The problem still occurs after adding
    image

    image

  6. JounQin commented on Jul 4, 2022

    @JounQin
    Member

    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.

  7. vnpp commented on Jul 4, 2022

    @vnpp
    Author

    npx prettier --write . resolved
    thank you again

  8. JounQin commented on Jul 4, 2022

    @JounQin
    Member

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

  9. pinned this issue on Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions