Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor module slug references with constants #3417

Open
johnPhillips opened this issue May 26, 2021 · 0 comments
Open

Refactor module slug references with constants #3417

johnPhillips opened this issue May 26, 2021 · 0 comments
Labels
P2 Low priority Type: Infrastructure Engineering infrastructure & tooling

Comments

@johnPhillips
Copy link
Contributor

Feature Description

Following on from a comment on a recent pull request, it might be a good idea to establish module slugs as module-level constants rather than typing the string whenever required.

/**
 * assets/js/modules/analytics/constants.js 
 */
export const MODULE_SLUG = 'analytics';

// An additional alias might also be useful when multiple slugs are referenced in a file
export { MODULE_SLUG as MODULE_SLUG_ANALYTICS };

/**
 * Then, elsewhere:
 */
import { MODULE_SLUG } from '../../constants'; 
import { MODULE_SLUG_ANALYTICS } from 'assets/js/modules/analytics/constants';

const ideaHubConnected = useSelect( ( select ) => select( CORE_MODULES ).isModuleConnected( MODULE_SLUG ) );
const analyticsConnected = useSelect( ( select ) => select( CORE_MODULES ).isModuleConnected( MODULE_SLUG_ANALYTICS ) );

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

Test Coverage

Visual Regression Changes

QA Brief

Changelog entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Low priority Type: Infrastructure Engineering infrastructure & tooling
Projects
None yet
Development

No branches or pull requests

2 participants