import withNuxt from './.nuxt/eslint.config.mjs'
import stylistic from '@stylistic/eslint-plugin'
import parser from 'vue-eslint-parser'
import eslintParser from '@typescript-eslint/parser'

export default withNuxt(
  {
    plugins: {
      '@stylistic': stylistic,
    },
    files: ['**/*.{ts,js,vue}'],
    languageOptions: {
      parser: parser,
      ecmaVersion: 2018,
      sourceType: 'module',
      parserOptions: {
        parser: eslintParser,
      },
    },
    rules: {
      'vue/multi-word-component-names': 'off',
      'nuxt/no-cjs-in-config': 'off',
      'vue/no-unused-components': 'off',
      'import/named': 'off',
      'vue/max-attributes-per-line': [
        'error',
        {
          singleline: {
            max: 1,
          },
          multiline: {
            max: 1,
          },
        },
      ],
      'vue/html-self-closing': [
        'error',
        {
          html: {
            void: 'any',
            normal: 'always',
            component: 'always',
          },
          svg: 'always',
          math: 'always',
        },
      ],
      'camelcase': ['off', { properties: 'never' }],
      'no-console': ['error', { allow: ['warn', 'error'] }],
      'no-unused-expressions': 'error',
      'no-dupe-else-if': 1,
      'no-duplicate-case': 2,
      'no-duplicate-imports': 2,
      'no-fallthrough': 2,
      'no-unreachable': 2,
      'no-unsafe-optional-chaining': 2,
      'no-unsafe-negation': 2,
      'valid-typeof': 2,
      'max-depth': ['error', 3],
      'eqeqeq': 2,
      'no-var': 2,
      'prefer-const': 2,
      'consistent-return': 2,
      'no-useless-return': 2,
      '@stylistic/indent': ['error', 4],
      '@stylistic/operator-linebreak': [
        'error',
        'after',
        {
          overrides: {
            '?': 'before',
            ':': 'before',
          },
        },
      ],
      '@stylistic/comma-dangle': [
        'error',
        {
          arrays: 'always-multiline',
          objects: 'always-multiline',
          imports: 'always-multiline',
          exports: 'always-multiline',
          functions: 'always-multiline',
        },
      ],
      '@stylistic/max-len': [
        'error',
        {
          code: 120,
          tabWidth: 5,
          ignoreUrls: true,
          ignoreStrings: true,
          ignoreTemplateLiterals: true,
          ignoreRegExpLiterals: true,
        },
      ],
      '@stylistic/array-element-newline': ['error', 'consistent'],
      '@stylistic/function-call-argument-newline': ['error', 'consistent'],
      '@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
      '@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }],
      '@stylistic/no-multiple-empty-lines': 'error',
      '@stylistic/object-curly-spacing': ['error', 'always'],
      '@stylistic/block-spacing': ['error', 'always'],
      '@stylistic/brace-style': ['error', '1tbs'],
      '@stylistic/key-spacing': 'error',
      '@stylistic/linebreak-style': 'error',
      '@stylistic/member-delimiter-style': 'error',
      '@stylistic/no-whitespace-before-property': 'error',
      '@stylistic/quotes': ['error', 'single'],
      '@stylistic/space-before-blocks': 'error',
      '@stylistic/eol-last': ['error', 'always'],
      '@stylistic/padding-line-between-statements': [
        'error',
        {
          blankLine: 'always',
          prev: '*',
          next: 'return',
        },
        {
          blankLine: 'always',
          prev: 'block-like',
          next: '*',
        },
      ],
      '@stylistic/semi': ['error', 'never'],
    },
  },
)
