|
| 1 | +/** |
| 2 | + * We are using the .JS version of an ESLint config file here so that we can |
| 3 | + * add lots of comments to better explain and document the setup. |
| 4 | + * |
| 5 | + * Source file: |
| 6 | + * @see https://github.com/angular-eslint/angular-eslint/blob/master/packages/integration-tests/fixtures/angular-cli-workspace/.eslintrc.js |
| 7 | + */ |
| 8 | +module.exports = { |
| 9 | + root: true, |
| 10 | + parser: '@typescript-eslint/parser', |
| 11 | + parserOptions: { |
| 12 | + ecmaVersion: 2020, |
| 13 | + sourceType: 'module', |
| 14 | + project: './tsconfig.json', |
| 15 | + }, |
| 16 | + ignorePatterns: [], |
| 17 | + settings: { |
| 18 | + 'import/parsers': { |
| 19 | + '@typescript-eslint/parser': ['.ts', '.tsx'], |
| 20 | + }, |
| 21 | + 'import/resolver': { |
| 22 | + typescript: { |
| 23 | + alwaysTryTypes: true, |
| 24 | + directory: './tsconfig.json', |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + plugins: ['import', '@typescript-eslint', '@angular-eslint'], |
| 29 | + extends: [ |
| 30 | + 'eslint:recommended', |
| 31 | + 'plugin:prettier/recommended', |
| 32 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 33 | + 'plugin:@typescript-eslint/recommended', |
| 34 | + 'prettier', |
| 35 | + 'prettier/@typescript-eslint', |
| 36 | + 'plugin:import/errors', |
| 37 | + 'plugin:import/warnings', |
| 38 | + 'plugin:import/typescript', |
| 39 | + ], |
| 40 | + |
| 41 | + /** |
| 42 | + * TODO: Look up what this actually includes |
| 43 | + */ |
| 44 | + // "extends": "tslint:recommended", |
| 45 | + |
| 46 | + rules: { |
| 47 | + '@typescript-eslint/explicit-member-accessibility': 'off', |
| 48 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 49 | + '@typescript-eslint/no-parameter-properties': 'off', |
| 50 | + '@typescript-eslint/no-explicit-any': 'off', |
| 51 | + '@typescript-eslint/no-use-before-define': ['error', { functions: false }], |
| 52 | + // TODO: Enable deprecation rule once available |
| 53 | + // @see https://github.com/typescript-eslint/typescript-eslint/issues/1223 |
| 54 | + // @see https://github.com/SonarSource/eslint-plugin-sonarjs/issues/150 |
| 55 | + // '@typescript-eslint/deprecation': 'warn', |
| 56 | + 'import/namespace': 0, |
| 57 | + 'import/order': [ |
| 58 | + 'error', |
| 59 | + { |
| 60 | + groups: [ |
| 61 | + ['builtin', 'external'], |
| 62 | + 'internal', |
| 63 | + 'parent', |
| 64 | + 'sibling', |
| 65 | + 'index', |
| 66 | + ], |
| 67 | + alphabetize: { order: 'asc' }, |
| 68 | + 'newlines-between': 'always', |
| 69 | + pathGroups: [{ pattern: 'ngx-testing', group: 'internal' }], |
| 70 | + }, |
| 71 | + ], |
| 72 | + |
| 73 | + // CODELYZER Section Below |
| 74 | + |
| 75 | + // ORIGINAL tslint.json -> "array-type": false, |
| 76 | + '@typescript-eslint/array-type': 'off', |
| 77 | + |
| 78 | + // ORIGINAL tslint.json -> "arrow-parens": false, |
| 79 | + 'arrow-parens': 'off', |
| 80 | + |
| 81 | + // ORIGINAL tslint.json -> "deprecation": { "severity": "warning" }, |
| 82 | + /** |
| 83 | + * | [`deprecation`] | 🌓 | [`import/no-deprecated`] <sup>[1]</sup> | |
| 84 | + * <sup>[1]</sup> Only warns when importing deprecated symbols<br> |
| 85 | + */ |
| 86 | + |
| 87 | + // ORIGINAL tslint.json -> "component-class-suffix": true, |
| 88 | + '@angular-eslint/component-class-suffix': 'error', |
| 89 | + |
| 90 | + // ORIGINAL tslint.json -> "contextual-lifecycle": true, |
| 91 | + '@angular-eslint/contextual-lifecycle': 'error', |
| 92 | + |
| 93 | + // ORIGINAL tslint.json -> "directive-class-suffix": true, |
| 94 | + /** |
| 95 | + * TODO: Not converted yet |
| 96 | + */ |
| 97 | + // '@angular-eslint/directive-class-suffix': 'error' |
| 98 | + |
| 99 | + // ORIGINAL tslint.json -> "directive-selector": [true, "attribute", "app", "camelCase"], |
| 100 | + '@angular-eslint/directive-selector': [ |
| 101 | + 'error', |
| 102 | + { type: 'attribute', prefix: 'ngt', style: 'camelCase' }, |
| 103 | + ], |
| 104 | + |
| 105 | + // ORIGINAL tslint.json -> "component-selector": [true, "element", "app", "kebab-case"], |
| 106 | + '@angular-eslint/component-selector': [ |
| 107 | + 'error', |
| 108 | + { type: 'element', prefix: 'ngt', style: 'kebab-case' }, |
| 109 | + ], |
| 110 | + |
| 111 | + // ORIGINAL tslint.json -> "import-blacklist": [true, "rxjs/Rx"], |
| 112 | + 'no-restricted-imports': [ |
| 113 | + 'error', |
| 114 | + { |
| 115 | + paths: [ |
| 116 | + { |
| 117 | + name: 'rxjs/Rx', |
| 118 | + message: "Please import directly from 'rxjs' instead", |
| 119 | + }, |
| 120 | + ], |
| 121 | + }, |
| 122 | + ], |
| 123 | + |
| 124 | + // ORIGINAL tslint.json -> "interface-name": false, |
| 125 | + '@typescript-eslint/interface-name-prefix': 'off', |
| 126 | + |
| 127 | + // ORIGINAL tslint.json -> "max-classes-per-file": false, |
| 128 | + 'max-classes-per-file': 'off', |
| 129 | + |
| 130 | + // ORIGINAL tslint.json -> "max-line-length": [true, 140], |
| 131 | + 'max-len': ['error', { code: 140 }], |
| 132 | + |
| 133 | + // ORIGINAL tslint.json -> "member-access": false, |
| 134 | + '@typescript-eslint/explicit-member-accessibility': 'off', |
| 135 | + |
| 136 | + // ORIGINAL tslint.json -> "member-ordering": [true, { "order": ["static-field", "instance-field", "static-method", "instance-method"] } ], |
| 137 | + '@typescript-eslint/member-ordering': [ |
| 138 | + 'error', |
| 139 | + { |
| 140 | + default: [ |
| 141 | + 'static-field', |
| 142 | + 'instance-field', |
| 143 | + 'static-method', |
| 144 | + 'instance-method', |
| 145 | + ], |
| 146 | + }, |
| 147 | + ], |
| 148 | + |
| 149 | + // ORIGINAL tslint.json -> "no-consecutive-blank-lines": false, |
| 150 | + 'no-multiple-empty-lines': 'error', |
| 151 | + |
| 152 | + // ORIGINAL tslint.json -> "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], |
| 153 | + 'no-restricted-syntax': [ |
| 154 | + 'error', |
| 155 | + { |
| 156 | + selector: |
| 157 | + 'CallExpression[callee.object.name="console"][callee.property.name=/^(debug|info|time|timeEnd|trace)$/]', |
| 158 | + message: 'Unexpected property on console object was called', |
| 159 | + }, |
| 160 | + ], |
| 161 | + |
| 162 | + // ORIGINAL tslint.json -> "no-empty": false, |
| 163 | + 'no-empty': 'off', |
| 164 | + |
| 165 | + // ORIGINAL tslint.json -> "no-inferrable-types": [true, "ignore-params"], |
| 166 | + '@typescript-eslint/no-inferrable-types': [ |
| 167 | + 'error', |
| 168 | + { |
| 169 | + ignoreParameters: true, |
| 170 | + }, |
| 171 | + ], |
| 172 | + |
| 173 | + // ORIGINAL tslint.json -> "no-non-null-assertion": true, |
| 174 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 175 | + |
| 176 | + // ORIGINAL tslint.json -> "no-redundant-jsdoc": true, |
| 177 | + /** |
| 178 | + * | [`no-redundant-jsdoc`] | 🛑 | N/A ([open issue](https://github.com/gajus/eslint-plugin-jsdoc/issues/134)) | |
| 179 | + */ |
| 180 | + |
| 181 | + // ORIGINAL tslint.json -> "no-switch-case-fall-through": true, |
| 182 | + 'no-fallthrough': 'error', |
| 183 | + |
| 184 | + // ORIGINAL tslint.json -> "no-var-requires": false, |
| 185 | + '@typescript-eslint/no-var-requires': 'off', |
| 186 | + |
| 187 | + // ORIGINAL tslint.json -> "object-literal-key-quotes": [true, "as-needed"], |
| 188 | + 'quote-props': ['error', 'as-needed'], |
| 189 | + |
| 190 | + // ORIGINAL tslint.json -> "object-literal-sort-keys": false, |
| 191 | + 'sort-keys': 'off', |
| 192 | + |
| 193 | + // ORIGINAL tslint.json -> "ordered-imports": false, |
| 194 | + /** |
| 195 | + * Needs import plugin |
| 196 | + */ |
| 197 | + |
| 198 | + // ORIGINAL tslint.json -> "quotemark": [true, "single"], |
| 199 | + // quotes: [ |
| 200 | + // 'error', |
| 201 | + // 'single', |
| 202 | + // { avoidEscape: true, allowTemplateLiterals: true }, |
| 203 | + // ], |
| 204 | + |
| 205 | + // ORIGINAL tslint.json -> "trailing-comma": false, |
| 206 | + 'comma-dangle': 'off', |
| 207 | + |
| 208 | + // ORIGINAL tslint.json -> "no-conflicting-lifecycle": true, |
| 209 | + // FIXME: Error - Definition for rule '@angular-eslint/no-conflicting-lifecycle' was not found |
| 210 | + // '@angular-eslint/no-conflicting-lifecycle': 'error', |
| 211 | + |
| 212 | + // ORIGINAL tslint.json -> "no-host-metadata-property": true, |
| 213 | + '@angular-eslint/no-host-metadata-property': 'error', |
| 214 | + |
| 215 | + // ORIGINAL tslint.json -> "no-input-rename": true, |
| 216 | + /** |
| 217 | + * TODO: Not converted yet |
| 218 | + */ |
| 219 | + // '@angular-eslint/no-input-rename': 'error', |
| 220 | + |
| 221 | + // ORIGINAL tslint.json -> "no-inputs-metadata-property": true, |
| 222 | + '@angular-eslint/no-inputs-metadata-property': 'error', |
| 223 | + |
| 224 | + // ORIGINAL tslint.json -> "no-output-native": true, |
| 225 | + '@angular-eslint/no-output-native': 'error', |
| 226 | + |
| 227 | + // ORIGINAL tslint.json -> "no-output-on-prefix": true, |
| 228 | + '@angular-eslint/no-output-on-prefix': 'error', |
| 229 | + |
| 230 | + // ORIGINAL tslint.json -> "no-output-rename": true, |
| 231 | + '@angular-eslint/no-output-rename': 'error', |
| 232 | + |
| 233 | + // ORIGINAL tslint.json -> "no-outputs-metadata-property": true, |
| 234 | + '@angular-eslint/no-outputs-metadata-property': 'error', |
| 235 | + |
| 236 | + // ORIGINAL tslint.json -> "template-banana-in-box": true, |
| 237 | + // APPLIED VIA TEMPLATE-RELATED CONFIG BELOW |
| 238 | + |
| 239 | + // ORIGINAL tslint.json -> "template-no-negated-async": true, |
| 240 | + /** |
| 241 | + * TODO: Not converted yet |
| 242 | + */ |
| 243 | + |
| 244 | + // ORIGINAL tslint.json -> "use-lifecycle-interface": true, |
| 245 | + '@angular-eslint/use-lifecycle-interface': 'error', |
| 246 | + |
| 247 | + // ORIGINAL tslint.json -> "use-pipe-transform-interface": true |
| 248 | + '@angular-eslint/use-pipe-transform-interface': 'error', |
| 249 | + }, |
| 250 | + overrides: [ |
| 251 | + { |
| 252 | + files: ['*.component.html'], |
| 253 | + parser: '@angular-eslint/template-parser', |
| 254 | + plugins: ['@angular-eslint/template'], |
| 255 | + rules: { |
| 256 | + // '@angular-eslint/template/banana-in-a-box': 'error', |
| 257 | + }, |
| 258 | + }, |
| 259 | + ], |
| 260 | +}; |
0 commit comments