Untitled

 avatar
unknown
plain_text
3 years ago
6.7 kB
5
Indexable
const path = require('path');

module.exports = {
  env: {
    commonjs: true,
    node: true,
    browser: true,
    es2021: true,
    jest: true,
    'cypress/globals': true,
  },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:prettier/recommended',
    'red',
    'plugin:sonarjs/recommended',
    'plugin:cypress/recommended',
  ],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 'latest',
    sourceType: 'module',
  },
  parser: '@babel/eslint-parser',
  plugins: [
    'react',
    'import',
    'react-hooks',
    'sonarjs',
    'unicorn',
    'fp',
    'prefer-optional-chaining',
    'jsdoc',
    // '@shopify',
    'jest',
    'jest-dom',
    'testing-library',
    'cypress',
  ],
  rules: {
    'linebreak-style': 0,
    'no-prototype-builtins': 0,
    'no-case-declarations': 0,
    'no-plusplus': 0,
    'no-magic-numbers': 0,
    'max-params': 0,
    'max-depth': 0,
    'no-implicit-coercion': 0,
    quotes: 0,
    'comma-dangle': 0,
    'no-ternary': 0,
    'no-children-prop': 0,
    'react/prop-types': 0,
    'react/no-unescaped-entities': 0,
    'react/no-render-return-value': 0,
    'react/no-children-prop': 0,
    'react/jsx-no-useless-fragment': 0,

    'no-restricted-syntax': [
      2,
      {
        selector: 'ExportDefaultDeclaration',
        message: 'Do not use default export. Use named exports instead.',
      },
      'WithStatement',
      'ClassDeclaration',
      'ClassExpression',
      "BinaryExpression[operator='in']",
    ],
    'arrow-body-style': [1, 'as-needed'],
    'no-unused-expressions': [
      2,
      {
        allowShortCircuit: true,
        allowTernary: true,
        allowTaggedTemplates: true,
        enforceForJSX: true,
      },
    ],
    'react/jsx-boolean-value': 2,
    'react/boolean-prop-naming': 2,
    'react/no-multi-comp': 2,
    'react/no-unstable-nested-components': 2,
    'react/jsx-props-no-spreading': 2,
    'jsdoc/check-types': 1,
    'jsdoc/check-alignment': 1,
    'fp/no-delete': 1,
    camelcase: [
      1,
      {
        properties: 'never',
      },
    ],
    'prefer-arrow-callback': 2,
    'no-useless-call': 2,
    'no-lone-blocks': 2,
    'no-var': 2,
    'prefer-const': 2,
    'prefer-rest-params': 2,
    'no-return-assign': [2, 'always'],
    'no-else-return': 2,
    'prefer-template': 2,
    'prefer-spread': 2,
    'no-return-await': 2,
    'no-param-reassign': 2,
    'array-callback-return': [2, { allowImplicit: true }],
    'dot-notation': 2,
    // '@shopify/prefer-early-return': 2, // too many warnings
    // '@shopify/restrict-full-import': [
    //   2,
    //   ['lodash', '@mui/material', "@mui/icons-material'"],
    // ],
    'object-shorthand': 2,
    'import/first': 2,
    'import/order': 2,
    'import/no-duplicates': 2,
    'import/no-useless-path-segments': [
      2,
      {
        noUselessIndex: true,
      },
    ],
    'no-unneeded-ternary': [2, { defaultAssignment: false }],
    'prefer-optional-chaining/prefer-optional-chaining': 1,
    'require-atomic-updates': 1,
    'no-nested-ternary': 1,
    'no-console': [1, { allow: ['warn', 'error', 'debug'] }],
    eqeqeq: 1,
    'cypress/no-unnecessary-waiting': 1,
    'sonarjs/cognitive-complexity': 0, // disabled because: sonar warns against react functional components
    'sonarjs/prefer-immediate-return': 0, // disabled because: bad rule. Too opinionated.
    'sonarjs/no-duplicate-string': 0,
    'sonarjs/no-nested-template-literals': 0, // disabled because: we use t`string` (ttag special syntax) for translations.
    'unicorn/better-regex': 2,
    'unicorn/explicit-length-check': 2,
    'unicorn/consistent-function-scoping': 2,
    'unicorn/prefer-default-parameters': 2,
    'unicorn/no-array-push-push': 1,
    'unicorn/prefer-array-index-of': 1,
    'unicorn/prefer-array-flat-map': 1,
    'unicorn/prefer-array-some': 1,
    'unicorn/prefer-array-find': 1,
    'unicorn/prefer-array-flat': 1,
    'unicorn/prefer-includes': 2,
    'unicorn/prefer-spread': 2,
    'unicorn/no-useless-undefined': 2,
    'unicorn/no-for-loop': 2,
    'no-shadow': [
      2,
      {
        hoist: 'all',
        allow: ['resolve', 'reject', 'done', 'next', 'err', 'error'],
      },
    ],
    'no-eval': 2,
    'prettier/prettier': [
      'error',
      {
        endOfLine: 'auto',
        trailingComma: 'es5',
        semi: true,
        singleQuote: true,
        bracketSpacing: true,
        bracketSameLine: false,
        printWidth: 85,
        arrowParens: 'avoid',
        parser: 'babel',
        tabWidth: 2,
        quoteProps: 'as-needed',
      },
    ],
  },
  overrides: [
    {
      files: ['**/__tests__/**/*.[jt]s?(x)'],
      extends: [
        'plugin:testing-library/react',
        'plugin:jest/all',
        'plugin:jest-dom/recommended',
      ],
      rules: {
        'jest/prefer-expect-assertions': 0,
        'jest/prefer-lowercase-title': [2, { ignore: ['describe'] }],
      },
    },
  ],
  ignorePatterns: ['node_modules/'],
  settings: {
    react: {
      version: 'detect',
    },
    jest: {
      version: require('jest/package.json').version,
    },
    'import/resolver': {
      alias: {
        map: [
          ['@src', path.resolve(__dirname, 'src')],
          ['@assets', path.resolve(__dirname, 'src/assets')],
          ['@builders', path.resolve(__dirname, 'src/builders')],
          ['@hooks', path.resolve(__dirname, 'src/hooks')],
          ['@old', path.resolve(__dirname, 'src/pages')],
          ['@register', path.resolve(__dirname, 'src/register')],
          ['@ux-core', path.resolve(__dirname, 'src/ux-core')],
          ['@pages', path.resolve(__dirname, 'src/new/Pages')],
          ['@admin', path.resolve(__dirname, 'src/new/Pages/Admin')],
          ['@app', path.resolve(__dirname, 'src/new/Pages/App')],
          ['@container', path.resolve(__dirname, 'src/new/Pages/ContainerPage')],
          ['@layout', path.resolve(__dirname, 'src/new/Pages/Layout')],
          ['@login', path.resolve(__dirname, 'src/new/Pages/Login')],
          [
            '@userPreferences',
            path.resolve(__dirname, 'src/new/Pages/user-preferences'),
          ],
          ['@users', path.resolve(__dirname, 'src/new/Pages/Users')],
          ['@entityManager', path.resolve(__dirname, 'src/new/EntityManager')],
          ['@entities', path.resolve(__dirname, 'src/new/Entities')],
          ['@components', path.resolve(__dirname, 'src/new/Components')],
        ],
      },
    },
  },
};
Editor is loading...