forked from EVOgeek/Vmeda.Online
		
	MOBILE-3303 lint: Migrate tslint to eslint
This commit is contained in:
		
							parent
							
								
									617d4764e8
								
							
						
					
					
						commit
						e1c37437a2
					
				
							
								
								
									
										216
									
								
								.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										216
									
								
								.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,216 @@ | ||||
| module.exports = { | ||||
|     root: true, | ||||
|     overrides: [ | ||||
|         { | ||||
|             files: ['*.ts'], | ||||
|             env: { | ||||
|                 browser: true, | ||||
|                 es6: true, | ||||
|                 node: true, | ||||
|             }, | ||||
|             extends: [ | ||||
|                 'eslint:recommended', | ||||
|                 'plugin:@typescript-eslint/recommended', | ||||
|                 'prettier', | ||||
|                 'prettier/@typescript-eslint', | ||||
|                 'plugin:jest/recommended', | ||||
|                 'plugin:@angular-eslint/recommended', | ||||
|             ], | ||||
|             parser: '@typescript-eslint/parser', | ||||
|             parserOptions: { | ||||
|                 project: 'tsconfig.json', | ||||
|                 sourceType: 'module', | ||||
|             }, | ||||
|             plugins: [ | ||||
|                 'eslint-plugin-prefer-arrow', | ||||
|                 'eslint-plugin-jsdoc', | ||||
|                 '@typescript-eslint', | ||||
|                 'header', | ||||
|                 'jest', | ||||
|             ], | ||||
|             rules: { | ||||
|                 '@angular-eslint/component-class-suffix': ['error', { suffixes: ['Component', 'Page'] }], | ||||
|                 '@typescript-eslint/adjacent-overload-signatures': 'error', | ||||
|                 '@typescript-eslint/ban-types': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         types: { | ||||
|                             Boolean: { | ||||
|                                 message: 'Use \'boolean\' instead.', | ||||
|                             }, | ||||
|                             Number: { | ||||
|                                 message: 'Use \'number\' instead.', | ||||
|                             }, | ||||
|                             String: { | ||||
|                                 message: 'Use \'string\' instead.', | ||||
|                             }, | ||||
|                             Object: { | ||||
|                                 message: 'Use {} instead.', | ||||
|                             }, | ||||
|                         }, | ||||
|                     }, | ||||
|                 ], | ||||
|                 '@typescript-eslint/explicit-member-accessibility': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         accessibility: 'no-public', | ||||
|                     }, | ||||
|                 ], | ||||
|                 '@typescript-eslint/indent': 'error', | ||||
|                 '@typescript-eslint/member-delimiter-style': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         multiline: { | ||||
|                             delimiter: 'semi', | ||||
|                             requireLast: true, | ||||
|                         }, | ||||
|                         singleline: { | ||||
|                             delimiter: 'semi', | ||||
|                             requireLast: false, | ||||
|                         }, | ||||
|                     }, | ||||
|                 ], | ||||
|                 '@typescript-eslint/member-ordering': 'error', | ||||
|                 '@typescript-eslint/naming-convention': 'error', | ||||
|                 '@typescript-eslint/no-empty-function': 'error', | ||||
|                 '@typescript-eslint/no-empty-interface': 'error', | ||||
|                 '@typescript-eslint/no-inferrable-types': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         ignoreParameters: true, | ||||
|                     }, | ||||
|                 ], | ||||
|                 '@typescript-eslint/no-non-null-assertion': 'error', | ||||
|                 '@typescript-eslint/no-this-alias': 'error', | ||||
|                 '@typescript-eslint/no-unused-vars': 'error', | ||||
|                 '@typescript-eslint/quotes': [ | ||||
|                     'error', | ||||
|                     'single', | ||||
|                 ], | ||||
|                 '@typescript-eslint/semi': [ | ||||
|                     'error', | ||||
|                     'always', | ||||
|                 ], | ||||
|                 '@typescript-eslint/type-annotation-spacing': 'error', | ||||
|                 '@typescript-eslint/unified-signatures': 'error', | ||||
|                 'header/header': [ | ||||
|                     2, | ||||
|                     'line', | ||||
|                     [ | ||||
|                         ' (C) Copyright 2015 Moodle Pty Ltd.', | ||||
|                         '', | ||||
|                         ' Licensed under the Apache License, Version 2.0 (the "License");', | ||||
|                         ' you may not use this file except in compliance with the License.', | ||||
|                         ' You may obtain a copy of the License at', | ||||
|                         '', | ||||
|                         '     http://www.apache.org/licenses/LICENSE-2.0', | ||||
|                         '', | ||||
|                         ' Unless required by applicable law or agreed to in writing, software', | ||||
|                         ' distributed under the License is distributed on an "AS IS" BASIS,', | ||||
|                         ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.', | ||||
|                         ' See the License for the specific language governing permissions and', | ||||
|                         ' limitations under the License.', | ||||
|                     ], | ||||
|                     1, | ||||
|                 ], | ||||
|                 'one-var': ['error', 'never'], | ||||
|                 'comma-dangle': ['error', 'always-multiline'], | ||||
|                 'capitalized-comments': [ | ||||
|                     'error', | ||||
|                     'always', | ||||
|                     { | ||||
|                         ignoreConsecutiveComments: true, | ||||
|                     }, | ||||
|                 ], | ||||
|                 'constructor-super': 'error', | ||||
|                 'curly': 'error', | ||||
|                 'default-case': 'error', | ||||
|                 'eol-last': 'error', | ||||
|                 'id-blacklist': [ | ||||
|                     'error', | ||||
|                     'any', | ||||
|                     'Number', | ||||
|                     'number', | ||||
|                     'String', | ||||
|                     'string', | ||||
|                     'Boolean', | ||||
|                     'boolean', | ||||
|                     'Undefined', | ||||
|                     'undefined', | ||||
|                 ], | ||||
|                 'id-match': 'error', | ||||
|                 'jsdoc/check-alignment': 'error', | ||||
|                 'jsdoc/check-indentation': 'error', | ||||
|                 'jsdoc/newline-after-description': 'error', | ||||
|                 'linebreak-style': [ | ||||
|                     'error', | ||||
|                     'unix', | ||||
|                 ], | ||||
|                 'max-len': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         code: 132, | ||||
|                     }, | ||||
|                 ], | ||||
|                 'new-parens': 'error', | ||||
|                 'no-bitwise': 'error', | ||||
|                 'no-cond-assign': 'error', | ||||
|                 'no-console': 'error', | ||||
|                 'no-debugger': 'error', | ||||
|                 'no-duplicate-case': 'error', | ||||
|                 'no-duplicate-imports': 'error', | ||||
|                 'no-empty': 'error', | ||||
|                 'no-eval': 'error', | ||||
|                 'no-invalid-this': 'error', | ||||
|                 'no-irregular-whitespace': 'error', | ||||
|                 'no-multiple-empty-lines': 'error', | ||||
|                 'no-new-wrappers': 'error', | ||||
|                 'no-redeclare': 'error', | ||||
|                 'no-sequences': 'error', | ||||
|                 'no-trailing-spaces': 'error', | ||||
|                 'no-underscore-dangle': 'error', | ||||
|                 'no-unused-labels': 'error', | ||||
|                 'no-var': 'error', | ||||
|                 'padding-line-between-statements': [ | ||||
|                     'error', | ||||
|                     { | ||||
|                         blankLine: 'always', | ||||
|                         prev: '*', | ||||
|                         next: 'return', | ||||
|                     }, | ||||
|                 ], | ||||
|                 'prefer-arrow/prefer-arrow-functions': [ | ||||
|                     'error', | ||||
|                     { allowStandaloneDeclarations: true }, | ||||
|                 ], | ||||
|                 'prefer-const': 'error', | ||||
|                 'quote-props': [ | ||||
|                     'error', | ||||
|                     'consistent-as-needed', | ||||
|                 ], | ||||
|                 'spaced-comment': [ | ||||
|                     'error', | ||||
|                     'always', | ||||
|                     { | ||||
|                         markers: [ | ||||
|                             '/', | ||||
|                         ], | ||||
|                     }, | ||||
|                 ], | ||||
|                 'use-isnan': 'error', | ||||
|                 'yoda': 'error', | ||||
|             }, | ||||
|         }, | ||||
|         { | ||||
|             files: ['*.html'], | ||||
|             extends: ['plugin:@angular-eslint/template/recommended'], | ||||
|             rules: { | ||||
|                 'max-len': ['error', { code: 140 }], | ||||
|             }, | ||||
|         }, | ||||
|         { | ||||
|             files: ['*.component.ts'], | ||||
|             extends: ['plugin:@angular-eslint/template/process-inline-templates'], | ||||
|         }, | ||||
|     ], | ||||
| }; | ||||
| @ -2,4 +2,5 @@ language: node_js | ||||
| node_js: 12 | ||||
| cache: npm | ||||
| script: | ||||
|   - npm run lint | ||||
|   - npm run test:ci | ||||
|  | ||||
							
								
								
									
										12
									
								
								angular.json
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								angular.json
									
									
									
									
									
								
							| @ -95,14 +95,12 @@ | ||||
