2017-04-17 16:37:37 +02:00
|
|
|
const error = 2;
|
|
|
|
const warn = 1;
|
|
|
|
const ignore = 0;
|
2019-04-25 17:59:37 +02:00
|
|
|
|
2017-04-14 09:26:27 +02:00
|
|
|
module.exports = {
|
2017-05-26 14:10:52 +02:00
|
|
|
root: true,
|
2018-02-17 21:27:49 +03:00
|
|
|
extends: [
|
2018-02-25 03:48:49 +03:00
|
|
|
'airbnb',
|
2018-02-17 21:27:49 +03:00
|
|
|
'plugin:jest/recommended',
|
|
|
|
'plugin:import/react-native',
|
2019-04-25 15:00:28 +02:00
|
|
|
'plugin:@typescript-eslint/recommended',
|
2018-02-17 21:27:49 +03:00
|
|
|
'prettier',
|
|
|
|
'prettier/react',
|
2019-04-25 15:00:28 +02:00
|
|
|
'prettier/@typescript-eslint',
|
2018-02-17 21:27:49 +03:00
|
|
|
],
|
2019-04-25 15:00:28 +02:00
|
|
|
plugins: [
|
|
|
|
'@typescript-eslint',
|
|
|
|
'prettier',
|
|
|
|
'jest',
|
|
|
|
'import',
|
|
|
|
'react',
|
|
|
|
'jsx-a11y',
|
|
|
|
'json',
|
|
|
|
'html',
|
|
|
|
],
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
parserOptions: {
|
|
|
|
ecmaVersion: 8,
|
|
|
|
sourceType: 'module',
|
|
|
|
ecmaFeatures: {
|
|
|
|
jsx: true,
|
|
|
|
},
|
|
|
|
},
|
2018-09-11 16:21:31 +02:00
|
|
|
env: { es6: true, node: true, 'jest/globals': true },
|
2017-10-04 00:20:18 +03:00
|
|
|
settings: {
|
|
|
|
'import/core-modules': ['enzyme'],
|
2017-12-28 04:38:46 +03:00
|
|
|
'import/ignore': ['node_modules\\/(?!@storybook)'],
|
2019-07-11 09:02:36 +09:00
|
|
|
'import/resolver': {
|
|
|
|
node: {
|
|
|
|
extensions: ['.js', '.ts', '.tsx', '.mjs', '.d.ts'],
|
|
|
|
paths: ['node_modules/', 'node_modules/@types/'],
|
|
|
|
},
|
|
|
|
},
|
2018-09-11 16:21:31 +02:00
|
|
|
'html/html-extensions': ['.html'],
|
2017-10-04 00:20:18 +03:00
|
|
|
},
|
2017-04-14 10:13:31 +02:00
|
|
|
rules: {
|
2019-05-20 11:47:50 +01:00
|
|
|
'no-restricted-imports': [
|
|
|
|
error,
|
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: 'lodash.isequal',
|
|
|
|
message:
|
|
|
|
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash.mergewith',
|
|
|
|
message:
|
|
|
|
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'lodash.pick',
|
|
|
|
message:
|
|
|
|
'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
// catch-all for any lodash modularised. The CVE is listed against the entire family for lodash < 4.17.11
|
|
|
|
patterns: ['lodash.*'],
|
|
|
|
},
|
|
|
|
],
|
2018-09-11 16:21:31 +02:00
|
|
|
'prettier/prettier': [warn],
|
2017-12-15 00:10:35 +01:00
|
|
|
'no-debugger': process.env.NODE_ENV === 'production' ? error : ignore,
|
2017-04-17 16:37:49 +02:00
|
|
|
'class-methods-use-this': ignore,
|
2017-06-06 13:18:33 +02:00
|
|
|
'import/extensions': [
|
2017-10-02 01:40:46 +03:00
|
|
|
error,
|
2018-02-17 21:27:49 +03:00
|
|
|
'always',
|
2017-06-06 13:18:33 +02:00
|
|
|
{
|
|
|
|
js: 'never',
|
2018-02-17 21:27:49 +03:00
|
|
|
ts: 'never',
|
2019-04-25 17:59:37 +02:00
|
|
|
tsx: 'never',
|
2018-11-25 01:26:54 +01:00
|
|
|
mjs: 'never',
|
2017-06-06 13:18:33 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/no-extraneous-dependencies': [
|
2017-08-18 04:35:25 +03:00
|
|
|
error,
|
2017-06-06 13:18:33 +02:00
|
|
|
{
|
|
|
|
devDependencies: [
|
2017-08-18 04:35:25 +03:00
|
|
|
'examples/**',
|
2018-10-13 18:39:23 +02:00
|
|
|
'examples-native/**',
|
2017-08-18 04:35:25 +03:00
|
|
|
'**/example/**',
|
|
|
|
'*.js',
|
2017-06-06 13:18:33 +02:00
|
|
|
'**/*.test.js',
|
2019-04-25 17:59:37 +02:00
|
|
|
'**/*.stories.*',
|
2017-06-06 13:18:33 +02:00
|
|
|
'**/scripts/*.js',
|
2017-11-18 14:20:34 +03:00
|
|
|
'**/stories/**/*.js',
|
|
|
|
'**/__tests__/**/*.js',
|
2019-04-25 17:59:37 +02:00
|
|
|
'**/.storybook/**/*.*',
|
2017-06-06 13:18:33 +02:00
|
|
|
],
|
|
|
|
peerDependencies: true,
|
|
|
|
},
|
|
|
|
],
|
2017-04-17 16:37:37 +02:00
|
|
|
'import/prefer-default-export': ignore,
|
2017-12-28 04:38:46 +03:00
|
|
|
'import/default': error,
|
|
|
|
'import/named': error,
|
|
|
|
'import/namespace': error,
|
2017-06-06 13:18:33 +02:00
|
|
|
'react/jsx-filename-extension': [
|
|
|
|
warn,
|
|
|
|
{
|
2018-12-08 14:29:37 +01:00
|
|
|
extensions: ['.js', '.jsx', '.tsx'],
|
2017-06-06 13:18:33 +02:00
|
|
|
},
|
|
|
|
],
|
2018-08-15 04:56:20 +02:00
|
|
|
'react/jsx-no-bind': [
|
|
|
|
error,
|
|
|
|
{
|
|
|
|
ignoreDOMComponents: true,
|
|
|
|
ignoreRefs: true,
|
|
|
|
allowArrowFunctions: true,
|
|
|
|
allowFunctions: true,
|
|
|
|
allowBind: true,
|
|
|
|
},
|
|
|
|
],
|
2018-12-29 16:15:00 +01:00
|
|
|
'jsx-a11y/accessible-emoji': ignore,
|
2018-08-15 04:56:20 +02:00
|
|
|
'jsx-a11y/label-has-associated-control': [
|
|
|
|
warn,
|
|
|
|
{
|
|
|
|
labelComponents: ['CustomInputLabel'],
|
|
|
|
labelAttributes: ['label'],
|
|
|
|
controlComponents: ['CustomInput'],
|
|
|
|
depth: 3,
|
|
|
|
},
|
|
|
|
],
|
2018-02-17 21:27:49 +03:00
|
|
|
'react/no-unescaped-entities': ignore,
|
2018-09-11 16:21:31 +02:00
|
|
|
'jsx-a11y/label-has-for': [error, { required: { some: ['nesting', 'id'] } }],
|
2018-02-17 22:33:31 +03:00
|
|
|
'jsx-a11y/anchor-is-valid': [
|
|
|
|
error,
|
|
|
|
{
|
2018-12-24 17:21:53 +01:00
|
|
|
components: ['A', 'LinkTo', 'Link'],
|
2018-02-17 22:33:31 +03:00
|
|
|
specialLink: ['overrideParams', 'kind', 'story', 'to'],
|
|
|
|
},
|
|
|
|
],
|
2018-02-23 12:00:38 +11:00
|
|
|
'no-underscore-dangle': [
|
|
|
|
error,
|
2019-06-19 22:15:11 +02:00
|
|
|
{
|
|
|
|
allow: [
|
|
|
|
'__STORYBOOK_CLIENT_API__',
|
|
|
|
'__STORYBOOK_ADDONS_CHANNEL__',
|
|
|
|
'__STORYBOOK_STORY_STORE__',
|
|
|
|
],
|
|
|
|
},
|
2018-02-23 12:00:38 +11:00
|
|
|
],
|
2019-04-25 17:59:37 +02:00
|
|
|
'@typescript-eslint/no-var-requires': ignore,
|
|
|
|
'@typescript-eslint/camelcase': ignore,
|
|
|
|
'@typescript-eslint/no-unused-vars': ignore,
|
|
|
|
'@typescript-eslint/explicit-member-accessibility': ignore,
|
|
|
|
'@typescript-eslint/explicit-function-return-type': ignore,
|
|
|
|
'@typescript-eslint/no-explicit-any': ignore, // would prefer to enable this
|
|
|
|
'@typescript-eslint/no-use-before-define': ignore, // this is duplicated
|
|
|
|
'@typescript-eslint/interface-name-prefix': ignore, // I don't agree
|
2017-04-14 09:26:27 +02:00
|
|
|
},
|
2018-02-17 22:33:31 +03:00
|
|
|
overrides: [
|
2018-11-19 17:21:53 +01:00
|
|
|
{
|
2019-04-05 04:58:14 +02:00
|
|
|
files: [
|
|
|
|
'**/__tests__/**',
|
2019-04-25 17:59:37 +02:00
|
|
|
'**/*.test.*',
|
|
|
|
'**/*.stories.*',
|
2019-04-05 04:58:14 +02:00
|
|
|
'**/storyshots/**/stories/**',
|
|
|
|
'docs/src/new-components/lib/StoryLinkWrapper.js',
|
|
|
|
'docs/src/stories/**',
|
|
|
|
],
|
2018-11-19 17:21:53 +01:00
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': ignore,
|
|
|
|
},
|
|
|
|
},
|
2018-09-11 16:21:31 +02:00
|
|
|
{ files: '**/.storybook/config.js', rules: { 'global-require': ignore } },
|
2019-04-25 17:59:37 +02:00
|
|
|
{
|
|
|
|
files: ['**/*.stories.*'],
|
|
|
|
rules: {
|
|
|
|
'no-console': ignore,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['**/*.tsx', '**/*.ts'],
|
|
|
|
rules: {
|
|
|
|
'react/prop-types': ignore, // we should use types
|
|
|
|
'no-dupe-class-members': ignore, // this is called overloads in typescript
|
|
|
|
},
|
|
|
|
},
|
2019-04-25 23:59:40 +02:00
|
|
|
{
|
|
|
|
files: ['**/*.d.ts'],
|
|
|
|
rules: {
|
2019-04-26 16:07:13 +02:00
|
|
|
'vars-on-top': ignore,
|
2019-04-25 23:59:40 +02:00
|
|
|
'no-var': ignore, // this is how typescript works
|
2019-04-26 09:53:13 +02:00
|
|
|
'spaced-comment': ignore,
|
2019-04-25 23:59:40 +02:00
|
|
|
},
|
|
|
|
},
|
2018-02-17 22:33:31 +03:00
|
|
|
],
|
2017-06-06 13:18:33 +02:00
|
|
|
};
|