|
| 1 | +// @ts-check |
| 2 | +// Allows us to bring in the recommended core rules from eslint itself |
| 3 | +const eslint = require('@eslint/js'); |
| 4 | +// Allows us to use the typed utility for our config, and to bring in the recommended rules for TypeScript projects from typescript-eslint |
| 5 | +const tsEslint = require('typescript-eslint'); |
| 6 | +// Allows us to bring in the recommended rules for Angular projects from angular-eslint |
| 7 | +const angular = require('angular-eslint'); |
| 8 | + |
| 9 | +// Export our config array, which is composed together thanks to the typed utility function from typescript-eslint |
| 10 | +module.exports = tsEslint.config( |
| 11 | + { |
| 12 | + // Everything in this config object targets our TypeScript files (Components, Directives, Pipes etc) |
| 13 | + files: [ '**/*.ts' ], |
| 14 | + extends: [ |
| 15 | + // Apply the recommended core rules |
| 16 | + eslint.configs.recommended, |
| 17 | + // Apply the recommended TypeScript rules |
| 18 | + ...tsEslint.configs.recommended, |
| 19 | + // Optionally apply stylistic rules from typescript-eslint that improve code consistency |
| 20 | + ...tsEslint.configs.stylistic, |
| 21 | + // Apply the recommended Angular rules |
| 22 | + ...angular.configs.tsRecommended |
| 23 | + ], |
| 24 | + // Set the custom processor which will allow us to have our inline Component templates extracted |
| 25 | + // and treated as if they are HTML files (and therefore have the .html config below applied to them) |
| 26 | + processor: angular.processInlineTemplates, |
| 27 | + // Override specific rules for TypeScript files (these will take priority over the extended configs above) |
| 28 | + rules: { |
| 29 | + '@angular-eslint/directive-selector': [ |
| 30 | + 'error', |
| 31 | + { |
| 32 | + type: 'attribute', |
| 33 | + prefix: 'ngx', |
| 34 | + style: 'camelCase', |
| 35 | + } |
| 36 | + ], |
| 37 | + '@angular-eslint/component-selector': [ |
| 38 | + 'error', |
| 39 | + { |
| 40 | + type: 'element', |
| 41 | + prefix: 'ngx', |
| 42 | + style: 'kebab-case', |
| 43 | + } |
| 44 | + ] |
| 45 | + } |
| 46 | + }, |
| 47 | + { |
| 48 | + files: [ '**/*.spec.ts' ], |
| 49 | + rules: { |
| 50 | + '@typescript-eslint/no-explicit-any': 'off' |
| 51 | + } |
| 52 | + }, |
| 53 | + { |
| 54 | + files: [ 'projects/ngx-multiple-dates-app/**/*.ts' ], |
| 55 | + rules: { |
| 56 | + '@angular-eslint/directive-selector': [ |
| 57 | + 'error', |
| 58 | + { |
| 59 | + type: 'attribute', |
| 60 | + prefix: 'app', |
| 61 | + style: 'camelCase', |
| 62 | + } |
| 63 | + ], |
| 64 | + '@angular-eslint/component-selector': [ |
| 65 | + 'error', |
| 66 | + { |
| 67 | + type: 'element', |
| 68 | + prefix: 'app', |
| 69 | + style: 'kebab-case', |
| 70 | + } |
| 71 | + ] |
| 72 | + } |
| 73 | + }, |
| 74 | + { |
| 75 | + // Everything in this config object targets our HTML files (external templates, |
| 76 | + // and inline templates as long as we have the `processor` set on our TypeScript config above) |
| 77 | + files: [ '**/*.html' ], |
| 78 | + extends: [ |
| 79 | + // Apply the recommended Angular template rules |
| 80 | + ...angular.configs.templateRecommended, |
| 81 | + // Apply the Angular template rules which focus on accessibility of our apps |
| 82 | + ...angular.configs.templateAccessibility |
| 83 | + ], |
| 84 | + rules: { } |
| 85 | + } |
| 86 | +); |
0 commit comments