// eslint.config.js
import js from '@eslint/js';
import {defineConfig} from 'eslint/config';
import globals from 'globals';

export default defineConfig([
  {
    ignores: [
      'dist/**',
      'rollup.config.js',
    ],
    plugins: {
      js,
    },
    extends: ['js/recommended'],
    languageOptions: {
      ecmaVersion: 2022,
      sourceType: 'module',
      globals: {
        ...globals.browser,
        ...globals.webextensions,
        __HOTPOCKET_EXTENSION_ENV__: false,
        __HOTPOCKET_EXTENSION_VERSION__: false,
      },
    },
    rules: {
      'no-undef': 'error',
      'quotes': [
        'error',
        'single',
        {'avoidEscape': true, 'allowTemplateLiterals': true},
      ],
      'no-unused-vars': ['error', {'args': 'none'}],
      'no-console': ['error', {'allow': ['warn', 'error', 'info']}],
      'no-empty': ['error', {'allowEmptyCatch': true}],
      'array-bracket-spacing': ['error', 'never'],
      'block-spacing': ['error', 'always'],
      'brace-style': ['error', '1tbs', {'allowSingleLine': true}],
      'camelcase': ['error', {'properties': 'never'}],
      'comma-dangle': ['error', 'always-multiline'],
      'comma-spacing': ['error', {'before': false, 'after': true}],
      'comma-style': ['error', 'last'],
      'computed-property-spacing': ['error', 'never'],
      'key-spacing': [
        'error', {'beforeColon': false, 'afterColon': true, 'mode': 'strict'},
      ],
      'keyword-spacing': ['error', { 'before': true, 'after': true }],
      'linebreak-style': ['error', 'unix'],
      'max-len': ['error', 120],
      'no-multiple-empty-lines': 'error',
      'no-spaced-func': 'error',
      'no-trailing-spaces': 'error',
      'no-unreachable': 'warn',
      'no-whitespace-before-property': 'error',
      'object-curly-spacing': 'off',
      'one-var-declaration-per-line': ['error', 'always'],
      'one-var': ['error', 'never'],
      'semi-spacing': ['error', {'before': false, 'after': true}],
      'semi': ['error', 'always'],
      'space-before-function-paren': ['error', 'always'],
      'space-before-blocks': ['error', 'always'],
      'space-in-parens': ['error', 'never'],
      'space-infix-ops': 'error',
      'unicode-bom': ['error', 'never'],
      'no-useless-escape': 'off',
      'class-methods-use-this': 'off',
      'no-invalid-this': 'off',
    },
  },
  {
    ignores: ['dist/**'],
  },
]);
