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

chore(null): null strictness fixes for /src/scanner/ files requiring manual attention #3341

Merged
merged 5 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/scanner/custom-rules/css-content-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ function pageHasElementsWithPseudoSelectors(node: HTMLElement): boolean {
return pseudoElements.length > 0;
}

function getAllPseudoElements(node: HTMLElement): HTMLElement[] {
function getAllPseudoElements(node: HTMLElement): Element[] {
const elements = node.querySelectorAll('*');

const hasContent = styles => {
return styles && styles.content !== 'none';
};

const pseudoElements = [];
const pseudoElements: Element[] = [];
for (let index = 0; index < elements.length; index++) {
const element = elements.item(index);
const beforeStyles = window.getComputedStyle(element, ':before');
Expand Down
4 changes: 2 additions & 2 deletions src/scanner/custom-rules/heading-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const headingConfiguration: RuleConfiguration = {

function evaluateCodedHeadings(node: HTMLElement, options: any): boolean {
const headingText: string = node.innerText;
let headingLevel: number;
const ariaHeadingLevel: string = node.getAttribute('aria-level');
let headingLevel: number | undefined;
const ariaHeadingLevel: string | null = node.getAttribute('aria-level');
if (ariaHeadingLevel !== null) {
headingLevel = parseInt(ariaHeadingLevel, 10);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/help-url-getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class HelpUrlGetter {
return customHelpUrl || axeHelpUrl;
}

private getCustomHelpUrl(ruleId: string): string {
private getCustomHelpUrl(ruleId: string): string | null {
for (let index = 0; index < this.ruleConfigs.length; index++) {
const config = this.ruleConfigs[index];
if (config.rule.id === ruleId && config.rule.helpUrl != null) {
Expand Down
5 changes: 4 additions & 1 deletion src/scanner/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export namespace Processor {
// add messages to suppress here. Remove comment when non-empty.
].map(normalizeText);

export function suppressChecksByMessages(rule: AxeRule, removeEmptyRules = true): AxeRule {
export function suppressChecksByMessages(
rule: AxeRule,
removeEmptyRules = true,
): AxeRule | null {
rule.nodes = rule.nodes.filter((nodeResult: AxeNodeResult) => {
nodeResult.any = nodeResult.any.filter((check: any) => {
const checkShown =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const fakeRuleConfigurationA: RuleConfiguration = {
checks: [
{
id: 'fake-check-id',
evaluate: () => null,
evaluate: () => {
throw 'unimplemented evaluate stub';
},
passMessage: () => passMessageStub,
failMessage: () => failMessageStub,
},
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.strictNullChecks.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,20 @@
"./src/scanner/check-message-transformer.ts",
"./src/scanner/custom-rules/autocomplete-rule.ts",
"./src/scanner/custom-rules/color-rule.ts",
"./src/scanner/custom-rules/css-content-rule.ts",
"./src/scanner/custom-rules/css-positioning-rule.ts",
"./src/scanner/custom-rules/frame-title.ts",
"./src/scanner/custom-rules/header-rule.ts",
"./src/scanner/custom-rules/heading-rule.ts",
"./src/scanner/custom-rules/link-purpose.ts",
"./src/scanner/custom-rules/page-title.ts",
"./src/scanner/custom-rules/text-contrast.ts",
"./src/scanner/custom-rules/unique-landmark.ts",
"./src/scanner/document-utils.ts",
"./src/scanner/help-url-getter.ts",
"./src/scanner/iruleresults.d.ts",
"./src/scanner/locale-configuration.ts",
"./src/scanner/processor.ts",
"./src/scanner/role-utils.ts",
"./src/scanner/scan-options.ts",
"./src/tests/common/get-automation-id-selector.ts",
Expand Down Expand Up @@ -357,6 +361,7 @@
"./src/tests/unit/tests/electron/flux/action-creator/scan-result-example.ts",
"./src/tests/unit/tests/electron/platform/android/setup/steps/actions-tester.ts",
"./src/tests/unit/tests/injected/visualization/drawer-utils-mock-builder.ts",
"./src/tests/unit/tests/scanner/custom-rules-configuration-stub.ts",
"./src/tests/unit/tests/scanner/mock-axe-utils.ts",
"./src/views/content/guidance-title.tsx"
],
Expand Down