2022-03-08 14:17:59 +01:00
|
|
|
/* global module */
|
2023-08-21 14:28:29 +02:00
|
|
|
|
|
|
|
const env = {
|
|
|
|
browser: true,
|
|
|
|
es6: true,
|
|
|
|
'cypress/globals': true,
|
|
|
|
}
|
|
|
|
|
|
|
|
const globals = {
|
|
|
|
Atomics: 'readonly',
|
|
|
|
SharedArrayBuffer: 'readonly',
|
|
|
|
}
|
|
|
|
|
2020-05-13 14:17:00 +02:00
|
|
|
module.exports = {
|
2021-11-04 23:03:28 +01:00
|
|
|
ignorePatterns: ['node_modules', 'plugin-server'],
|
2023-08-21 14:28:29 +02:00
|
|
|
env,
|
2020-05-13 14:17:00 +02:00
|
|
|
settings: {
|
|
|
|
react: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
2023-10-26 13:11:38 +02:00
|
|
|
'import/resolver': {
|
|
|
|
node: {
|
|
|
|
paths: ['eslint-rules'], // Add the directory containing your custom rules
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Ensure ESLint resolves both JS and TS files
|
|
|
|
},
|
|
|
|
},
|
2020-05-13 14:17:00 +02:00
|
|
|
},
|
2022-03-08 14:17:59 +01:00
|
|
|
extends: [
|
2023-08-21 14:28:29 +02:00
|
|
|
'eslint:recommended',
|
2022-03-08 14:17:59 +01:00
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
'plugin:react/recommended',
|
2022-05-25 16:38:44 +02:00
|
|
|
'plugin:eslint-comments/recommended',
|
2022-03-08 14:17:59 +01:00
|
|
|
'plugin:storybook/recommended',
|
2022-05-25 16:38:44 +02:00
|
|
|
'prettier',
|
2023-09-19 17:19:48 +02:00
|
|
|
'plugin:compat/recommended',
|
2022-03-08 14:17:59 +01:00
|
|
|
],
|
2023-08-21 14:28:29 +02:00
|
|
|
globals,
|
2020-07-17 19:57:42 +02:00
|
|
|
parser: '@typescript-eslint/parser',
|
2020-05-13 14:17:00 +02:00
|
|
|
parserOptions: {
|
|
|
|
ecmaFeatures: {
|
|
|
|
jsx: true,
|
|
|
|
},
|
2020-07-28 22:25:24 +02:00
|
|
|
ecmaVersion: 2018,
|
|
|
|
sourceType: 'module',
|
2020-05-13 14:17:00 +02:00
|
|
|
},
|
2023-10-26 13:11:38 +02:00
|
|
|
plugins: ['prettier', 'react', 'cypress', '@typescript-eslint', 'no-only-tests', 'jest', 'compat', 'posthog'],
|
2020-05-13 14:17:00 +02:00
|
|
|
rules: {
|
2023-07-27 11:51:29 +02:00
|
|
|
'no-console': ['error', { allow: ['warn', 'error'] }],
|
2023-05-11 11:01:27 +02:00
|
|
|
'no-debugger': 'error',
|
2022-08-04 15:14:11 +02:00
|
|
|
'no-only-tests/no-only-tests': 'error',
|
2020-05-13 14:17:00 +02:00
|
|
|
'react/prop-types': [0],
|
2022-10-17 19:30:31 +02:00
|
|
|
'react/react-in-jsx-scope': [0],
|
2020-05-13 14:17:00 +02:00
|
|
|
'react/no-unescaped-entities': [0],
|
2020-08-27 14:34:11 +02:00
|
|
|
'react/jsx-no-target-blank': [0],
|
2020-10-26 11:45:57 +01:00
|
|
|
'react/self-closing-comp': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
component: true,
|
|
|
|
html: true,
|
|
|
|
},
|
|
|
|
],
|
2022-05-25 16:38:44 +02:00
|
|
|
'no-unused-vars': 'off',
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
2022-03-08 14:17:59 +01:00
|
|
|
'error',
|
|
|
|
{
|
|
|
|
ignoreRestSiblings: true,
|
|
|
|
},
|
|
|
|
],
|
2022-05-25 16:38:44 +02:00
|
|
|
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
2020-07-08 09:45:23 +02:00
|
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
|
|
'@typescript-eslint/no-empty-function': 'off',
|
2020-07-28 22:25:24 +02:00
|
|
|
'@typescript-eslint/no-inferrable-types': 'off',
|
2021-02-09 18:11:53 +01:00
|
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
2021-07-01 04:27:36 +02:00
|
|
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
2020-11-25 17:46:49 +01:00
|
|
|
curly: 'error',
|
2022-01-20 13:13:29 +01:00
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: 'dayjs',
|
|
|
|
message: 'Do not directly import dayjs. Only import the dayjs exported from lib/dayjs.',
|
|
|
|
},
|
2023-11-08 23:08:18 +01:00
|
|
|
{
|
|
|
|
name: '@ant-design/icons',
|
|
|
|
message: 'Please use icons from the @posthog/icons package instead',
|
|
|
|
},
|
2022-01-20 13:13:29 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-08-02 10:49:06 +02:00
|
|
|
'react/forbid-dom-props': [
|
2023-11-07 15:46:03 +01:00
|
|
|
'warn',
|
2022-08-02 10:49:06 +02:00
|
|
|
{
|
|
|
|
forbid: [
|
|
|
|
{
|
|
|
|
propName: 'style',
|
|
|
|
message:
|
|
|
|
'style should be avoided in favor of utility CSS classes - see https://storybook.posthog.net/?path=/docs/lemon-ui-utilities--overview',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-10-26 13:11:38 +02:00
|
|
|
'posthog/warn-elements': [
|
2023-11-07 15:46:03 +01:00
|
|
|
'warn',
|
2022-08-02 10:49:06 +02:00
|
|
|
{
|
|
|
|
forbid: [
|
|
|
|
{
|
|
|
|
element: 'Row',
|
|
|
|
message:
|
2023-01-12 12:37:17 +01:00
|
|
|
'use flex utility classes instead, e.g. <Row align="middle"> could be <div className="flex items-center">',
|
2022-08-02 10:49:06 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'Col',
|
2023-01-12 12:37:17 +01:00
|
|
|
message: 'use flex utility classes instead - most of the time can simply be a plain <div>',
|
|
|
|
},
|
2023-08-04 15:49:45 +02:00
|
|
|
{
|
|
|
|
element: 'Divider',
|
|
|
|
message: 'use <LemonDivider> instead',
|
|
|
|
},
|
2023-01-12 12:37:17 +01:00
|
|
|
{
|
|
|
|
element: 'Card',
|
|
|
|
message: 'use utility classes instead',
|
2022-08-02 10:49:06 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'Button',
|
|
|
|
message: 'use <LemonButton> instead',
|
|
|
|
},
|
2022-08-16 11:07:50 +02:00
|
|
|
{
|
|
|
|
element: 'Input',
|
|
|
|
message: 'use <LemonInput> instead',
|
|
|
|
},
|
2022-09-08 15:54:00 +02:00
|
|
|
{
|
|
|
|
element: 'Skeleton',
|
|
|
|
message: 'use <LemonSkeleton> instead',
|
|
|
|
},
|
2023-02-13 17:13:07 +01:00
|
|
|
{
|
2023-08-04 15:49:45 +02:00
|
|
|
element: 'Modal',
|
|
|
|
message: 'use <LemonModal> or `<LemonDialog> instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'Select',
|
|
|
|
message: 'use <LemonSelect> instead',
|
2023-02-13 17:13:07 +01:00
|
|
|
},
|
2023-11-03 11:22:19 +01:00
|
|
|
{
|
|
|
|
element: 'LemonButtonWithDropdown',
|
|
|
|
message: 'use <LemonMenu> with a <LemonButton> child instead',
|
|
|
|
},
|
2022-08-02 10:49:06 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-01-12 12:37:17 +01:00
|
|
|
'react/forbid-elements': [
|
2023-11-07 15:46:03 +01:00
|
|
|
'error',
|
2023-01-12 12:37:17 +01:00
|
|
|
{
|
|
|
|
forbid: [
|
|
|
|
{
|
|
|
|
element: 'Layout',
|
|
|
|
message: 'use utility classes instead',
|
|
|
|
},
|
2023-08-04 15:49:45 +02:00
|
|
|
{
|
|
|
|
element: 'Tabs',
|
|
|
|
message: 'use <LemonTabs> instead',
|
|
|
|
},
|
2023-11-06 16:58:08 +01:00
|
|
|
{
|
|
|
|
element: 'Space',
|
|
|
|
message: 'use flex or space utility classes instead',
|
|
|
|
},
|
2023-01-12 12:37:17 +01:00
|
|
|
{
|
|
|
|
element: 'Spin',
|
|
|
|
message: 'use Spinner instead',
|
|
|
|
},
|
2023-01-18 15:50:51 +01:00
|
|
|
{
|
|
|
|
element: 'Badge',
|
|
|
|
message: 'use LemonBadge instead',
|
|
|
|
},
|
2023-03-10 15:55:26 +01:00
|
|
|
{
|
|
|
|
element: 'Collapse',
|
|
|
|
message: 'use <LemonCollapse> instead',
|
|
|
|
},
|
2023-11-06 14:38:55 +01:00
|
|
|
{
|
|
|
|
element: 'Checkbox',
|
|
|
|
message: 'use <LemonCheckbox> instead',
|
|
|
|
},
|
2023-08-29 09:28:03 +02:00
|
|
|
{
|
2023-09-18 12:16:33 +02:00
|
|
|
element: 'MonacoEditor',
|
2023-08-29 09:28:03 +02:00
|
|
|
message: 'use <CodeEditor> instead',
|
2023-09-18 12:16:33 +02:00
|
|
|
},
|
2023-10-04 15:32:49 +02:00
|
|
|
{
|
|
|
|
element: 'Typography',
|
|
|
|
message: 'use utility classes instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'Input.TextArea',
|
|
|
|
message: 'use <LemonTextArea> instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: 'ReactMarkdown',
|
|
|
|
message: 'use <LemonMarkdown> instead',
|
|
|
|
},
|
2023-11-02 10:35:10 +01:00
|
|
|
{
|
|
|
|
element: 'a',
|
|
|
|
message: 'use <Link> instead',
|
|
|
|
},
|
2023-01-12 12:37:17 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-11-07 15:46:03 +01:00
|
|
|
'no-constant-condition': 'off',
|
|
|
|
'no-prototype-builtins': 'off',
|
|
|
|
'no-irregular-whitespace': 'off',
|
2020-05-13 14:17:00 +02:00
|
|
|
},
|
2020-07-08 09:45:23 +02:00
|
|
|
overrides: [
|
2023-08-21 14:28:29 +02:00
|
|
|
{
|
|
|
|
files: ['**/test/**/*', '**/*.test.*'],
|
|
|
|
env: {
|
|
|
|
...env,
|
|
|
|
node: true,
|
|
|
|
'jest/globals': true,
|
|
|
|
},
|
|
|
|
globals: {
|
|
|
|
...globals,
|
|
|
|
given: 'readonly',
|
|
|
|
},
|
|
|
|
},
|
2020-07-28 22:25:24 +02:00
|
|
|
{
|
2023-01-12 12:37:17 +01:00
|
|
|
// disable these rules for files generated by kea-typegen
|
2020-07-28 22:25:24 +02:00
|
|
|
files: ['*Type.ts', '*Type.tsx'],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-explicit-any': ['off'],
|
|
|
|
'@typescript-eslint/ban-types': ['off'],
|
|
|
|
},
|
|
|
|
},
|
2020-07-08 09:45:23 +02:00
|
|
|
{
|
|
|
|
// enable the rule specifically for TypeScript files
|
|
|
|
files: ['*.ts', '*.tsx'],
|
|
|
|
rules: {
|
2020-07-28 22:25:24 +02:00
|
|
|
'@typescript-eslint/no-explicit-any': ['off'],
|
|
|
|
'@typescript-eslint/explicit-function-return-type': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
allowExpressions: true,
|
|
|
|
},
|
|
|
|
],
|
2020-10-14 10:42:06 +02:00
|
|
|
'@typescript-eslint/explicit-module-boundary-types': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
allowArgumentsExplicitlyTypedAsAny: true,
|
|
|
|
},
|
|
|
|
],
|
2020-07-08 09:45:23 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['*.js'],
|
|
|
|
rules: {
|
2021-01-13 00:46:59 +01:00
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
2020-07-08 09:45:23 +02:00
|
|
|
},
|
|
|
|
},
|
2023-10-26 13:11:38 +02:00
|
|
|
{
|
|
|
|
files: 'eslint-rules/**/*',
|
|
|
|
extends: ['eslint:recommended'],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-var-requires': 'off',
|
|
|
|
},
|
|
|
|
env: {
|
|
|
|
node: true,
|
|
|
|
},
|
|
|
|
},
|
2020-07-08 09:45:23 +02:00
|
|
|
],
|
2022-05-25 16:38:44 +02:00
|
|
|
reportUnusedDisableDirectives: true,
|
2020-05-13 14:17:00 +02:00
|
|
|
}
|