|           } | ||||
|         }, | ||||
|         "lint": { | ||||
|           "builder": "@angular-devkit/build-angular:tslint", | ||||
|           "builder": "@angular-eslint/builder:lint", | ||||
|           "options": { | ||||
|             "tsConfig": [ | ||||
|               "tsconfig.app.json", | ||||
|               "tsconfig.spec.json", | ||||
|               "e2e/tsconfig.json" | ||||
|             ], | ||||
|             "exclude": ["**/node_modules/**"] | ||||
|             "lintFilePatterns": [ | ||||
|             "src/**/*.ts", | ||||
|             "src/app/**/*.html" | ||||
|             ] | ||||
|           } | ||||
|         }, | ||||
|         "ionic-cordova-build": { | ||||
|  | ||||
							
								
								
									
										6626
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6626
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								package.json
									
									
									
									
									
								
							| @ -109,6 +109,11 @@ | ||||
|   "devDependencies": { | ||||
|     "@angular-builders/custom-webpack": "^10.0.1", | ||||
|     "@angular-devkit/build-angular": "~0.1000.0", | ||||
|     "@angular-eslint/builder": "0.5.0-beta.2", | ||||
|     "@angular-eslint/eslint-plugin": "0.5.0-beta.2", | ||||
|     "@angular-eslint/eslint-plugin-template": "0.5.0-beta.2", | ||||
|     "@angular-eslint/schematics": "^0.5.0-beta.2", | ||||
|     "@angular-eslint/template-parser": "0.5.0-beta.2", | ||||
|     "@angular/cli": "~10.0.5", | ||||
|     "@angular/compiler": "~10.0.0", | ||||
|     "@angular/compiler-cli": "~10.0.0", | ||||
| @ -116,11 +121,19 @@ | ||||
|     "@ionic/angular-toolkit": "^2.3.0", | ||||
|     "@types/node": "^12.12.64", | ||||
|     "codelyzer": "^6.0.0", | ||||
|     "@typescript-eslint/eslint-plugin": "4.3.0", | ||||
|     "@typescript-eslint/parser": "4.3.0", | ||||
|     "eslint": "^7.6.0", | ||||
|     "eslint-config-prettier": "^6.12.0", | ||||
|     "eslint-plugin-header": "^3.1.0", | ||||
|     "eslint-plugin-import": "^2.22.1", | ||||
|     "eslint-plugin-jest": "^24.1.0", | ||||
|     "eslint-plugin-jsdoc": "^30.6.3", | ||||
|     "eslint-plugin-prefer-arrow": "^1.2.2", | ||||
|     "jest": "^26.5.0", | ||||
|     "jest-preset-angular": "^8.3.1", | ||||
|     "ts-jest": "^26.4.1", | ||||
|     "ts-node": "~8.3.0", | ||||
|     "tslint": "~6.1.0", | ||||
|     "typescript": "~3.9.5" | ||||
|   }, | ||||
|   "engines": { | ||||
|  | ||||
| @ -17,8 +17,6 @@ import { Component } from '@angular/core'; | ||||
| @Component({ | ||||
|     selector: 'app-root', | ||||
|     templateUrl: 'app.component.html', | ||||
|     styleUrls: ['app.component.scss'] | ||||
|     styleUrls: ['app.component.scss'], | ||||
| }) | ||||
| export class AppComponent { | ||||
|     constructor() { } | ||||
| } | ||||
| export class AppComponent { } | ||||
|  | ||||
| @ -96,9 +96,7 @@ import { setSingletonsInjector } from '@singletons/core.singletons'; | ||||
|     bootstrap: [AppComponent], | ||||
| }) | ||||
| export class AppModule { | ||||
|     constructor(injector: Injector, | ||||
|             platform: Platform, | ||||
|             ) { | ||||
|     constructor(injector: Injector, platform: Platform) { | ||||
| 
 | ||||
|         // Set the injector.
 | ||||
|         setSingletonsInjector(injector); | ||||
|  | ||||
| @ -22,5 +22,9 @@ if (environment.production) { | ||||
|     enableProdMode(); | ||||
| } | ||||
| 
 | ||||
| platformBrowserDynamic().bootstrapModule(AppModule) | ||||
|   .catch(err => console.log(err)); | ||||
| platformBrowserDynamic() | ||||
|     .bootstrapModule(AppModule) | ||||
|     .catch(err => { | ||||
|         // eslint-disable-next-line no-console
 | ||||
|         console.log(err); | ||||
|     }); | ||||
|  | ||||
| @ -13,68 +13,11 @@ | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| /** | ||||
|  * This file includes polyfills needed by Angular and is loaded before the app. | ||||
|  * You can add your own extra polyfills to this file. | ||||
|  * | ||||
|  * This file is divided into 2 sections: | ||||
|  *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. | ||||
|  *   2. Application imports. Files imported after ZoneJS that should be loaded before your main | ||||
|  *      file. | ||||
|  * | ||||
|  * The current setup is for so-called "evergreen" browsers; the last versions of browsers that | ||||
|  * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), | ||||
|  * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. | ||||
|  * | ||||
|  * Learn more in https://angular.io/guide/browser-support
 | ||||
|  */ | ||||
| 
 | ||||
| /*************************************************************************************************** | ||||
|  * BROWSER POLYFILLS | ||||
|  */ | ||||
| 
 | ||||
| /** IE10 and IE11 requires the following for NgClass support on SVG elements */ | ||||
| // import 'classlist.js';  // Run `npm install --save classlist.js`.
 | ||||
| 
 | ||||
| /** | ||||
|  * Web Animations `@angular/platform-browser/animations` | ||||
|  * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. | ||||
|  * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). | ||||
|  */ | ||||
| // import 'web-animations-js';  // Run `npm install --save web-animations-js`.
 | ||||
| 
 | ||||
| /** | ||||
|  * By default, zone.js will patch all possible macroTask and DomEvents | ||||
|  * user can disable parts of macroTask/DomEvents patch by setting following flags | ||||
|  * because those flags need to be set before `zone.js` being loaded, and webpack | ||||
|  * will put import in the top of bundle, so user need to create a separate file | ||||
|  * in this directory (for example: zone-flags.ts), and put the following flags | ||||
|  * into that file, and then add the following code before importing zone.js. | ||||
|  * import './zone-flags.ts'; | ||||
|  * | ||||
|  * The flags allowed in zone-flags.ts are listed here. | ||||
|  * | ||||
|  * The following flags will work for all browsers. | ||||
|  * | ||||
|  * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
 | ||||
|  * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
 | ||||
|  * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
 | ||||
|  * | ||||
|  *  in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js | ||||
|  *  with the following flag, it will bypass `zone.js` patch for IE/Edge | ||||
|  * | ||||
|  *  (window as any).__Zone_enable_cross_context_check = true; | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| import './zone-flags'; | ||||
| 
 | ||||
| /*************************************************************************************************** | ||||
| /** | ||||
|  * Zone JS is required by default for Angular itself. | ||||
|  */ | ||||
| 
 | ||||
| import 'zone.js/dist/zone';  // Included with Angular CLI.
 | ||||
| 
 | ||||
| 
 | ||||
| /*************************************************************************************************** | ||||
|  * APPLICATION IMPORTS | ||||
|  */ | ||||
|  | ||||
| @ -1 +1,15 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import 'jest-preset-angular'; | ||||
|  | ||||
| @ -14,8 +14,9 @@ | ||||
| 
 | ||||
| import { CUSTOM_ELEMENTS_SCHEMA, Type } from '@angular/core'; | ||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
| import { Component } from '@angular/compiler/src/core'; | ||||
| 
 | ||||
| export async function prepareComponentTest(component: any): Promise<void> { | ||||
| export async function prepareComponentTest(component: Type<Component>): Promise<void> { | ||||
|     TestBed.configureTestingModule({ | ||||
|         declarations: [component], | ||||
|         schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||||
|  | ||||
							
								
								
									
										26
									
								
								src/types/global.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/types/global.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| // (C) Copyright 2015 Moodle Pty Ltd.
 | ||||
| //
 | ||||
| // Licensed under the Apache License, Version 2.0 (the "License");
 | ||||
| // you may not use this file except in compliance with the License.
 | ||||
| // You may obtain a copy of the License at
 | ||||
| //
 | ||||
| //     http://www.apache.org/licenses/LICENSE-2.0
 | ||||
| //
 | ||||
| // Unless required by applicable law or agreed to in writing, software
 | ||||
| // distributed under the License is distributed on an "AS IS" BASIS,
 | ||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | ||||
| // See the License for the specific language governing permissions and
 | ||||
| // limitations under the License.
 | ||||
| 
 | ||||
| import ''; | ||||
| 
 | ||||
| declare global { | ||||
| 
 | ||||
|     interface Window { | ||||
| 
 | ||||
|         // eslint-disable-next-line @typescript-eslint/naming-convention
 | ||||
|         __Zone_disable_customElements: boolean; | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -16,4 +16,6 @@ | ||||
|  * Prevents Angular change detection from | ||||
|  * running with certain Web Component callbacks | ||||
|  */ | ||||
| (window as any).__Zone_disable_customElements = true; | ||||
| 
 | ||||
| // eslint-disable-next-line no-underscore-dangle
 | ||||
| window.__Zone_disable_customElements = true; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user