308 lines
9.3 KiB
JavaScript
308 lines
9.3 KiB
JavaScript
const appConfig = {
|
|
env: {
|
|
browser: true,
|
|
es6: true,
|
|
node: true,
|
|
},
|
|
plugins: [
|
|
'@typescript-eslint',
|
|
'header',
|
|
'jsdoc',
|
|
'prefer-arrow',
|
|
'promise',
|
|
],
|
|
extends: [
|
|
'eslint:recommended',
|
|
'plugin:@typescript-eslint/recommended',
|
|
'prettier',
|
|
'plugin:@angular-eslint/recommended',
|
|
'plugin:promise/recommended',
|
|
],
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
project: 'tsconfig.json',
|
|
sourceType: 'module',
|
|
},
|
|
reportUnusedDisableDirectives: true,
|
|
rules: {
|
|
'@angular-eslint/component-class-suffix': ['error', { suffixes: ['Component', 'Page'] }],
|
|
'@angular-eslint/no-output-on-prefix': 'off',
|
|
'@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/explicit-module-boundary-types': [
|
|
'error',
|
|
{
|
|
allowArgumentsExplicitlyTypedAsAny: true,
|
|
},
|
|
],
|
|
'@typescript-eslint/indent': [
|
|
'error',
|
|
4,
|
|
{
|
|
SwitchCase: 1,
|
|
ignoredNodes: [
|
|
'ClassProperty *',
|
|
],
|
|
},
|
|
],
|
|
'@typescript-eslint/lines-between-class-members': [
|
|
'error',
|
|
'always',
|
|
{
|
|
exceptAfterSingleLine: true,
|
|
},
|
|
],
|
|
'@typescript-eslint/member-delimiter-style': [
|
|
'error',
|
|
{
|
|
multiline: {
|
|
delimiter: 'semi',
|
|
requireLast: true,
|
|
},
|
|
singleline: {
|
|
delimiter: 'semi',
|
|
requireLast: false,
|
|
},
|
|
},
|
|
],
|
|
'@typescript-eslint/member-ordering': [
|
|
'error',
|
|
{
|
|
default:
|
|
{
|
|
order: 'as-written',
|
|
},
|
|
|
|
}
|
|
],
|
|
'@typescript-eslint/naming-convention': [
|
|
'error',
|
|
{
|
|
selector: 'property',
|
|
modifiers: ['readonly'],
|
|
format: ['UPPER_CASE'],
|
|
},
|
|
{
|
|
selector: 'property',
|
|
format: ['camelCase'],
|
|
},
|
|
{
|
|
selector: 'property',
|
|
modifiers: ['private'],
|
|
format: ['camelCase'],
|
|
leadingUnderscore: 'allow',
|
|
},
|
|
],
|
|
'@typescript-eslint/no-empty-function': 'error',
|
|
'@typescript-eslint/no-empty-interface': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/no-inferrable-types': [
|
|
'error',
|
|
{
|
|
ignoreParameters: true,
|
|
},
|
|
],
|
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
'@typescript-eslint/no-redeclare': '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',
|
|
'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,
|
|
],
|
|
'promise/catch-or-return': [
|
|
'warn',
|
|
{
|
|
allowFinally: true,
|
|
terminationMethod: ['catch', 'finally'],
|
|
},
|
|
],
|
|
'arrow-body-style': ['error', 'as-needed'],
|
|
'array-bracket-spacing': ['error', 'never'],
|
|
'comma-dangle': ['error', 'always-multiline'],
|
|
'constructor-super': 'error',
|
|
'curly': 'error',
|
|
'eol-last': 'error',
|
|
'function-call-argument-newline': ['error', 'consistent'],
|
|
'function-paren-newline': ['error', 'multiline-arguments'],
|
|
'id-blacklist': [
|
|
'error',
|
|
'any',
|
|
'Number',
|
|
'number',
|
|
'String',
|
|
'string',
|
|
'Boolean',
|
|
'boolean',
|
|
'Undefined',
|
|
'undefined',
|
|
],
|
|
'id-match': 'error',
|
|
'jsdoc/check-alignment': '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-fallthrough': 'off',
|
|
'no-invalid-this': 'error',
|
|
'no-irregular-whitespace': 'error',
|
|
'no-multiple-empty-lines': ['error', { "max": 1 }],
|
|
'no-new-wrappers': 'error',
|
|
'no-sequences': 'error',
|
|
'no-trailing-spaces': 'error',
|
|
'no-unused-labels': 'error',
|
|
'no-var': 'error',
|
|
'object-curly-spacing': ['error', 'always'],
|
|
'one-var': ['error', 'never'],
|
|
'padded-blocks': [
|
|
'error',
|
|
{
|
|
classes: 'always',
|
|
blocks: 'never',
|
|
switches: 'never',
|
|
},
|
|
],
|
|
'padding-line-between-statements': [
|
|
'error',
|
|
{
|
|
blankLine: 'always',
|
|
prev: '*',
|
|
next: 'return',
|
|
},
|
|
{
|
|
blankLine: 'always',
|
|
prev: '*',
|
|
next: 'function',
|
|
},
|
|
],
|
|
'prefer-arrow/prefer-arrow-functions': [
|
|
'error',
|
|
{
|
|
singleReturnOnly: true,
|
|
allowStandaloneDeclarations: true,
|
|
},
|
|
],
|
|
'prefer-const': 'error',
|
|
'prefer-spread': 'off',
|
|
'quote-props': [
|
|
'error',
|
|
'consistent-as-needed',
|
|
],
|
|
'spaced-comment': [
|
|
'error',
|
|
'always',
|
|
{
|
|
markers: [
|
|
'/',
|
|
],
|
|
},
|
|
],
|
|
'use-isnan': 'error',
|
|
'yoda': 'error',
|
|
},
|
|
};
|
|
|
|
var testsConfig = Object.assign({}, appConfig);
|
|
testsConfig['rules']['padded-blocks'] = [
|
|
'error',
|
|
{
|
|
classes: 'always',
|
|
switches: 'never',
|
|
},
|
|
];
|
|
testsConfig['rules']['jest/expect-expect'] = 'off';
|
|
testsConfig['plugins'].push('jest');
|
|
testsConfig['extends'].push('plugin:jest/recommended');
|
|
|
|
module.exports = {
|
|
root: true,
|
|
overrides: [
|
|
Object.assign({ files: ['*.ts'] }, appConfig),
|
|
Object.assign({ files: ['*.test.ts'] }, testsConfig),
|
|
{
|
|
files: ['*.html'],
|
|
extends: ['plugin:@angular-eslint/template/recommended'],
|
|
rules: {
|
|
'max-len': ['warn', { code: 140 }],
|
|
'@angular-eslint/template/accessibility-valid-aria': 'warn',
|
|
'@angular-eslint/template/accessibility-alt-text': 'error',
|
|
'@angular-eslint/template/accessibility-elements-content': 'error',
|
|
'@angular-eslint/template/accessibility-label-for': 'error',
|
|
'@angular-eslint/template/no-positive-tabindex': 'error',
|
|
'@angular-eslint/template/accessibility-table-scope': 'error',
|
|
'@angular-eslint/template/accessibility-valid-aria': 'error',
|
|
'@angular-eslint/template/no-duplicate-attributes': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: ['*.component.ts'],
|
|
extends: ['plugin:@angular-eslint/template/process-inline-templates'],
|
|
},
|
|
],
|
|
};
|