const lernaJSON = require('./lerna.json');

module.exports = {
  extends: ['airbnb', 'prettier'],
  plugins: ['import', 'prettier'],
  env: {
    browser: true,
  },
  rules: {
    'arrow-body-style': 'off',
    'arrow-parens': ['error', 'as-needed'],
    'import/no-relative-packages': 'off',
    'import/prefer-default-export': 'off',
    'import/extensions': 'off',
    camelcase: 'off',
    indent: [
      'error',
      2,
      {
        SwitchCase: 1,
        ignoredNodes: [
          'TaggedTemplateExpression[tag.name=/html|outdent/]',
          'TaggedTemplateExpression[tag.name=/html|outdent/] *',
        ],
      },
    ],
    'no-confusing-arrow': 'off',
    'class-methods-use-this': 'off',
    'no-return-assign': 'off',
    'no-bitwise': 'off',
    'no-continue': 'off',
    'no-param-reassign': ['error', { props: false }],
    'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
    'no-underscore-dangle': 'off',
    'no-use-before-define': ['error', { functions: false, classes: false }],
    'import/no-extraneous-dependencies': [
      'error',
      {
        devDependencies: [
          'scripts/**',
          'rollup.config.js',
          'rollup.config.dist.js',
          'playwright.config.js',
          '**/story.{js,jsx}',
          '**/demo.{js,jsx}',
          '**/react/*.{js,jsx}',
          '**/05-utils/**/*.{js,jsx}',
          '**/src/**/*.react.js',
          '**/demo/**',
          '**/ui.test.js',
          '**/e2e.js',
          '**/unit.test.{js,jsx}',
          '**/*test.accessor.js',
          '**/*ui.test.js',
        ],
        packageDir: [__dirname, ...lernaJSON.packages],
      },
    ],
    'no-restricted-syntax': [
      'error',
      'ForInStatement',
      'LabeledStatement',
      'WithStatement',
    ],
    'object-curly-newline': ['error', { multiline: true, consistent: true }],
    'react/function-component-definition': 'off',
    'react/jsx-props-no-spreading': 'off',
    'react/destructuring-assignment': 'off',
    'react/prop-types': 'off',
  },
  globals: {
    HTMLElement: true,
    HTMLSelectElement: true,
    XMLHttpRequest: true,
    history: true,
    CustomEvent: true,
    MutationObserver: true,
    customElements: true,
    document: true,
    navigator: true,
    window: true,
    ENV: true,
    PROD: true,
    DEV: true,
    fixture: true,
    test: true,
    page: true,
    __VERSION_INFO__: true,
    __COLORS_SCSS_AS_STRING__: true,
  },
  parserOptions: {
    ecmaVersion: 2019,
    ecmaFeatures: {
      jsx: true,
    },
  },
};
