-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add prettier and eslint (#633)
* chore: add eslint * chore: add prettier
- Loading branch information
John Kleinschmidt
authored
Jun 29, 2020
1 parent
9fdb353
commit c4fe27e
Showing
35 changed files
with
3,211 additions
and
2,978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/axs_testing.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"extends": "standard", | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"env": { | ||
"browser": true | ||
}, | ||
"rules": { | ||
"semi": ["error", "always"], | ||
"no-var": "error", | ||
"no-unused-vars": 0, | ||
"no-global-assign": 0, | ||
"guard-for-in": 2, | ||
"space-before-function-paren": 0, | ||
"@typescript-eslint/no-unused-vars": ["error", { | ||
"vars": "all", | ||
"args": "after-used", | ||
"ignoreRestSiblings": false | ||
}], | ||
"prefer-const": ["error", { | ||
"destructuring": "all" | ||
}], | ||
"standard/no-callback-literal": "off", | ||
"node/no-deprecated-api": 0 | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": "*.d.ts", | ||
"rules": { | ||
"no-useless-constructor": "off" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/axs_testing.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"trailingComma": "none", | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"endOfLine": "lf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
exports.Application = require('./lib/application') | ||
exports.Application = require('./lib/application'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,72 @@ | ||
var axsPath = require.resolve('../vendor/axs_testing') | ||
const axsPath = require.resolve('../vendor/axs_testing'); | ||
|
||
exports.addCommand = function (client, requireName) { | ||
client.addCommand('auditAccessibility', function (options) { | ||
return this.execute(function (axsPath, requireName, options) { | ||
options = options || {} | ||
var ignoreWarnings = options.ignoreWarnings || false | ||
var ignoreRules = Array.isArray(options.ignoreRules) ? options.ignoreRules : [] | ||
return this.execute( | ||
function (axsPath, requireName, options) { | ||
options = options || {}; | ||
const ignoreWarnings = options.ignoreWarnings || false; | ||
const ignoreRules = Array.isArray(options.ignoreRules) | ||
? options.ignoreRules | ||
: []; | ||
|
||
var axs = window[requireName](axsPath) | ||
var audit = axs.Audit.run(new axs.AuditConfiguration({ | ||
showUnsupportedRulesWarning: false | ||
})) | ||
const axs = window[requireName](axsPath); | ||
const audit = axs.Audit.run( | ||
new axs.AuditConfiguration({ | ||
showUnsupportedRulesWarning: false | ||
}) | ||
); | ||
|
||
var failures = audit.filter(function (result) { | ||
return result.result === 'FAIL' | ||
}) | ||
let failures = audit.filter(function (result) { | ||
return result.result === 'FAIL'; | ||
}); | ||
|
||
if (ignoreWarnings) { | ||
failures = failures.filter(function (result) { | ||
return result.rule.severity !== 'Warning' | ||
}) | ||
} | ||
if (ignoreWarnings) { | ||
failures = failures.filter(function (result) { | ||
return result.rule.severity !== 'Warning'; | ||
}); | ||
} | ||
|
||
failures = failures.filter(function (result) { | ||
return ignoreRules.indexOf(result.rule.code) === -1 | ||
}) | ||
failures = failures.filter(function (result) { | ||
return ignoreRules.indexOf(result.rule.code) === -1; | ||
}); | ||
|
||
if (failures.length > 0) { | ||
var message = 'Accessibilty audit failed\n\n' | ||
message += failures.map(function (result) { | ||
return axs.Audit.accessibilityErrorMessage(result) | ||
}).join('\n\n') | ||
if (failures.length > 0) { | ||
let message = 'Accessibilty audit failed\n\n'; | ||
message += failures | ||
.map(function (result) { | ||
return axs.Audit.accessibilityErrorMessage(result); | ||
}) | ||
.join('\n\n'); | ||
|
||
return { | ||
message: message, | ||
failed: true, | ||
results: failures.map(function (result) { | ||
return { | ||
code: result.rule.code, | ||
elements: result.elements.map(function (element) { | ||
return axs.utils.getQuerySelectorText(element) | ||
}), | ||
message: result.rule.heading, | ||
severity: result.rule.severity, | ||
url: result.rule.url | ||
} | ||
}) | ||
} | ||
} else { | ||
return { | ||
message: 'Accessibilty audit passed', | ||
results: [], | ||
failed: false | ||
return { | ||
message: message, | ||
failed: true, | ||
results: failures.map(function (result) { | ||
return { | ||
code: result.rule.code, | ||
elements: result.elements.map(function (element) { | ||
return axs.utils.getQuerySelectorText(element); | ||
}), | ||
message: result.rule.heading, | ||
severity: result.rule.severity, | ||
url: result.rule.url | ||
}; | ||
}) | ||
}; | ||
} else { | ||
return { | ||
message: 'Accessibilty audit passed', | ||
results: [], | ||
failed: false | ||
}; | ||
} | ||
} | ||
}, axsPath, requireName, options).then(function (response) { | ||
return response | ||
}) | ||
}) | ||
} | ||
}, | ||
axsPath, | ||
requireName, | ||
options | ||
).then(function (response) { | ||
return response; | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.