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