Skip to content

Commit

Permalink
refactor: put all internal function exports into same file (#3677)
Browse files Browse the repository at this point in the history
  • Loading branch information
straker authored Sep 27, 2022
1 parent e0a0692 commit 0fe4a00
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 88 deletions.
77 changes: 77 additions & 0 deletions lib/core/_exposed-for-testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
This file only exists to expose inner axe-core functionality for testing prior to being able to support ES6 imports in our tests.
TODO: remove `_thisWillBeDeletedDoNotUse` once we can support imports in our tests
*/
import Audit from './base/audit';
import CheckResult from './base/check-result';
import Check from './base/check';
import Context from './base/context';
import metadataFunctionMap from './base/metadata-function-map';
import RuleResult from './base/rule-result';
import Rule from './base/rule';

import { reporters } from './public/reporter';

import failureSummary from './reporters/helpers/failure-summary';
import incompleteFallbackMessage from './reporters/helpers/incomplete-fallback-msg';
import processAggregate from './reporters/helpers/process-aggregate';

import { setDefaultFrameMessenger } from './utils/frame-messenger';
import {
cacheNodeSelectors,
getNodesMatchingExpression
} from './utils/selector-cache';
import { convertSelector } from './utils/matches';

import {
nativelyHidden,
displayHidden,
visibilityHidden,
ariaHidden,
opacityHidden,
scrollHidden,
overflowHidden,
clipHidden,
areaHidden
} from '../commons/dom/visibility-methods';

const _thisWillBeDeletedDoNotUse = {
base: {
Audit,
CheckResult,
Check,
Context,
RuleResult,
Rule,
metadataFunctionMap
},
public: {
reporters
},
helpers: {
failureSummary,
incompleteFallbackMessage,
processAggregate
},
utils: {
setDefaultFrameMessenger,
cacheNodeSelectors,
getNodesMatchingExpression,
convertSelector
},
commons: {
dom: {
nativelyHidden,
displayHidden,
visibilityHidden,
ariaHidden,
opacityHidden,
scrollHidden,
overflowHidden,
clipHidden,
areaHidden
}
}
};

export default _thisWillBeDeletedDoNotUse;
69 changes: 4 additions & 65 deletions lib/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import SerialVirtualNode from './base/virtual-node/serial-virtual-node';
import VirtualNode from './base/virtual-node/virtual-node';
import cache from './base/cache';

import Audit from './base/audit';
import CheckResult from './base/check-result';
import Check from './base/check';
import Context from './base/context';
import metadataFunctionMap from './base/metadata-function-map';
import RuleResult from './base/rule-result';
import Rule from './base/rule';

import * as imports from './imports';

import cleanup from './public/cleanup';
Expand All @@ -22,12 +14,7 @@ import frameMessenger from './public/frame-messenger';
import getRules from './public/get-rules';
import load from './public/load';
import registerPlugin from './public/plugins';
import {
reporters,
hasReporter,
getReporter,
addReporter
} from './public/reporter';
import { hasReporter, getReporter, addReporter } from './public/reporter';
import reset from './public/reset';
import runRules from './public/run-rules';
import runVirtualRule from './public/run-virtual-rule';
Expand All @@ -46,22 +33,9 @@ import v2Reporter from './reporters/v2';

import * as commons from '../commons';
import * as utils from './utils';
import {
cacheNodeSelectors,
getNodesMatchingExpression
} from './utils/selector-cache';
import { convertSelector } from './utils/matches';
import {
nativelyHidden,
displayHidden,
visibilityHidden,
ariaHidden,
opacityHidden,
scrollHidden,
overflowHidden,
clipHidden,
areaHidden
} from '../commons/dom/visibility-methods';

import _thisWillBeDeletedDoNotUse from './_exposed-for-testing.js';
axe._thisWillBeDeletedDoNotUse = _thisWillBeDeletedDoNotUse;

axe.constants = constants;
axe.log = log;
Expand All @@ -71,41 +45,6 @@ axe.SerialVirtualNode = SerialVirtualNode;
axe.VirtualNode = VirtualNode;
axe._cache = cache;

// Setting up this private/temp namespace for the tests (which cannot yet `import/export` things).
// TODO: remove `_thisWillBeDeletedDoNotUse`
axe._thisWillBeDeletedDoNotUse = axe._thisWillBeDeletedDoNotUse || {};
axe._thisWillBeDeletedDoNotUse.base = {
Audit,
CheckResult,
Check,
Context,
RuleResult,
Rule,
metadataFunctionMap
};
axe._thisWillBeDeletedDoNotUse.public = {
reporters
};
axe._thisWillBeDeletedDoNotUse.utils =
axe._thisWillBeDeletedDoNotUse.utils || {};
axe._thisWillBeDeletedDoNotUse.utils.cacheNodeSelectors = cacheNodeSelectors;
axe._thisWillBeDeletedDoNotUse.utils.getNodesMatchingExpression =
getNodesMatchingExpression;
axe._thisWillBeDeletedDoNotUse.utils.convertSelector = convertSelector;
axe._thisWillBeDeletedDoNotUse.commons =
axe._thisWillBeDeletedDoNotUse.commons || {};
axe._thisWillBeDeletedDoNotUse.commons.dom =
axe._thisWillBeDeletedDoNotUse.commons.dom || {};
axe._thisWillBeDeletedDoNotUse.commons.dom.nativelyHidden = nativelyHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.displayHidden = displayHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.visibilityHidden = visibilityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.ariaHidden = ariaHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.opacityHidden = opacityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.scrollHidden = scrollHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.overflowHidden = overflowHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.clipHidden = clipHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.areaHidden = areaHidden;

axe.imports = imports;

axe.cleanup = cleanup;
Expand Down
15 changes: 1 addition & 14 deletions lib/core/reporters/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,4 @@ import failureSummary from './failure-summary';
import incompleteFallbackMessage from './incomplete-fallback-msg';
import processAggregate from './process-aggregate';

// Setting up this private/temp namespace for the tests (which cannot yet `import/export` things).
// TODO: remove `_thisWillBeDeletedDoNotUse`
axe._thisWillBeDeletedDoNotUse = axe._thisWillBeDeletedDoNotUse || {};
axe._thisWillBeDeletedDoNotUse.helpers = {
failureSummary,
incompleteFallbackMessage,
processAggregate
};

export {
failureSummary,
incompleteFallbackMessage,
processAggregate
};
export { failureSummary, incompleteFallbackMessage, processAggregate };
9 changes: 0 additions & 9 deletions lib/core/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { setDefaultFrameMessenger } from './frame-messenger';

/**
* Namespace for utility helper methods.
* @namespace utils
Expand Down Expand Up @@ -85,10 +83,3 @@ export { default as uniqueArray } from './unique-array';
export { default as uuid } from './uuid';
export { default as validInputTypes } from './valid-input-type';
export { default as isValidLang, validLangs } from './valid-langs';

// Setting up this private/temp namespace for the tests (which cannot yet `import/export` things).
// TODO: remove `_thisWillBeDeletedDoNotUse`
axe._thisWillBeDeletedDoNotUse = axe._thisWillBeDeletedDoNotUse || {};
axe._thisWillBeDeletedDoNotUse.utils = {
setDefaultFrameMessenger
};

0 comments on commit 0fe4a00

Please sign in to comment.