diff --git a/.eslintrc.js b/.eslintrc.js index 3d136069d31..7c47fb0b89d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,6 +18,12 @@ module.exports = { react: { version: 'detect', }, + '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 + }, + }, }, extends: [ 'eslint:recommended', @@ -37,7 +43,7 @@ module.exports = { ecmaVersion: 2018, sourceType: 'module', }, - plugins: ['prettier', 'react', 'cypress', '@typescript-eslint', 'no-only-tests', 'jest', 'compat'], + plugins: ['prettier', 'react', 'cypress', '@typescript-eslint', 'no-only-tests', 'jest', 'compat', 'posthog'], rules: { 'no-console': ['error', { allow: ['warn', 'error'] }], 'no-debugger': 'error', @@ -91,7 +97,7 @@ module.exports = { ], }, ], - 'react/forbid-elements': [ + 'posthog/warn-elements': [ 1, { forbid: [ @@ -236,6 +242,16 @@ module.exports = { '@typescript-eslint/no-var-requires': 'off', }, }, + { + files: 'eslint-rules/**/*', + extends: ['eslint:recommended'], + rules: { + '@typescript-eslint/no-var-requires': 'off', + }, + env: { + node: true, + }, + }, ], reportUnusedDisableDirectives: true, } diff --git a/eslint-rules/README.md b/eslint-rules/README.md new file mode 100644 index 00000000000..9d1d8c06672 --- /dev/null +++ b/eslint-rules/README.md @@ -0,0 +1,3 @@ +# PostHog Custom ESLint rules + +This package contains custom ESLint rules for PostHog's codebase. diff --git a/eslint-rules/index.js b/eslint-rules/index.js new file mode 100644 index 00000000000..61e49e1b8c3 --- /dev/null +++ b/eslint-rules/index.js @@ -0,0 +1,10 @@ +const { readdirSync } = require('fs') +const { basename } = require('path') + +const ruleFiles = readdirSync('eslint-rules').filter( + (file) => file.endsWith('.js') && file !== 'index.js' && !file.endsWith('test.js') +) + +const rules = Object.fromEntries(ruleFiles.map((file) => [basename(file, '.js'), require('./' + file)])) + +module.exports = { rules } diff --git a/eslint-rules/warn-elements.js b/eslint-rules/warn-elements.js new file mode 100644 index 00000000000..4013d6090e4 --- /dev/null +++ b/eslint-rules/warn-elements.js @@ -0,0 +1,3 @@ +const { rules } = require('eslint-plugin-react') + +module.exports = rules['forbid-elements'] diff --git a/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-breakdown-edit--webkit.png b/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-breakdown-edit--webkit.png index bc79f804ca5..6db5ed04bf6 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-breakdown-edit--webkit.png and b/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-breakdown-edit--webkit.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-edit--webkit.png b/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-edit--webkit.png index 118d11b614a..8d7d747f899 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-edit--webkit.png and b/frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-edit--webkit.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--webkit.png b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--webkit.png index 5f8f362dc80..192aee10588 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--webkit.png and b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--webkit.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--webkit.png b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--webkit.png index 73a6ac1fbc6..1158f400a0d 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--webkit.png and b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--webkit.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--user-paths-edit--webkit.png b/frontend/__snapshots__/scenes-app-insights--user-paths-edit--webkit.png index 25086a8cbda..aa0201c92e8 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--user-paths-edit--webkit.png and b/frontend/__snapshots__/scenes-app-insights--user-paths-edit--webkit.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--user-paths-edit.png b/frontend/__snapshots__/scenes-app-insights--user-paths-edit.png index 1c01944a7c9..df710f4dd46 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--user-paths-edit.png and b/frontend/__snapshots__/scenes-app-insights--user-paths-edit.png differ diff --git a/frontend/src/lib/components/PayGateMini/PayGateMini.tsx b/frontend/src/lib/components/PayGateMini/PayGateMini.tsx index 477fda2461d..6c02869d746 100644 --- a/frontend/src/lib/components/PayGateMini/PayGateMini.tsx +++ b/frontend/src/lib/components/PayGateMini/PayGateMini.tsx @@ -120,12 +120,12 @@ export function PayGateMini({
{featureSummary.icon || }
{featureSummary.description}
- Subscribe to gain {featureSummary.umbrella}. + Subscribe to gain {featureSummary.umbrella}. {featureSummary.docsHref && ( <> {' '} - Learn more in PostHog Docs. + Learn more in PostHog Docs. )} diff --git a/package.json b/package.json index e98ba7d7b16..85796f23468 100644 --- a/package.json +++ b/package.json @@ -248,6 +248,7 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-jest": "^27.4.3", "eslint-plugin-no-only-tests": "^3.1.0", + "eslint-plugin-posthog": "link:./eslint-rules", "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-react": "^7.33.2", "eslint-plugin-storybook": "^0.6.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43ab2cbe9a5..ba38929ba6f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -546,6 +546,9 @@ devDependencies: eslint-plugin-no-only-tests: specifier: ^3.1.0 version: 3.1.0 + eslint-plugin-posthog: + specifier: link:./eslint-rules + version: link:eslint-rules eslint-plugin-prettier: specifier: ^5.0.1 version: 5.0.1(eslint-config-prettier@9.0.0)(eslint@8.52.0)(prettier@2.8.8)