forum-django/eslint.config.mjs

116 lines
3 KiB
JavaScript
Raw Permalink Normal View History

2024-11-26 17:57:13 +01:00
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import typescriptEslintParser from '@typescript-eslint/parser'
/** @typedef {
import('typescript-eslint').ConfigWithExtends
} ConfigWithExtends */
/** @type {ConfigWithExtends} */
const jsCustomTypecheck = {
files: ['frontend/src/**/*.js'],
extends: [
eslint.configs.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.strict,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
],
rules: {
'max-classes-per-file': 0,
'no-continue': [0],
'no-console': [1],
'semi': [2, 'never'],
'quotes': [2, 'single'],
'strict': [2, 'never'],
'max-len': [2, { 'code': 80, 'tabWidth': 4, 'ignoreUrls': true }],
'no-restricted-syntax': 'off',
'import/prefer-default-export': ['off'],
'operator-linebreak': 'off',
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'@typescript-eslint/consistent-type-assertions': [
'error', {
'assertionStyle': 'angle-bracket'
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
'args': 'all',
'argsIgnorePattern': '^_',
'caughtErrors': 'all',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'ignoreRestSiblings': true
}
]
},
languageOptions: {
parser: typescriptEslintParser,
parserOptions: {
project: true,
},
sourceType: 'module',
},
}
/** @type {ConfigWithExtends} */
const tsCustomTypecheck = {
files: ['frontend/src/**/*.ts'],
extends: [
eslint.configs.recommended,
tseslint.configs.eslintRecommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
rules: {
'max-classes-per-file': 0,
'no-continue': [0],
'no-console': [1],
'semi': [2, 'never'],
'quotes': [2, 'single'],
'strict': [2, 'never'],
'max-len': [2, { 'code': 80, 'tabWidth': 4, 'ignoreUrls': true }],
'no-restricted-syntax': 'off',
'import/prefer-default-export': ['off'],
'operator-linebreak': 'off',
'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'@typescript-eslint/consistent-type-assertions': [
'error', {
'assertionStyle': 'angle-bracket'
}
],
'@typescript-eslint/no-unused-vars': [
'error',
{
'args': 'all',
'argsIgnorePattern': '^_',
'caughtErrors': 'all',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'ignoreRestSiblings': true
}
]
},
languageOptions: {
parser: typescriptEslintParser,
parserOptions: {
project: true,
ecmaVersion: 'latest',
sourceType: 'module'
},
sourceType: 'module',
},
}
const obj = tseslint.config(
jsCustomTypecheck,
tsCustomTypecheck
);
export default obj