UNPKG

@gitlab/eslint-plugin

Version:

GitLab package for our custom eslint rules

116 lines (114 loc) 3.03 kB
const confusingBrowserGlobals = require('confusing-browser-globals'); /* This plugin contains rules related to GitLab JavaScript style guide Vue specific rules are in lib/configs/vue.js */ module.exports = { env: { browser: true, es2020: true, }, extends: [ ...[ './base/best-practices.js', './base/errors', './base/node', './base/style', './base/variables', './base/es6', './base/imports', './base/strict', ].map((f) => require.resolve(f)), 'prettier', 'plugin:promise/recommended', ], parserOptions: { parser: 'espree', ecmaVersion: 'latest', }, plugins: ['unicorn', 'promise', 'import', '@gitlab'], rules: { camelcase: [ 'error', { properties: 'never', ignoreDestructuring: true, }, ], 'default-param-last': 'off', 'arrow-body-style': 'off', 'unicorn/filename-case': ['error', { case: 'snakeCase' }], 'unicorn/no-array-callback-reference': 'error', 'import/prefer-default-export': 'off', 'import/no-default-export': 'error', 'import/no-deprecated': 'error', 'import/no-dynamic-require': ['error', { esmodule: true }], 'no-implicit-coercion': [ 'error', { boolean: true, number: true, string: true, }, ], 'no-param-reassign': [ 'error', { props: true, ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'], }, ], 'no-restricted-exports': [ 'error', { restrictedNamedExports: [ 'then', // avoid confusion when used with dynamic `import()` promise ], }, ], 'no-restricted-syntax': 'off', 'no-sequences': [ 'error', { allowInParentheses: false, }, ], 'promise/catch-or-return': [ 'error', { allowFinally: true, }, ], 'no-restricted-globals': [ 'error', { name: 'isFinite', message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite', }, { name: 'isNaN', message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan', }, { name: 'escape', message: "The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?", }, { name: 'unescape', message: "The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?", }, ].concat(confusingBrowserGlobals), 'import/order': [ 'error', { groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], }, ], // https://docs.gitlab.com/ee/development/fe_guide/style/javascript.html#limit-number-of-parameters 'max-params': ['error', { max: 3 }], }, };