From 248ab1e8af68af3798ef4e9c40838f95e78ac051 Mon Sep 17 00:00:00 2001 From: Ryan Wilson-Perkin Date: Tue, 23 Jul 2024 13:52:14 -0400 Subject: [PATCH] Separate out plugin.js to avoid circular import --- packages/eslint-plugin/index.js | 37 ++------------------ packages/eslint-plugin/lib/config/core.js | 2 +- packages/eslint-plugin/lib/config/jest.js | 2 +- packages/eslint-plugin/lib/config/polaris.js | 2 +- packages/eslint-plugin/lib/config/react.js | 2 +- packages/eslint-plugin/plugin.js | 37 ++++++++++++++++++++ 6 files changed, 43 insertions(+), 39 deletions(-) create mode 100644 packages/eslint-plugin/plugin.js diff --git a/packages/eslint-plugin/index.js b/packages/eslint-plugin/index.js index bab6399c..6e3d4af1 100644 --- a/packages/eslint-plugin/index.js +++ b/packages/eslint-plugin/index.js @@ -1,39 +1,6 @@ module.exports = { - rules: { - 'binary-assignment-parens': require('./lib/rules/binary-assignment-parens'), - 'class-property-semi': require('./lib/rules/class-property-semi'), - 'images-no-direct-imports': require('./lib/rules/images-no-direct-imports'), - 'jest-no-all-mocks-methods': require('./lib/rules/jest/no-all-mocks-methods'), - 'jest-no-snapshots': require('./lib/rules/jest/no-snapshots'), - 'jsx-no-complex-expressions': require('./lib/rules/jsx-no-complex-expressions'), - 'jsx-no-hardcoded-content': require('./lib/rules/jsx-no-hardcoded-content'), - 'jsx-prefer-fragment-wrappers': require('./lib/rules/jsx-prefer-fragment-wrappers'), - 'no-ancestor-directory-import': require('./lib/rules/no-ancestor-directory-import'), - 'no-debugger': require('./lib/rules/no-debugger'), - 'no-namespace-imports': require('./lib/rules/no-namespace-imports'), - 'no-useless-computed-properties': require('./lib/rules/no-useless-computed-properties'), - 'no-fully-static-classes': require('./lib/rules/no-fully-static-classes'), - 'polaris-prefer-sectioned-prop': require('./lib/rules/polaris-prefer-sectioned-prop'), - 'polaris-no-bare-stack-item': require('./lib/rules/polaris-no-bare-stack-item'), - 'prefer-class-properties': require('./lib/rules/prefer-class-properties'), - 'prefer-early-return': require('./lib/rules/prefer-early-return'), - 'prefer-module-scope-constants': require('./lib/rules/prefer-module-scope-constants'), - 'prefer-twine': require('./lib/rules/prefer-twine'), - 'react-hooks-strict-return': require('./lib/rules/react-hooks-strict-return'), - 'react-initialize-state': require('./lib/rules/react-initialize-state'), - 'react-no-multiple-render-methods': require('./lib/rules/react-no-multiple-render-methods'), - 'react-prefer-private-members': require('./lib/rules/react-prefer-private-members'), - 'react-require-autocomplete': require('./lib/rules/react-require-autocomplete'), - 'react-type-state': require('./lib/rules/react-type-state'), - 'restrict-full-import': require('./lib/rules/restrict-full-import'), - 'sinon-no-restricted-features': require('./lib/rules/sinon-no-restricted-features'), - 'sinon-prefer-meaningful-assertions': require('./lib/rules/sinon-prefer-meaningful-assertions'), - 'strict-component-boundaries': require('./lib/rules/strict-component-boundaries'), - 'typescript-prefer-pascal-case-enums': require('./lib/rules/typescript/prefer-pascal-case-enums'), - 'typescript-prefer-singular-enums': require('./lib/rules/typescript/prefer-singular-enums'), - 'typescript-prefer-build-client-schema': require('./lib/rules/typescript/prefer-build-client-schema'), - 'webpack-no-unnamed-dynamic-imports': require('./lib/rules/webpack/no-unnamed-dynamic-imports'), - }, + // Imported separately to allow configs to reference it and avoid circular reference + ...require('./plugin'), configs: { // Core configs - When extending, one of these should go first diff --git a/packages/eslint-plugin/lib/config/core.js b/packages/eslint-plugin/lib/config/core.js index c7d9f322..8a0bfc24 100644 --- a/packages/eslint-plugin/lib/config/core.js +++ b/packages/eslint-plugin/lib/config/core.js @@ -1,6 +1,6 @@ const eslintCommentsPlugin = require('eslint-plugin-eslint-comments'); -const shopifyPlugin = require('../..'); +const shopifyPlugin = require('../../plugin'); module.exports = [ { diff --git a/packages/eslint-plugin/lib/config/jest.js b/packages/eslint-plugin/lib/config/jest.js index d06b0b07..9eeb0dfa 100644 --- a/packages/eslint-plugin/lib/config/jest.js +++ b/packages/eslint-plugin/lib/config/jest.js @@ -2,7 +2,7 @@ const globals = require('globals'); const jestPlugin = require('eslint-plugin-jest'); const jestFormattingPlugin = require('eslint-plugin-jest-formatting'); -const shopifyPlugin = require('../..'); +const shopifyPlugin = require('../../plugin'); module.exports = [ { diff --git a/packages/eslint-plugin/lib/config/polaris.js b/packages/eslint-plugin/lib/config/polaris.js index 06401920..6ade47b0 100644 --- a/packages/eslint-plugin/lib/config/polaris.js +++ b/packages/eslint-plugin/lib/config/polaris.js @@ -1,4 +1,4 @@ -const shopifyPlugin = require('../..'); +const shopifyPlugin = require('../../plugin'); module.exports = [ { diff --git a/packages/eslint-plugin/lib/config/react.js b/packages/eslint-plugin/lib/config/react.js index 0adbe6ef..142ba522 100644 --- a/packages/eslint-plugin/lib/config/react.js +++ b/packages/eslint-plugin/lib/config/react.js @@ -3,7 +3,7 @@ const reactPlugin = require('eslint-plugin-react'); const reactHooksPlugin = require('eslint-plugin-react-hooks'); const jsxA11yPlugin = require('eslint-plugin-jsx-a11y'); -const shopifyPlugin = require('../..'); +const shopifyPlugin = require('../../plugin'); module.exports = [ { diff --git a/packages/eslint-plugin/plugin.js b/packages/eslint-plugin/plugin.js new file mode 100644 index 00000000..6411fc91 --- /dev/null +++ b/packages/eslint-plugin/plugin.js @@ -0,0 +1,37 @@ +module.exports = { + rules: { + 'binary-assignment-parens': require('./lib/rules/binary-assignment-parens'), + 'class-property-semi': require('./lib/rules/class-property-semi'), + 'images-no-direct-imports': require('./lib/rules/images-no-direct-imports'), + 'jest-no-all-mocks-methods': require('./lib/rules/jest/no-all-mocks-methods'), + 'jest-no-snapshots': require('./lib/rules/jest/no-snapshots'), + 'jsx-no-complex-expressions': require('./lib/rules/jsx-no-complex-expressions'), + 'jsx-no-hardcoded-content': require('./lib/rules/jsx-no-hardcoded-content'), + 'jsx-prefer-fragment-wrappers': require('./lib/rules/jsx-prefer-fragment-wrappers'), + 'no-ancestor-directory-import': require('./lib/rules/no-ancestor-directory-import'), + 'no-debugger': require('./lib/rules/no-debugger'), + 'no-namespace-imports': require('./lib/rules/no-namespace-imports'), + 'no-useless-computed-properties': require('./lib/rules/no-useless-computed-properties'), + 'no-fully-static-classes': require('./lib/rules/no-fully-static-classes'), + 'polaris-prefer-sectioned-prop': require('./lib/rules/polaris-prefer-sectioned-prop'), + 'polaris-no-bare-stack-item': require('./lib/rules/polaris-no-bare-stack-item'), + 'prefer-class-properties': require('./lib/rules/prefer-class-properties'), + 'prefer-early-return': require('./lib/rules/prefer-early-return'), + 'prefer-module-scope-constants': require('./lib/rules/prefer-module-scope-constants'), + 'prefer-twine': require('./lib/rules/prefer-twine'), + 'react-hooks-strict-return': require('./lib/rules/react-hooks-strict-return'), + 'react-initialize-state': require('./lib/rules/react-initialize-state'), + 'react-no-multiple-render-methods': require('./lib/rules/react-no-multiple-render-methods'), + 'react-prefer-private-members': require('./lib/rules/react-prefer-private-members'), + 'react-require-autocomplete': require('./lib/rules/react-require-autocomplete'), + 'react-type-state': require('./lib/rules/react-type-state'), + 'restrict-full-import': require('./lib/rules/restrict-full-import'), + 'sinon-no-restricted-features': require('./lib/rules/sinon-no-restricted-features'), + 'sinon-prefer-meaningful-assertions': require('./lib/rules/sinon-prefer-meaningful-assertions'), + 'strict-component-boundaries': require('./lib/rules/strict-component-boundaries'), + 'typescript-prefer-pascal-case-enums': require('./lib/rules/typescript/prefer-pascal-case-enums'), + 'typescript-prefer-singular-enums': require('./lib/rules/typescript/prefer-singular-enums'), + 'typescript-prefer-build-client-schema': require('./lib/rules/typescript/prefer-build-client-schema'), + 'webpack-no-unnamed-dynamic-imports': require('./lib/rules/webpack/no-unnamed-dynamic-imports'), + }, +};