@codyswann/lisa 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +867 -0
- package/all/copy-overwrite/.claude/README.md +205 -0
- package/all/copy-overwrite/.claude/agents/agent-architect.md +311 -0
- package/all/copy-overwrite/.claude/agents/codebase-analyzer.md +146 -0
- package/all/copy-overwrite/.claude/agents/codebase-locator.md +125 -0
- package/all/copy-overwrite/.claude/agents/codebase-pattern-finder.md +237 -0
- package/all/copy-overwrite/.claude/agents/git-history-analyzer.md +183 -0
- package/all/copy-overwrite/.claude/agents/hooks-expert.md +74 -0
- package/all/copy-overwrite/.claude/agents/skill-evaluator.md +246 -0
- package/all/copy-overwrite/.claude/agents/slash-command-architect.md +87 -0
- package/all/copy-overwrite/.claude/agents/web-search-researcher.md +112 -0
- package/all/copy-overwrite/.claude/commands/git/commit-and-submit-pr.md +8 -0
- package/all/copy-overwrite/.claude/commands/git/commit.md +44 -0
- package/all/copy-overwrite/.claude/commands/git/prune.md +34 -0
- package/all/copy-overwrite/.claude/commands/git/submit-pr.md +50 -0
- package/all/copy-overwrite/.claude/commands/jira/create.md +50 -0
- package/all/copy-overwrite/.claude/commands/jira/verify.md +34 -0
- package/all/copy-overwrite/.claude/commands/project/archive.md +8 -0
- package/all/copy-overwrite/.claude/commands/project/bootstrap.md +49 -0
- package/all/copy-overwrite/.claude/commands/project/complete-task.md +7 -0
- package/all/copy-overwrite/.claude/commands/project/debrief.md +65 -0
- package/all/copy-overwrite/.claude/commands/project/execute.md +94 -0
- package/all/copy-overwrite/.claude/commands/project/implement.md +42 -0
- package/all/copy-overwrite/.claude/commands/project/local-code-review.md +88 -0
- package/all/copy-overwrite/.claude/commands/project/lower-code-complexity.md +74 -0
- package/all/copy-overwrite/.claude/commands/project/plan.md +314 -0
- package/all/copy-overwrite/.claude/commands/project/research.md +248 -0
- package/all/copy-overwrite/.claude/commands/project/review.md +63 -0
- package/all/copy-overwrite/.claude/commands/project/setup.md +19 -0
- package/all/copy-overwrite/.claude/commands/project/verify.md +38 -0
- package/all/copy-overwrite/.claude/commands/pull-request/review.md +12 -0
- package/all/copy-overwrite/.claude/commands/rules/format-md.md +72 -0
- package/all/copy-overwrite/.claude/commands/sonarqube/check.md +6 -0
- package/all/copy-overwrite/.claude/commands/sonarqube/fix.md +3 -0
- package/all/copy-overwrite/.claude/hooks/README.md +301 -0
- package/all/copy-overwrite/.claude/hooks/notify-ntfy.sh +181 -0
- package/all/copy-overwrite/.claude/settings.json +41 -0
- package/all/copy-overwrite/.claude/settings.local.json.example +14 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/SKILL.md +405 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/function-structure.md +416 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/immutable-patterns.md +316 -0
- package/all/copy-overwrite/.claude/skills/prompt-complexity-scorer/SKILL.md +118 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/LICENSE.txt +202 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/SKILL.md +210 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/init_skill.py +303 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/all/copy-overwrite/CLAUDE.md +77 -0
- package/all/copy-overwrite/HUMAN.md +17 -0
- package/all/copy-overwrite/specs/.keep +0 -0
- package/all/create-only/PROJECT_RULES.md +0 -0
- package/cdk/merge/package.json +20 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +107 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/prompts.d.ts +45 -0
- package/dist/cli/prompts.d.ts.map +1 -0
- package/dist/cli/prompts.js +58 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/core/config.d.ts +73 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +36 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lisa.d.ts +81 -0
- package/dist/core/lisa.d.ts.map +1 -0
- package/dist/core/lisa.js +459 -0
- package/dist/core/lisa.js.map +1 -0
- package/dist/core/manifest.d.ts +58 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +104 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/detection/detector.interface.d.ts +15 -0
- package/dist/detection/detector.interface.d.ts.map +1 -0
- package/dist/detection/detector.interface.js +2 -0
- package/dist/detection/detector.interface.js.map +1 -0
- package/dist/detection/detectors/cdk.d.ts +10 -0
- package/dist/detection/detectors/cdk.d.ts.map +1 -0
- package/dist/detection/detectors/cdk.js +34 -0
- package/dist/detection/detectors/cdk.js.map +1 -0
- package/dist/detection/detectors/expo.d.ts +10 -0
- package/dist/detection/detectors/expo.d.ts.map +1 -0
- package/dist/detection/detectors/expo.js +30 -0
- package/dist/detection/detectors/expo.js.map +1 -0
- package/dist/detection/detectors/nestjs.d.ts +10 -0
- package/dist/detection/detectors/nestjs.d.ts.map +1 -0
- package/dist/detection/detectors/nestjs.js +34 -0
- package/dist/detection/detectors/nestjs.js.map +1 -0
- package/dist/detection/detectors/npm-package.d.ts +13 -0
- package/dist/detection/detectors/npm-package.d.ts.map +1 -0
- package/dist/detection/detectors/npm-package.js +30 -0
- package/dist/detection/detectors/npm-package.js.map +1 -0
- package/dist/detection/detectors/typescript.d.ts +10 -0
- package/dist/detection/detectors/typescript.d.ts.map +1 -0
- package/dist/detection/detectors/typescript.js +25 -0
- package/dist/detection/detectors/typescript.js.map +1 -0
- package/dist/detection/index.d.ts +24 -0
- package/dist/detection/index.d.ts.map +1 -0
- package/dist/detection/index.js +57 -0
- package/dist/detection/index.js.map +1 -0
- package/dist/errors/index.d.ts +69 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +110 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/console-logger.d.ts +12 -0
- package/dist/logging/console-logger.d.ts.map +1 -0
- package/dist/logging/console-logger.js +22 -0
- package/dist/logging/console-logger.js.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.interface.d.ts +20 -0
- package/dist/logging/logger.interface.d.ts.map +1 -0
- package/dist/logging/logger.interface.js +2 -0
- package/dist/logging/logger.interface.js.map +1 -0
- package/dist/logging/silent-logger.d.ts +12 -0
- package/dist/logging/silent-logger.d.ts.map +1 -0
- package/dist/logging/silent-logger.js +21 -0
- package/dist/logging/silent-logger.js.map +1 -0
- package/dist/strategies/copy-contents.d.ts +14 -0
- package/dist/strategies/copy-contents.d.ts.map +1 -0
- package/dist/strategies/copy-contents.js +69 -0
- package/dist/strategies/copy-contents.js.map +1 -0
- package/dist/strategies/copy-overwrite.d.ts +14 -0
- package/dist/strategies/copy-overwrite.d.ts.map +1 -0
- package/dist/strategies/copy-overwrite.js +47 -0
- package/dist/strategies/copy-overwrite.js.map +1 -0
- package/dist/strategies/create-only.d.ts +13 -0
- package/dist/strategies/create-only.d.ts.map +1 -0
- package/dist/strategies/create-only.js +30 -0
- package/dist/strategies/create-only.js.map +1 -0
- package/dist/strategies/index.d.ts +31 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +52 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/merge.d.ts +13 -0
- package/dist/strategies/merge.d.ts.map +1 -0
- package/dist/strategies/merge.js +60 -0
- package/dist/strategies/merge.js.map +1 -0
- package/dist/strategies/strategy.interface.d.ts +31 -0
- package/dist/strategies/strategy.interface.d.ts.map +1 -0
- package/dist/strategies/strategy.interface.js +2 -0
- package/dist/strategies/strategy.interface.js.map +1 -0
- package/dist/transaction/backup.d.ts +38 -0
- package/dist/transaction/backup.d.ts.map +1 -0
- package/dist/transaction/backup.js +97 -0
- package/dist/transaction/backup.js.map +1 -0
- package/dist/transaction/index.d.ts +4 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +3 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction/transaction.d.ts +34 -0
- package/dist/transaction/transaction.d.ts.map +1 -0
- package/dist/transaction/transaction.js +68 -0
- package/dist/transaction/transaction.js.map +1 -0
- package/dist/utils/file-operations.d.ts +29 -0
- package/dist/utils/file-operations.d.ts.map +1 -0
- package/dist/utils/file-operations.js +84 -0
- package/dist/utils/file-operations.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json-utils.d.ts +22 -0
- package/dist/utils/json-utils.d.ts.map +1 -0
- package/dist/utils/json-utils.js +57 -0
- package/dist/utils/json-utils.js.map +1 -0
- package/dist/utils/path-utils.d.ts +21 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +35 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/eslint-plugin-code-organization/README.md +149 -0
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +468 -0
- package/eslint-plugin-code-organization/index.js +23 -0
- package/eslint-plugin-code-organization/package.json +10 -0
- package/eslint-plugin-code-organization/rules/enforce-statement-order.js +157 -0
- package/expo/copy-overwrite/.claude/skills/apollo-client/SKILL.md +238 -0
- package/expo/copy-overwrite/.claude/skills/apollo-client/references/mutation-patterns.md +360 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/SKILL.md +360 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/atomic-levels.md +417 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/folder-structure.md +257 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/gluestack-mapping.md +233 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/scripts/validate_atomic_structure.py +327 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/SKILL.md +299 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/references/examples.md +749 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/references/patterns.md +318 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/create_component.py +198 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/validate_component.py +207 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/SKILL.md +268 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/common-issues.md +619 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/file-extensions.md +340 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/platform-api.md +276 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/scripts/validate_cross_platform.py +414 -0
- package/expo/copy-overwrite/.claude/skills/directory-structure/SKILL.md +202 -0
- package/expo/copy-overwrite/.claude/skills/directory-structure/scripts/validate_structure.py +443 -0
- package/expo/copy-overwrite/.claude/skills/expo-env-config/SKILL.md +309 -0
- package/expo/copy-overwrite/.claude/skills/expo-env-config/references/validation-patterns.md +417 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/SKILL.md +431 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/references/official-docs.md +290 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/scripts/generate-route.py +169 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/SKILL.md +411 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/color-tokens.md +343 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/component-mapping.md +307 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/spacing-scale.md +300 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/scripts/validate_styling.py +354 -0
- package/expo/copy-overwrite/.claude/skills/local-state/SKILL.md +362 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/async-storage.md +505 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/persistence-patterns.md +711 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/reactive-variables.md +446 -0
- package/expo/copy-overwrite/.claude/skills/playwright-selectors/SKILL.md +223 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/SKILL.md +319 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/async-patterns.md +420 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/expo-router-testing.md +556 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/mocking-patterns.md +590 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/query-priority.md +291 -0
- package/expo/copy-overwrite/.easignore.extra +2 -0
- package/expo/copy-overwrite/.mcp.json +33 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/README.md +234 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/plugin-index.test.js +84 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/require-memo-in-view.test.js +196 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/single-component-per-file.test.js +289 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/index.js +32 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/package.json +10 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/enforce-component-structure.js +230 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/no-return-in-view.js +91 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/require-memo-in-view.js +178 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/single-component-per-file.js +238 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/README.md +260 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/index.js +29 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/package.json +10 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-classname-outside-ui.js +51 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-direct-rn-imports.js +55 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-inline-styles.js +73 -0
- package/expo/copy-overwrite/eslint.config.mjs +560 -0
- package/expo/copy-overwrite/lighthouserc.js +194 -0
- package/expo/create-only/lighthouserc-config.json +28 -0
- package/expo/merge/package.json +132 -0
- package/lisa.sh +35 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/SKILL.md +176 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/advanced-features.md +527 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/project-patterns.md +483 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/quick-start.md +257 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/resolvers-mutations.md +413 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/types-scalars.md +513 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-rules/SKILL.md +536 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/SKILL.md +275 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/configuration-patterns.md +487 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/entity-patterns.md +450 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/observability-patterns.md +536 -0
- package/nestjs/merge/package.json +75 -0
- package/package.json +124 -0
- package/typescript/copy-contents/.husky/commit-msg +91 -0
- package/typescript/copy-contents/.husky/pre-commit +96 -0
- package/typescript/copy-contents/.husky/pre-push +211 -0
- package/typescript/copy-overwrite/.claude/hooks/format-on-edit.sh +74 -0
- package/typescript/copy-overwrite/.claude/hooks/install_pkgs.sh +59 -0
- package/typescript/copy-overwrite/.claude/hooks/lint-on-edit.sh +103 -0
- package/typescript/copy-overwrite/.claude/skills/jsdoc-best-practices/SKILL.md +388 -0
- package/typescript/copy-overwrite/.github/README.md +455 -0
- package/typescript/copy-overwrite/.github/dependabot.yml +40 -0
- package/typescript/copy-overwrite/.github/k6/BROWSER_TESTING_NOTE.md +129 -0
- package/typescript/copy-overwrite/.github/k6/INTEGRATION_GUIDE.md +354 -0
- package/typescript/copy-overwrite/.github/k6/README.md +386 -0
- package/typescript/copy-overwrite/.github/k6/SCENARIO_SELECTION_GUIDE.md +264 -0
- package/typescript/copy-overwrite/.github/k6/examples/customer-deploy-integration.yml +115 -0
- package/typescript/copy-overwrite/.github/k6/examples/data-driven-test.js +268 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/load.js +142 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/load.json +27 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/smoke.js +26 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/smoke.json +20 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/soak.js +244 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/soak.json +29 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/spike.js +180 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/spike.json +32 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/stress.js +206 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/stress.json +38 -0
- package/typescript/copy-overwrite/.github/k6/scripts/api-test.js +452 -0
- package/typescript/copy-overwrite/.github/k6/scripts/default-test.js +185 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/normal.json +30 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/relaxed.json +21 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/strict.json +29 -0
- package/typescript/copy-overwrite/.github/workflows/build.yml +72 -0
- package/typescript/copy-overwrite/.github/workflows/ci.yml +49 -0
- package/typescript/copy-overwrite/.github/workflows/claude.yml +51 -0
- package/typescript/copy-overwrite/.github/workflows/create-github-issue-on-failure.yml +113 -0
- package/typescript/copy-overwrite/.github/workflows/create-jira-issue-on-failure.yml +195 -0
- package/typescript/copy-overwrite/.github/workflows/create-sentry-issue-on-failure.yml +267 -0
- package/typescript/copy-overwrite/.github/workflows/deploy.yml +228 -0
- package/typescript/copy-overwrite/.github/workflows/k6-load-test-README.md +230 -0
- package/typescript/copy-overwrite/.github/workflows/lighthouse.yml +68 -0
- package/typescript/copy-overwrite/.github/workflows/load-test.yml +282 -0
- package/typescript/copy-overwrite/.github/workflows/quality.yml +1737 -0
- package/typescript/copy-overwrite/.github/workflows/release.yml +1599 -0
- package/typescript/copy-overwrite/.gitleaksignore +28 -0
- package/typescript/copy-overwrite/.nvmrc +1 -0
- package/typescript/copy-overwrite/.prettierignore +23 -0
- package/typescript/copy-overwrite/.prettierrc.json +22 -0
- package/typescript/copy-overwrite/.versionrc +42 -0
- package/typescript/copy-overwrite/.yamllint +20 -0
- package/typescript/copy-overwrite/commitlint.config.js +11 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/README.md +149 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +468 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/index.js +23 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/package.json +10 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/rules/enforce-statement-order.js +157 -0
- package/typescript/copy-overwrite/eslint.config.mjs +390 -0
- package/typescript/copy-overwrite/eslint.ignore.config.json +57 -0
- package/typescript/copy-overwrite/eslint.thresholds.config.json +5 -0
- package/typescript/github-rulesets/base.json +106 -0
- package/typescript/merge/.claude/settings.json +28 -0
- package/typescript/merge/package.json +71 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
/* eslint-disable max-lines -- comprehensive test coverage requires extensive test cases */
|
|
2
|
+
/**
|
|
3
|
+
* Tests for enforce-statement-order ESLint rule
|
|
4
|
+
*
|
|
5
|
+
* Enforces the order: definitions → side effects → return
|
|
6
|
+
* 1. Definitions: const/let/var declarations, function declarations
|
|
7
|
+
* 2. Side effects: Expression statements that are function calls
|
|
8
|
+
* 3. Return statement
|
|
9
|
+
*/
|
|
10
|
+
const { RuleTester } = require("eslint");
|
|
11
|
+
|
|
12
|
+
const rule = require("../rules/enforce-statement-order");
|
|
13
|
+
|
|
14
|
+
/** Message data constants for test assertions */
|
|
15
|
+
const DEFINITIONS = "Definitions";
|
|
16
|
+
const SIDE_EFFECTS = "Side effects";
|
|
17
|
+
const RETURN_STATEMENT = "Return statement";
|
|
18
|
+
|
|
19
|
+
const ruleTester = new RuleTester({
|
|
20
|
+
languageOptions: {
|
|
21
|
+
ecmaVersion: 2020,
|
|
22
|
+
sourceType: "module",
|
|
23
|
+
parserOptions: {
|
|
24
|
+
ecmaFeatures: {
|
|
25
|
+
jsx: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
ruleTester.run("enforce-statement-order", rule, {
|
|
32
|
+
valid: [
|
|
33
|
+
// ===== BASIC PATTERNS =====
|
|
34
|
+
|
|
35
|
+
// Correct order: definitions → side effects → return
|
|
36
|
+
{
|
|
37
|
+
code: `
|
|
38
|
+
function example() {
|
|
39
|
+
const x = 1;
|
|
40
|
+
doSomething();
|
|
41
|
+
return x;
|
|
42
|
+
}
|
|
43
|
+
`,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// Definitions only (no side effects)
|
|
47
|
+
{
|
|
48
|
+
code: `
|
|
49
|
+
function example() {
|
|
50
|
+
const x = 1;
|
|
51
|
+
const y = 2;
|
|
52
|
+
return x + y;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// Multiple side effects in correct position
|
|
58
|
+
{
|
|
59
|
+
code: `
|
|
60
|
+
function example() {
|
|
61
|
+
const x = 1;
|
|
62
|
+
doSomething();
|
|
63
|
+
doSomethingElse();
|
|
64
|
+
logger.info("done");
|
|
65
|
+
return x;
|
|
66
|
+
}
|
|
67
|
+
`,
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// Function declaration followed by side effect
|
|
71
|
+
{
|
|
72
|
+
code: `
|
|
73
|
+
function example() {
|
|
74
|
+
const x = 1;
|
|
75
|
+
function helper() {}
|
|
76
|
+
doSomething();
|
|
77
|
+
return x;
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// No return statement (void function)
|
|
83
|
+
{
|
|
84
|
+
code: `
|
|
85
|
+
function example() {
|
|
86
|
+
const x = 1;
|
|
87
|
+
doSomething();
|
|
88
|
+
}
|
|
89
|
+
`,
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
// Only side effects (no definitions, no return)
|
|
93
|
+
{
|
|
94
|
+
code: `
|
|
95
|
+
function example() {
|
|
96
|
+
doSomething();
|
|
97
|
+
doSomethingElse();
|
|
98
|
+
}
|
|
99
|
+
`,
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// ===== REACT PATTERNS =====
|
|
103
|
+
|
|
104
|
+
// React hook with correct order
|
|
105
|
+
{
|
|
106
|
+
code: `
|
|
107
|
+
const useExample = () => {
|
|
108
|
+
const [state, setState] = useState(null);
|
|
109
|
+
const data = useMemo(() => [], []);
|
|
110
|
+
const handleClick = useCallback(() => {}, []);
|
|
111
|
+
|
|
112
|
+
useEffect(() => {}, []);
|
|
113
|
+
|
|
114
|
+
return data;
|
|
115
|
+
};
|
|
116
|
+
`,
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
// React component with correct order
|
|
120
|
+
{
|
|
121
|
+
code: `
|
|
122
|
+
const MyComponent = () => {
|
|
123
|
+
const [state, setState] = useState(null);
|
|
124
|
+
const data = useMemo(() => [], []);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {}, []);
|
|
127
|
+
logRender();
|
|
128
|
+
|
|
129
|
+
return <div>{data}</div>;
|
|
130
|
+
};
|
|
131
|
+
`,
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// React component function declaration
|
|
135
|
+
{
|
|
136
|
+
code: `
|
|
137
|
+
function MyComponent() {
|
|
138
|
+
const [state, setState] = useState(null);
|
|
139
|
+
const handleClick = useCallback(() => {}, []);
|
|
140
|
+
|
|
141
|
+
useEffect(() => {}, []);
|
|
142
|
+
|
|
143
|
+
return <div />;
|
|
144
|
+
}
|
|
145
|
+
`,
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// Early return pattern after side effects is valid
|
|
149
|
+
{
|
|
150
|
+
code: `
|
|
151
|
+
const MyComponent = () => {
|
|
152
|
+
const [loading, setLoading] = useState(true);
|
|
153
|
+
|
|
154
|
+
useEffect(() => {}, []);
|
|
155
|
+
|
|
156
|
+
if (loading) return null;
|
|
157
|
+
|
|
158
|
+
return <div />;
|
|
159
|
+
};
|
|
160
|
+
`,
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
// Early return with block statement after side effects
|
|
164
|
+
{
|
|
165
|
+
code: `
|
|
166
|
+
const MyComponent = () => {
|
|
167
|
+
const data = useMemo(() => [], []);
|
|
168
|
+
|
|
169
|
+
useEffect(() => {}, []);
|
|
170
|
+
|
|
171
|
+
if (!data) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return <div />;
|
|
176
|
+
};
|
|
177
|
+
`,
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// ===== ARROW FUNCTIONS =====
|
|
181
|
+
|
|
182
|
+
// Arrow function with correct order
|
|
183
|
+
{
|
|
184
|
+
code: `
|
|
185
|
+
const process = () => {
|
|
186
|
+
const config = getConfig();
|
|
187
|
+
initialize();
|
|
188
|
+
return config;
|
|
189
|
+
};
|
|
190
|
+
`,
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
// ===== EDGE CASES =====
|
|
194
|
+
|
|
195
|
+
// Empty function
|
|
196
|
+
{
|
|
197
|
+
code: `
|
|
198
|
+
function empty() {}
|
|
199
|
+
`,
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// Only return
|
|
203
|
+
{
|
|
204
|
+
code: `
|
|
205
|
+
function getValue() {
|
|
206
|
+
return 42;
|
|
207
|
+
}
|
|
208
|
+
`,
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
// Nested functions are checked independently
|
|
212
|
+
{
|
|
213
|
+
code: `
|
|
214
|
+
function outer() {
|
|
215
|
+
const x = 1;
|
|
216
|
+
const inner = () => {
|
|
217
|
+
const y = 2;
|
|
218
|
+
doSomething();
|
|
219
|
+
return y;
|
|
220
|
+
};
|
|
221
|
+
doSomething();
|
|
222
|
+
return x;
|
|
223
|
+
}
|
|
224
|
+
`,
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
|
|
228
|
+
invalid: [
|
|
229
|
+
// ===== BASIC VIOLATIONS =====
|
|
230
|
+
|
|
231
|
+
// Definition after side effect
|
|
232
|
+
{
|
|
233
|
+
code: `
|
|
234
|
+
function example() {
|
|
235
|
+
doSomething();
|
|
236
|
+
const x = 1;
|
|
237
|
+
return x;
|
|
238
|
+
}
|
|
239
|
+
`,
|
|
240
|
+
errors: [
|
|
241
|
+
{
|
|
242
|
+
messageId: "wrongOrder",
|
|
243
|
+
data: {
|
|
244
|
+
current: DEFINITIONS,
|
|
245
|
+
previous: SIDE_EFFECTS,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// Side effect after return
|
|
252
|
+
{
|
|
253
|
+
code: `
|
|
254
|
+
function example() {
|
|
255
|
+
const x = 1;
|
|
256
|
+
return x;
|
|
257
|
+
doSomething();
|
|
258
|
+
}
|
|
259
|
+
`,
|
|
260
|
+
errors: [
|
|
261
|
+
{
|
|
262
|
+
messageId: "wrongOrder",
|
|
263
|
+
data: {
|
|
264
|
+
current: SIDE_EFFECTS,
|
|
265
|
+
previous: RETURN_STATEMENT,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
// Definition after return
|
|
272
|
+
{
|
|
273
|
+
code: `
|
|
274
|
+
function example() {
|
|
275
|
+
return 1;
|
|
276
|
+
const x = 2;
|
|
277
|
+
}
|
|
278
|
+
`,
|
|
279
|
+
errors: [
|
|
280
|
+
{
|
|
281
|
+
messageId: "wrongOrder",
|
|
282
|
+
data: {
|
|
283
|
+
current: DEFINITIONS,
|
|
284
|
+
previous: RETURN_STATEMENT,
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
// Multiple violations
|
|
291
|
+
{
|
|
292
|
+
code: `
|
|
293
|
+
function example() {
|
|
294
|
+
doSomething();
|
|
295
|
+
const x = 1;
|
|
296
|
+
return x;
|
|
297
|
+
const y = 2;
|
|
298
|
+
}
|
|
299
|
+
`,
|
|
300
|
+
errors: [
|
|
301
|
+
{
|
|
302
|
+
messageId: "wrongOrder",
|
|
303
|
+
data: {
|
|
304
|
+
current: DEFINITIONS,
|
|
305
|
+
previous: SIDE_EFFECTS,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
messageId: "wrongOrder",
|
|
310
|
+
data: {
|
|
311
|
+
current: DEFINITIONS,
|
|
312
|
+
previous: RETURN_STATEMENT,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
// ===== NON-REACT VIOLATIONS =====
|
|
319
|
+
|
|
320
|
+
// Plain function call before definition
|
|
321
|
+
{
|
|
322
|
+
code: `
|
|
323
|
+
function process() {
|
|
324
|
+
initialize();
|
|
325
|
+
const config = {};
|
|
326
|
+
return config;
|
|
327
|
+
}
|
|
328
|
+
`,
|
|
329
|
+
errors: [
|
|
330
|
+
{
|
|
331
|
+
messageId: "wrongOrder",
|
|
332
|
+
data: {
|
|
333
|
+
current: DEFINITIONS,
|
|
334
|
+
previous: SIDE_EFFECTS,
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
// Logger call before definition
|
|
341
|
+
{
|
|
342
|
+
code: `
|
|
343
|
+
function getData() {
|
|
344
|
+
logger.info("fetching");
|
|
345
|
+
const data = fetch();
|
|
346
|
+
return data;
|
|
347
|
+
}
|
|
348
|
+
`,
|
|
349
|
+
errors: [
|
|
350
|
+
{
|
|
351
|
+
messageId: "wrongOrder",
|
|
352
|
+
data: {
|
|
353
|
+
current: DEFINITIONS,
|
|
354
|
+
previous: SIDE_EFFECTS,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
// Console.log before definition
|
|
361
|
+
{
|
|
362
|
+
code: `
|
|
363
|
+
function debug() {
|
|
364
|
+
console.log("starting");
|
|
365
|
+
const value = compute();
|
|
366
|
+
return value;
|
|
367
|
+
}
|
|
368
|
+
`,
|
|
369
|
+
errors: [
|
|
370
|
+
{
|
|
371
|
+
messageId: "wrongOrder",
|
|
372
|
+
data: {
|
|
373
|
+
current: DEFINITIONS,
|
|
374
|
+
previous: SIDE_EFFECTS,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
// ===== REACT VIOLATIONS =====
|
|
381
|
+
|
|
382
|
+
// Variable after useEffect
|
|
383
|
+
{
|
|
384
|
+
code: `
|
|
385
|
+
const useExample = () => {
|
|
386
|
+
useEffect(() => {}, []);
|
|
387
|
+
const data = useMemo(() => [], []);
|
|
388
|
+
return data;
|
|
389
|
+
};
|
|
390
|
+
`,
|
|
391
|
+
errors: [
|
|
392
|
+
{
|
|
393
|
+
messageId: "wrongOrder",
|
|
394
|
+
data: {
|
|
395
|
+
current: DEFINITIONS,
|
|
396
|
+
previous: SIDE_EFFECTS,
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
// useCallback after useEffect
|
|
403
|
+
{
|
|
404
|
+
code: `
|
|
405
|
+
const MyComponent = () => {
|
|
406
|
+
const [state, setState] = useState(null);
|
|
407
|
+
useEffect(() => {}, []);
|
|
408
|
+
const handleClick = useCallback(() => {}, []);
|
|
409
|
+
return <div />;
|
|
410
|
+
};
|
|
411
|
+
`,
|
|
412
|
+
errors: [
|
|
413
|
+
{
|
|
414
|
+
messageId: "wrongOrder",
|
|
415
|
+
data: {
|
|
416
|
+
current: DEFINITIONS,
|
|
417
|
+
previous: SIDE_EFFECTS,
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
// Function declaration after side effect
|
|
424
|
+
{
|
|
425
|
+
code: `
|
|
426
|
+
function MyComponent() {
|
|
427
|
+
useEffect(() => {}, []);
|
|
428
|
+
function handleClick() {}
|
|
429
|
+
return <div />;
|
|
430
|
+
}
|
|
431
|
+
`,
|
|
432
|
+
errors: [
|
|
433
|
+
{
|
|
434
|
+
messageId: "wrongOrder",
|
|
435
|
+
data: {
|
|
436
|
+
current: DEFINITIONS,
|
|
437
|
+
previous: SIDE_EFFECTS,
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
|
|
443
|
+
// ===== ARROW FUNCTION VIOLATIONS =====
|
|
444
|
+
|
|
445
|
+
// Arrow function with side effect before definition
|
|
446
|
+
{
|
|
447
|
+
code: `
|
|
448
|
+
const process = () => {
|
|
449
|
+
initialize();
|
|
450
|
+
const config = getConfig();
|
|
451
|
+
return config;
|
|
452
|
+
};
|
|
453
|
+
`,
|
|
454
|
+
errors: [
|
|
455
|
+
{
|
|
456
|
+
messageId: "wrongOrder",
|
|
457
|
+
data: {
|
|
458
|
+
current: DEFINITIONS,
|
|
459
|
+
previous: SIDE_EFFECTS,
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
console.log("All enforce-statement-order tests passed!");
|
|
468
|
+
/* eslint-enable max-lines -- comprehensive test coverage requires extensive test cases */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint plugin for code organization standards
|
|
3
|
+
*
|
|
4
|
+
* This plugin enforces code organization patterns for all functions
|
|
5
|
+
* in the frontend application. Supports ESLint 9 flat config format.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - enforce-statement-order: Ensures statements follow the order (definitions -> side effects -> return)
|
|
9
|
+
* @module eslint-plugin-code-organization
|
|
10
|
+
*/
|
|
11
|
+
const enforceStatementOrder = require("./rules/enforce-statement-order");
|
|
12
|
+
|
|
13
|
+
const plugin = {
|
|
14
|
+
meta: {
|
|
15
|
+
name: "eslint-plugin-code-organization",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
"enforce-statement-order": enforceStatementOrder,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
module.exports = plugin;
|
package/typescript/copy-overwrite/eslint-plugin-code-organization/rules/enforce-statement-order.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint rule to enforce statement order in all functions
|
|
3
|
+
*
|
|
4
|
+
* Enforces the following order:
|
|
5
|
+
* 1. Definitions: Variable declarations (const/let/var) and function declarations
|
|
6
|
+
* 2. Side effects: Expression statements that are function calls
|
|
7
|
+
* 3. Return statement
|
|
8
|
+
*
|
|
9
|
+
* Applies to all functions: hooks, components, utilities, etc.
|
|
10
|
+
* @type {import('eslint').Rule.RuleModule}
|
|
11
|
+
*/
|
|
12
|
+
module.exports = {
|
|
13
|
+
meta: {
|
|
14
|
+
type: "problem",
|
|
15
|
+
docs: {
|
|
16
|
+
description:
|
|
17
|
+
"Enforce statement order: definitions → side effects → return",
|
|
18
|
+
category: "Best Practices",
|
|
19
|
+
recommended: true,
|
|
20
|
+
},
|
|
21
|
+
fixable: null,
|
|
22
|
+
schema: [],
|
|
23
|
+
messages: {
|
|
24
|
+
wrongOrder:
|
|
25
|
+
"{{current}} should come before {{previous}}. Expected order: definitions → side effects → return statement",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
create(context) {
|
|
30
|
+
const ORDER = {
|
|
31
|
+
DEFINITION: 1, // Variable declarations, function declarations
|
|
32
|
+
SIDE_EFFECT: 2, // Expression statements with function calls
|
|
33
|
+
RETURN: 3, // Return statement
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const ORDER_NAMES = {
|
|
37
|
+
[ORDER.DEFINITION]: "Definitions",
|
|
38
|
+
[ORDER.SIDE_EFFECT]: "Side effects",
|
|
39
|
+
[ORDER.RETURN]: "Return statement",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Checks if an expression statement is a function call (side effect)
|
|
44
|
+
* @param {import('eslint').Rule.Node} statement - AST node
|
|
45
|
+
* @returns {boolean} True if this is a function call expression
|
|
46
|
+
*/
|
|
47
|
+
function isFunctionCallExpression(statement) {
|
|
48
|
+
if (statement.type !== "ExpressionStatement") {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const expression = statement.expression;
|
|
53
|
+
|
|
54
|
+
// Direct call: doSomething() or object.method()
|
|
55
|
+
if (expression.type === "CallExpression") {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Determines the order category of a statement
|
|
64
|
+
* Guard clauses (if statements with early returns) are ignored and don't
|
|
65
|
+
* affect order validation - they can appear anywhere in the function.
|
|
66
|
+
* @param {import('eslint').Rule.Node} statement - AST node
|
|
67
|
+
* @returns {number|null} Order category value, or null to skip this statement
|
|
68
|
+
*/
|
|
69
|
+
function getStatementOrder(statement) {
|
|
70
|
+
// Bare return statement (not in an if block)
|
|
71
|
+
if (statement.type === "ReturnStatement") {
|
|
72
|
+
return ORDER.RETURN;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// If statements are ignored - they may contain guard clauses (early returns)
|
|
76
|
+
// which are valid at any position in the function
|
|
77
|
+
if (statement.type === "IfStatement") {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Variable declarations are definitions
|
|
82
|
+
if (statement.type === "VariableDeclaration") {
|
|
83
|
+
return ORDER.DEFINITION;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Function declarations are definitions
|
|
87
|
+
if (statement.type === "FunctionDeclaration") {
|
|
88
|
+
return ORDER.DEFINITION;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Expression statements with function calls are side effects
|
|
92
|
+
if (isFunctionCallExpression(statement)) {
|
|
93
|
+
return ORDER.SIDE_EFFECT;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Default to null for other statements (they don't affect order)
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Checks if a function body follows the correct statement order
|
|
102
|
+
* @param {import('eslint').Rule.Node} node - Function node
|
|
103
|
+
*/
|
|
104
|
+
function checkBodyOrder(node) {
|
|
105
|
+
if (!node.body || node.body.type !== "BlockStatement") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const statements = node.body.body;
|
|
110
|
+
// eslint-disable-next-line functional/no-let -- ESLint plugin requires mutable tracking variable for order validation
|
|
111
|
+
let maxOrderSeen = 0;
|
|
112
|
+
|
|
113
|
+
statements.forEach(statement => {
|
|
114
|
+
const currentOrder = getStatementOrder(statement);
|
|
115
|
+
|
|
116
|
+
// Skip statements that don't affect order (e.g., if statements)
|
|
117
|
+
if (currentOrder === null) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (currentOrder < maxOrderSeen) {
|
|
122
|
+
context.report({
|
|
123
|
+
node: statement,
|
|
124
|
+
messageId: "wrongOrder",
|
|
125
|
+
data: {
|
|
126
|
+
current: ORDER_NAMES[currentOrder],
|
|
127
|
+
previous: ORDER_NAMES[maxOrderSeen],
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Track the highest order we've seen so far
|
|
133
|
+
if (currentOrder > maxOrderSeen) {
|
|
134
|
+
maxOrderSeen = currentOrder;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
// Check all function declarations
|
|
141
|
+
FunctionDeclaration(node) {
|
|
142
|
+
checkBodyOrder(node);
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Check all arrow functions and function expressions assigned to variables
|
|
146
|
+
VariableDeclarator(node) {
|
|
147
|
+
if (
|
|
148
|
+
node.init &&
|
|
149
|
+
(node.init.type === "ArrowFunctionExpression" ||
|
|
150
|
+
node.init.type === "FunctionExpression")
|
|
151
|
+
) {
|
|
152
|
+
checkBodyOrder(node.init);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
};
|