Skip to content

Commit

Permalink
ci: essential linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ScarletFlash committed Jun 22, 2024
1 parent 19690e2 commit 375dde5
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 419 deletions.
2 changes: 2 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"quiet": true,
"eslintConfig": "eslint.config.js",
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
}
Expand Down
240 changes: 220 additions & 20 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,240 @@
// @ts-check
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const angular = require('angular-eslint');
const ESLint = require('@eslint/js');
const AngularESLint = require('angular-eslint');
const TypeScriptESLint = require('typescript-eslint');

module.exports = tseslint.config(
module.exports = TypeScriptESLint.config(
{
languageOptions: {
parser: TypeScriptESLint.parser,
parserOptions: {
ecmaFeatures: { modules: true },
ecmaVersion: 'latest',
project: './tsconfig.app.json'
}
},
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
...angular.configs.tsRecommended
ESLint.configs.recommended,
...TypeScriptESLint.configs.strictTypeChecked,
...TypeScriptESLint.configs.stylisticTypeChecked,
...AngularESLint.configs.tsAll
],
processor: angular.processInlineTemplates,
processor: AngularESLint.processInlineTemplates,
rules: {
'@angular-eslint/directive-selector': [
curly: 'error',
'max-depth': [
'error',
{
type: 'attribute',
prefix: 'app',
style: 'camelCase'
max: 2
}
],
'@angular-eslint/component-selector': [
'no-else-return': [
'error',
{
type: 'element',
prefix: 'app',
style: 'kebab-case'
allowElseIf: false
}
]
],
'no-extra-boolean-cast': [
'error',
{
enforceForLogicalOperands: true
}
],
'no-implicit-coercion': [
'error',
{
boolean: true,
number: true,
string: true,
disallowTemplateShorthand: false
}
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports'
}
],
'@typescript-eslint/consistent-type-exports': [
'error',
{
fixMixedExportsWithInlineTypeSpecifier: true
}
],
'@typescript-eslint/ban-types': [
'error',
{
types: {
Object: null
},
extendDefaults: false
}
],
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never'
}
],
'@typescript-eslint/no-unnecessary-condition': [
'error',
{
allowConstantLoopConditions: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: true
}
],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
overrides: {
constructors: 'off',
parameterProperties: 'off'
}
}
],
'@typescript-eslint/member-ordering': [
'error',
{
classes: [
'abstract-field',
'instance-field',
'static-field',

'static-get',
'instance-get',
'abstract-get',

'constructor',

'abstract-method',

'public-instance-method',
'protected-instance-method',
'private-instance-method',
'#private-instance-method',

'public-static-method',
'protected-static-method',
'private-static-method',
'#private-static-method'
]
}
],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-require-imports': 'error',
'no-unused-expressions': 'off',
'no-inner-declarations': 'off',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: false,
allowTernary: true,
allowTaggedTemplates: false,
enforceForJSX: false
}
],
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowString: false,
allowNumber: false,
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false
}
],
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/typedef': [
'error',
{
arrowParameter: true,
arrayDestructuring: false,
memberVariableDeclaration: true,
objectDestructuring: false,
parameter: true,
propertyDeclaration: true,
variableDeclaration: true,
variableDeclarationIgnoreFunction: true
}
],
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true
}
],
'@typescript-eslint/no-namespace': 'off',
complexity: [
'error',
{
max: 10
}
],
'consistent-return': 'error',
'no-underscore-dangle': 'error',
'default-case': 'error',
'default-case-last': 'error',
eqeqeq: 'error',
'no-caller': 'error',
'no-duplicate-imports': 'error',
'no-sequences': [
'error',
{
allowInParentheses: false
}
],
'no-template-curly-in-string': 'error',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'prefer-object-spread': 'error',
'prefer-template': 'error',
'object-shorthand': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_'
}
],
'no-var': 'error',
'no-unneeded-ternary': 'error',
'no-undef-init': 'error',
'no-new-wrappers': 'error',
'no-bitwise': 'error',
'prefer-const': 'error',
radix: 'error',
'no-eval': 'error',
'no-console': [
'error',
{
allow: ['warn']
}
],
'id-denylist': ['warn', 'data', 'e', 'acc'],
'arrow-body-style': ['error', 'as-needed'],
'prefer-arrow-callback': 'error',
'no-restricted-imports': 'off',
'@typescript-eslint/no-restricted-imports': 'error'
}
},
{
files: ['**/*.html'],
extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
rules: {}
extends: [...AngularESLint.configs.templateAll],
rules: {
'@angular-eslint/template/i18n': 'off'
}
}
);
Loading

0 comments on commit 375dde5

Please sign in to comment.