2024-09-07 12:49:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import love from 'eslint-config-love'
|
|
|
|
import eslint from '@eslint/js'
|
|
|
|
import tseslint from 'typescript-eslint'
|
|
|
|
import typescriptParser from '@typescript-eslint/parser'
|
|
|
|
import stylistic from '@stylistic/eslint-plugin'
|
2024-09-09 16:47:21 +00:00
|
|
|
import eslintLit from 'eslint-plugin-lit'
|
2024-09-07 12:49:27 +00:00
|
|
|
import globals from 'globals'
|
|
|
|
|
|
|
|
export default tseslint.config(
|
|
|
|
{
|
|
|
|
ignores: [
|
2024-09-09 16:47:21 +00:00
|
|
|
'node_modules/', 'dist/', 'webpack.config.js',
|
|
|
|
'build/',
|
|
|
|
'vendor/',
|
|
|
|
'support/documentation', 'support',
|
2024-09-09 18:37:45 +00:00
|
|
|
'build-*js'
|
2024-09-07 12:49:27 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
eslint.configs.recommended,
|
|
|
|
...tseslint.configs.recommended,
|
|
|
|
{
|
|
|
|
...love,
|
|
|
|
files: ['**/*.ts']
|
|
|
|
},
|
2024-09-09 16:47:21 +00:00
|
|
|
stylistic.configs.customize({
|
|
|
|
quotes: 'single',
|
|
|
|
semi: false,
|
|
|
|
commaDangle: 'never',
|
|
|
|
blockSpacing: true,
|
|
|
|
braceStyle: '1tbs',
|
|
|
|
indent: 2,
|
|
|
|
quoteProps: 'as-needed'
|
|
|
|
}),
|
2024-09-07 12:49:27 +00:00
|
|
|
{
|
|
|
|
rules: {
|
2024-09-09 16:47:21 +00:00
|
|
|
'@stylistic/space-before-function-paren': ['error', { anonymous: 'always', asyncArrow: 'always', named: 'always' }],
|
|
|
|
'@stylistic/arrow-parens': 'off',
|
|
|
|
'@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before' } }],
|
|
|
|
'@stylistic/max-statements-per-line': ['error', { max: 2 }]
|
2024-09-07 12:49:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['**/*.ts'],
|
|
|
|
rules: {
|
2024-09-09 16:47:21 +00:00
|
|
|
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
|
2024-09-09 18:01:25 +00:00
|
|
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
|
|
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
2024-09-09 16:47:21 +00:00
|
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
|
|
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
|
|
'@typescript-eslint/return-await': [2, 'in-try-catch'], // FIXME: correct?
|
|
|
|
'@typescript-eslint/no-invalid-void-type': 'off',
|
|
|
|
'@typescript-eslint/triple-slash-reference': 'off',
|
|
|
|
'@typescript-eslint/no-explicit-any': 'off', // FIXME: should be "error", and we should use 'unknown' in the code.
|
|
|
|
'init-declarations': 'off',
|
|
|
|
'@typescript-eslint/init-declarations': 'off',
|
|
|
|
'@typescript-eslint/consistent-type-imports': 'off',
|
|
|
|
'@typescript-eslint/consistent-type-exports': 'off',
|
|
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
|
|
'@typescript-eslint/unbound-method': 'off',
|
|
|
|
'@typescript-eslint/prefer-promise-reject-errors': 'off',
|
|
|
|
'max-params': 'off',
|
|
|
|
'@typescript-eslint/max-params': ['error', { max: 8 }], // FIXME: this rules should use the default max value.
|
|
|
|
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
|
|
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
|
|
'@typescript-eslint/class-methods-use-this': 'off',
|
|
|
|
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
2024-09-16 09:34:44 +00:00
|
|
|
'@typescript-eslint/no-magic-numbers': 'off',
|
2024-09-09 16:47:21 +00:00
|
|
|
'max-len': [
|
|
|
|
'error',
|
2024-09-07 12:49:27 +00:00
|
|
|
{
|
2024-09-09 16:47:21 +00:00
|
|
|
code: 120,
|
|
|
|
comments: 120
|
2024-09-07 12:49:27 +00:00
|
|
|
}
|
2024-09-09 18:01:25 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['**/*.js'],
|
|
|
|
rules: {
|
|
|
|
// Disabling typescript-eslint rules for JS files (did not find a simplier way...)
|
|
|
|
'@typescript-eslint/no-empty-function': 'off',
|
|
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
|
|
'@typescript-eslint/no-floating-promises': 'off',
|
|
|
|
'@typescript-eslint/no-misused-promises': 'off',
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
|
|
'@typescript-eslint/return-await': 'off',
|
|
|
|
'@typescript-eslint/no-invalid-void-type': 'off',
|
|
|
|
'@typescript-eslint/triple-slash-reference': 'off',
|
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
|
|
'@typescript-eslint/init-declarations': 'off',
|
|
|
|
'@typescript-eslint/consistent-type-imports': 'off',
|
|
|
|
'@typescript-eslint/consistent-type-exports': 'off',
|
|
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
|
|
'@typescript-eslint/unbound-method': 'off',
|
|
|
|
'@typescript-eslint/prefer-promise-reject-errors': 'off',
|
|
|
|
'@typescript-eslint/max-params': 'off',
|
|
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
|
|
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
|
|
'@typescript-eslint/class-methods-use-this': 'off',
|
|
|
|
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
2024-09-16 09:34:44 +00:00
|
|
|
'@typescript-eslint/no-magic-numbers': 'off',
|
2024-09-09 18:01:25 +00:00
|
|
|
|
|
|
|
'max-params': 'off',
|
|
|
|
'init-declarations': 'off',
|
|
|
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
|
|
|
|
'max-len': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
code: 120,
|
|
|
|
comments: 120
|
|
|
|
}
|
|
|
|
]
|
2024-09-07 12:49:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['.stylelintrc.js'],
|
|
|
|
languageOptions: {
|
|
|
|
globals: globals.node
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-09-10 07:49:21 +00:00
|
|
|
files: ['server/**/*.js', 'server/**/*.ts'],
|
2024-09-07 12:49:27 +00:00
|
|
|
languageOptions: {
|
|
|
|
ecmaVersion: 6,
|
|
|
|
globals: {
|
|
|
|
...globals.node
|
|
|
|
},
|
|
|
|
parser: typescriptParser,
|
|
|
|
parserOptions: {
|
|
|
|
ecmaVersion: 2018,
|
2024-09-10 07:49:21 +00:00
|
|
|
project: './server/tsconfig.json',
|
|
|
|
projectService: true
|
2024-09-07 12:49:27 +00:00
|
|
|
}
|
|
|
|
}
|
2024-09-09 16:47:21 +00:00
|
|
|
},
|
|
|
|
{
|
2024-09-09 18:01:25 +00:00
|
|
|
files: ['shared/**/*.js', 'shared/**/*.ts'],
|
2024-09-09 16:47:21 +00:00
|
|
|
languageOptions: {
|
|
|
|
ecmaVersion: 6,
|
|
|
|
globals: {
|
|
|
|
...globals.es2016,
|
|
|
|
...globals.browser
|
|
|
|
},
|
|
|
|
parser: typescriptParser,
|
|
|
|
parserOptions: {
|
|
|
|
ecmaVersion: 2018,
|
|
|
|
project: [
|
2024-09-09 18:37:45 +00:00
|
|
|
'./server/tsconfig.json'
|
|
|
|
// './client/tsconfig.json' // FIXME: dont really know what is necessary here.
|
2024-09-09 16:47:21 +00:00
|
|
|
],
|
2024-09-09 18:37:45 +00:00
|
|
|
// FIXME: how to make projectService work?
|
|
|
|
projectService: false
|
|
|
|
// projectService: {
|
|
|
|
// allowDefaultProject: ['shared/lib/*.js', 'shared/lib/*.ts'],
|
|
|
|
// defaultProject: './server/tsconfig.json'
|
|
|
|
// }
|
2024-09-09 16:47:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-09-09 18:01:25 +00:00
|
|
|
files: ['client/**/*.js', 'client/**/*.ts', 'conversejs/**/*.js', 'conversejs/**/*.ts'],
|
2024-09-09 16:47:21 +00:00
|
|
|
languageOptions: {
|
|
|
|
ecmaVersion: 6,
|
|
|
|
globals: {
|
|
|
|
...globals.browser
|
|
|
|
},
|
|
|
|
parser: typescriptParser,
|
|
|
|
parserOptions: {
|
|
|
|
ecmaVersion: 2018,
|
2024-09-09 18:01:25 +00:00
|
|
|
project: [
|
|
|
|
'./client/tsconfig.json',
|
|
|
|
'./conversejs/tsconfig.json'
|
|
|
|
]
|
2024-09-09 16:47:21 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
// FIXME: not sure elintLit works.
|
|
|
|
plugins: {
|
|
|
|
...eslintLit.configs['flat/recommended'].plugins
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
...eslintLit.configs['flat/recommended'].rules
|
|
|
|
}
|
2024-09-09 18:01:25 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['conversejs/build-*.js', 'conversejs/loc.keys.js', 'conversejs/custom/webpack.livechat.js'],
|
|
|
|
languageOptions: {
|
|
|
|
globals: {
|
|
|
|
...globals.node
|
|
|
|
}
|
|
|
|
}
|
2024-09-07 12:49:27 +00:00
|
|
|
}
|
|
|
|
)
|