113 lines
2.8 KiB
JavaScript
113 lines
2.8 KiB
JavaScript
const angularEslint = require('angular-eslint');
|
|
|
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
const config = [
|
|
{
|
|
ignores: ['dist/**', 'node_modules/**', '.angular/**', 'backend/sql/**'],
|
|
},
|
|
|
|
{
|
|
files: ['**/*.{ts,tsx,js,cjs,mjs}'],
|
|
|
|
languageOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
parser: require('@typescript-eslint/parser'),
|
|
parserOptions: {
|
|
ecmaFeatures: {},
|
|
},
|
|
},
|
|
|
|
plugins: {
|
|
'@angular-eslint': angularEslint.tsPlugin,
|
|
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
|
|
import: require('eslint-plugin-import'),
|
|
promise: require('eslint-plugin-promise'),
|
|
'unused-imports': require('eslint-plugin-unused-imports'),
|
|
n: require('eslint-plugin-n'),
|
|
},
|
|
|
|
rules: {
|
|
// Your selectors
|
|
'@angular-eslint/directive-selector': [
|
|
'error',
|
|
{ type: 'attribute', prefix: 'app', style: 'camelCase' },
|
|
],
|
|
'@angular-eslint/component-selector': [
|
|
'error',
|
|
{ type: 'element', prefix: 'app', style: 'kebab-case' },
|
|
],
|
|
|
|
// Practical TS hygiene
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
],
|
|
'@typescript-eslint/consistent-type-imports': [
|
|
'warn',
|
|
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
|
|
],
|
|
|
|
/* Base */
|
|
'no-debugger': 'warn',
|
|
|
|
/* TypeScript */
|
|
'unused-imports/no-unused-imports': 'warn',
|
|
'unused-imports/no-unused-vars': [
|
|
'warn',
|
|
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
|
|
/* Imports */
|
|
'import/first': 'error',
|
|
'import/no-duplicates': 'error',
|
|
'import/newline-after-import': 'warn',
|
|
'import/no-extraneous-dependencies': [
|
|
'error',
|
|
{
|
|
devDependencies: [
|
|
'**/*.config*.{js,cjs,mjs,ts}',
|
|
'**/scripts/**',
|
|
'**/*.test.{ts,js}',
|
|
'**/Testing.{ts,js}',
|
|
'**/.eslintrc.{js,cjs}',
|
|
],
|
|
},
|
|
],
|
|
|
|
/* Node */
|
|
'n/no-missing-import': 'off',
|
|
'n/no-unsupported-features/es-syntax': 'off',
|
|
|
|
/* Promis */
|
|
'promise/catch-or-return': 'warn',
|
|
'promise/always-return': 'off',
|
|
|
|
/* „Fire-and-forget“-Promises `void` */
|
|
'no-void': ['warn', { allowAsStatement: true }],
|
|
},
|
|
|
|
settings: {
|
|
'import/resolver': {
|
|
typescript: {
|
|
alwaysTryTypes: true,
|
|
},
|
|
node: true,
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
files: ['**/*.{js,cjs}'],
|
|
languageOptions: {
|
|
sourceType: 'script',
|
|
},
|
|
rules: {
|
|
'n/global-require': 'off',
|
|
},
|
|
},
|
|
];
|
|
|
|
module.exports = config;
|