diff --git a/eslint-rules/index.js b/eslint-rules/index.js new file mode 100644 index 0000000000000..61e49e1b8c393 --- /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/index.ts b/eslint-rules/index.ts deleted file mode 100644 index d7d16dfce1dea..0000000000000 --- a/eslint-rules/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { readdirSync } from 'fs' -import { basename } from 'path' - -const projectName = 'posthog' - -const ruleFiles = readdirSync('eslint-rules').filter( - (file) => file.endsWith('.ts') && file !== 'index.ts' && !file.endsWith('test.ts') -) - -const rules = Object.fromEntries(ruleFiles.map((file) => [basename(file, '.ts'), require('./' + file)])) - -module.exports = { rules } diff --git a/eslint-rules/warn-elements.js b/eslint-rules/warn-elements.js new file mode 100644 index 0000000000000..4013d6090e4a1 --- /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/eslint-rules/warn-elements.ts b/eslint-rules/warn-elements.ts deleted file mode 100644 index 222c0f2c8ab57..0000000000000 --- a/eslint-rules/warn-elements.ts +++ /dev/null @@ -1,3 +0,0 @@ -const eslint = require('eslint') - -module.exports = new eslint.Linter().getRules().get('react/forbid-elements') diff --git a/package.json b/package.json index 699370d85cc67..c20dbbda7c9d7 100644 --- a/package.json +++ b/package.json @@ -248,7 +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-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 bb346e5adcc0e..f2790364ab610 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -547,7 +547,7 @@ devDependencies: specifier: ^3.1.0 version: 3.1.0 eslint-plugin-posthog: - specifier: link:eslint-rules + specifier: link:./eslint-rules version: link:eslint-rules eslint-plugin-prettier: specifier: ^5.0.1