Last active
August 2, 2022 12:15
-
-
Save LukeSamkharadze/ffe04d148980d8be9d10c29a1cc1d1de to your computer and use it in GitHub Desktop.
ESLint for Angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
env: { | |
node: true, | |
browser: true, | |
es2021: true, | |
}, | |
extends: ['plugin:prettier/recommended'], | |
rules: { | |
'prettier/prettier': 'warn', | |
}, | |
parserOptions: { | |
sourceType: 'module', | |
}, | |
overrides: [ | |
{ | |
files: '*.ts', | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
project: 'tsconfig.json', | |
createDefaultProgram: true, | |
}, | |
extends: [ | |
'airbnb-typescript/base', | |
'eslint:recommended', | |
'plugin:@typescript-eslint/eslint-recommended', | |
'plugin:@typescript-eslint/recommended', | |
'plugin:@typescript-eslint/recommended-requiring-type-checking', | |
'plugin:@angular-eslint/recommended', | |
'plugin:@angular-eslint/recommended--extra', | |
'plugin:prettier/recommended', | |
], | |
rules: { | |
'no-plusplus': 'off', | |
'no-underscore-dangle': 'off', | |
'import/prefer-default-export': 'off', | |
'import/order': 'warn', | |
'prettier/prettier': 'warn', | |
'@typescript-eslint/lines-between-class-members': 'warn', | |
'@typescript-eslint/no-use-before-define': 'off', // <-- We use forwardRef in Angular | |
'@angular-eslint/sort-ngmodule-metadata-arrays': 'warn', | |
'@angular-eslint/component-selector': [ | |
'warn', | |
{ | |
type: 'element', | |
prefix: 'app', | |
style: 'kebab-case', | |
}, | |
], | |
'@angular-eslint/directive-selector': [ | |
'warn', | |
{ | |
type: 'attribute', | |
prefix: 'app', | |
style: 'camelCase', | |
}, | |
], | |
}, | |
overrides: [ | |
{ | |
files: '*spec.ts', | |
rules: { | |
'import/no-extraneous-dependencies': 'off', // <-- So we dont get warnings about dev dependencies used in spec files | |
'@typescript-eslint/no-floating-promises': 'off', // <-- Heavily used in spec files | |
}, | |
}, | |
], | |
}, | |
{ | |
files: ['*.html'], | |
extends: ['plugin:@angular-eslint/template/recommended'], | |
}, | |
{ | |
files: ['*.html'], | |
excludedFiles: ['*inline-template-*.component.html'], | |
extends: ['plugin:prettier/recommended'], | |
rules: { | |
'prettier/prettier': [ | |
'warn', | |
{ | |
parser: 'angular', | |
}, | |
], | |
}, | |
}, | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Angular-ESLint
This is intended to be used with
ng add @angular-eslint/schematics
, but you can still use it withoutCLI
Packages used: