mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
6
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/IdentifierMock.js
generated
vendored
Normal file
6
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/IdentifierMock.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
export default function IdentifierMock(ident) {
|
||||
return {
|
||||
type: 'Identifier',
|
||||
name: ident,
|
||||
};
|
||||
}
|
24
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXAttributeMock.js
generated
vendored
Normal file
24
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXAttributeMock.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
import toAST from 'to-ast'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import JSXExpressionContainerMock from './JSXExpressionContainerMock';
|
||||
|
||||
export default function JSXAttributeMock(prop, value, isExpressionContainer = false) {
|
||||
let astValue;
|
||||
if (value && value.type !== undefined) {
|
||||
astValue = value;
|
||||
} else {
|
||||
astValue = toAST(value);
|
||||
}
|
||||
let attributeValue = astValue;
|
||||
if (isExpressionContainer || astValue.type !== 'Literal') {
|
||||
attributeValue = JSXExpressionContainerMock(astValue);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'JSXAttribute',
|
||||
name: {
|
||||
type: 'JSXIdentifier',
|
||||
name: prop,
|
||||
},
|
||||
value: attributeValue,
|
||||
};
|
||||
}
|
37
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXElementMock.js
generated
vendored
Normal file
37
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXElementMock.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import JSXAttributeMock from './JSXAttributeMock';
|
||||
|
||||
export type TJSXElementMock = {
|
||||
type: 'JSXElement',
|
||||
openingElement: {
|
||||
type: 'JSXOpeningElement',
|
||||
name: {
|
||||
type: 'JSXIdentifier',
|
||||
name: string,
|
||||
},
|
||||
attributes: Array<JSXAttributeMock>,
|
||||
},
|
||||
children: Array<Node>,
|
||||
};
|
||||
|
||||
export default function JSXElementMock(
|
||||
tagName: string,
|
||||
attributes: Array<JSXAttributeMock> = [],
|
||||
children: Array<Node> = [],
|
||||
): TJSXElementMock {
|
||||
return {
|
||||
type: 'JSXElement',
|
||||
openingElement: {
|
||||
type: 'JSXOpeningElement',
|
||||
name: {
|
||||
type: 'JSXIdentifier',
|
||||
name: tagName,
|
||||
},
|
||||
attributes,
|
||||
},
|
||||
children,
|
||||
};
|
||||
}
|
6
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXExpressionContainerMock.js
generated
vendored
Normal file
6
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXExpressionContainerMock.js
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
export default function JSXExpressionContainerMock(exp) {
|
||||
return {
|
||||
type: 'JSXExpressionContainer',
|
||||
expression: exp,
|
||||
};
|
||||
}
|
12
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXSpreadAttributeMock.js
generated
vendored
Normal file
12
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXSpreadAttributeMock.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import IdentifierMock from './IdentifierMock';
|
||||
|
||||
export default function JSXSpreadAttributeMock(identifier: string) {
|
||||
return {
|
||||
type: 'JSXSpreadAttribute',
|
||||
argument: IdentifierMock(identifier),
|
||||
};
|
||||
}
|
10
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXTextMock.js
generated
vendored
Normal file
10
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/JSXTextMock.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
export default function JSXTextMock(value: string) {
|
||||
return {
|
||||
type: 'JSXText',
|
||||
value,
|
||||
raw: value,
|
||||
};
|
||||
}
|
10
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/LiteralMock.js
generated
vendored
Normal file
10
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/LiteralMock.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
export default function LiteralMock(value: string) {
|
||||
return {
|
||||
type: 'Literal',
|
||||
value,
|
||||
raw: value,
|
||||
};
|
||||
}
|
213
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/genInteractives.js
generated
vendored
Normal file
213
web/node_modules/eslint-plugin-jsx-a11y/__mocks__/genInteractives.js
generated
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import { dom, roles } from 'aria-query';
|
||||
import includes from 'array-includes';
|
||||
import JSXAttributeMock from './JSXAttributeMock';
|
||||
import JSXElementMock from './JSXElementMock';
|
||||
|
||||
import type { TJSXElementMock } from './JSXElementMock';
|
||||
|
||||
const domElements = [...dom.keys()];
|
||||
const roleNames = [...roles.keys()];
|
||||
|
||||
const interactiveElementsMap = {
|
||||
a: [{ prop: 'href', value: '#' }],
|
||||
area: [{ prop: 'href', value: '#' }],
|
||||
audio: [],
|
||||
button: [],
|
||||
canvas: [],
|
||||
datalist: [],
|
||||
embed: [],
|
||||
input: [],
|
||||
'input[type="button"]': [{ prop: 'type', value: 'button' }],
|
||||
'input[type="checkbox"]': [{ prop: 'type', value: 'checkbox' }],
|
||||
'input[type="color"]': [{ prop: 'type', value: 'color' }],
|
||||
'input[type="date"]': [{ prop: 'type', value: 'date' }],
|
||||
'input[type="datetime"]': [{ prop: 'type', value: 'datetime' }],
|
||||
'input[type="email"]': [{ prop: 'type', value: 'email' }],
|
||||
'input[type="file"]': [{ prop: 'type', value: 'file' }],
|
||||
'input[type="image"]': [{ prop: 'type', value: 'image' }],
|
||||
'input[type="month"]': [{ prop: 'type', value: 'month' }],
|
||||
'input[type="number"]': [{ prop: 'type', value: 'number' }],
|
||||
'input[type="password"]': [{ prop: 'type', value: 'password' }],
|
||||
'input[type="radio"]': [{ prop: 'type', value: 'radio' }],
|
||||
'input[type="range"]': [{ prop: 'type', value: 'range' }],
|
||||
'input[type="reset"]': [{ prop: 'type', value: 'reset' }],
|
||||
'input[type="search"]': [{ prop: 'type', value: 'search' }],
|
||||
'input[type="submit"]': [{ prop: 'type', value: 'submit' }],
|
||||
'input[type="tel"]': [{ prop: 'type', value: 'tel' }],
|
||||
'input[type="text"]': [{ prop: 'type', value: 'text' }],
|
||||
'input[type="time"]': [{ prop: 'type', value: 'time' }],
|
||||
'input[type="url"]': [{ prop: 'type', value: 'url' }],
|
||||
'input[type="week"]': [{ prop: 'type', value: 'week' }],
|
||||
link: [{ prop: 'href', value: '#' }],
|
||||
menuitem: [],
|
||||
option: [],
|
||||
select: [],
|
||||
summary: [],
|
||||
// Whereas ARIA makes a distinction between cell and gridcell, the AXObject
|
||||
// treats them both as CellRole and since gridcell is interactive, we consider
|
||||
// cell interactive as well.
|
||||
// td: [],
|
||||
th: [],
|
||||
tr: [],
|
||||
textarea: [],
|
||||
video: [],
|
||||
};
|
||||
|
||||
const nonInteractiveElementsMap: {[string]: Array<{[string]: string}>} = {
|
||||
abbr: [],
|
||||
aside: [],
|
||||
article: [],
|
||||
blockquote: [],
|
||||
body: [],
|
||||
br: [],
|
||||
caption: [],
|
||||
dd: [],
|
||||
details: [],
|
||||
dfn: [],
|
||||
dialog: [],
|
||||
dir: [],
|
||||
dl: [],
|
||||
dt: [],
|
||||
fieldset: [],
|
||||
figcaption: [],
|
||||
figure: [],
|
||||
footer: [],
|
||||
form: [],
|
||||
frame: [],
|
||||
h1: [],
|
||||
h2: [],
|
||||
h3: [],
|
||||
h4: [],
|
||||
h5: [],
|
||||
h6: [],
|
||||
hr: [],
|
||||
iframe: [],
|
||||
img: [],
|
||||
label: [],
|
||||
legend: [],
|
||||
li: [],
|
||||
main: [],
|
||||
mark: [],
|
||||
marquee: [],
|
||||
menu: [],
|
||||
meter: [],
|
||||
nav: [],
|
||||
ol: [],
|
||||
optgroup: [],
|
||||
output: [],
|
||||
p: [],
|
||||
pre: [],
|
||||
progress: [],
|
||||
ruby: [],
|
||||
'section[aria-label]': [{ prop: 'aria-label' }],
|
||||
'section[aria-labelledby]': [{ prop: 'aria-labelledby' }],
|
||||
table: [],
|
||||
tbody: [],
|
||||
td: [],
|
||||
tfoot: [],
|
||||
thead: [],
|
||||
time: [],
|
||||
ul: [],
|
||||
};
|
||||
|
||||
const indeterminantInteractiveElementsMap = domElements.reduce(
|
||||
(accumulator: { [key: string]: Array<any> }, name: string): { [key: string]: Array<any> } => ({
|
||||
...accumulator,
|
||||
[name]: [],
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
Object.keys(interactiveElementsMap)
|
||||
.concat(Object.keys(nonInteractiveElementsMap))
|
||||
.forEach((name: string) => delete indeterminantInteractiveElementsMap[name]);
|
||||
|
||||
const abstractRoles = roleNames.filter((role) => roles.get(role).abstract);
|
||||
|
||||
const nonAbstractRoles = roleNames.filter((role) => !roles.get(role).abstract);
|
||||
|
||||
const interactiveRoles = []
|
||||
.concat(
|
||||
roleNames,
|
||||
// 'toolbar' does not descend from widget, but it does support
|
||||
// aria-activedescendant, thus in practice we treat it as a widget.
|
||||
'toolbar',
|
||||
)
|
||||
.filter((role) => !roles.get(role).abstract)
|
||||
.filter((role) => roles.get(role).superClass.some((klasses) => includes(klasses, 'widget')));
|
||||
|
||||
const nonInteractiveRoles = roleNames
|
||||
.filter((role) => !roles.get(role).abstract)
|
||||
.filter((role) => !roles.get(role).superClass.some((klasses) => includes(klasses, 'widget')))
|
||||
// 'toolbar' does not descend from widget, but it does support
|
||||
// aria-activedescendant, thus in practice we treat it as a widget.
|
||||
.filter((role) => !includes(['toolbar'], role));
|
||||
|
||||
export function genElementSymbol(openingElement: Object) {
|
||||
return (
|
||||
openingElement.name.name + (openingElement.attributes.length > 0
|
||||
? `${openingElement.attributes
|
||||
.map((attr) => `[${attr.name.name}="${attr.value.value}"]`)
|
||||
.join('')}`
|
||||
: ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function genInteractiveElements(): Array<TJSXElementMock> {
|
||||
return Object.keys(interactiveElementsMap).map((elementSymbol: string): TJSXElementMock => {
|
||||
const bracketIndex = elementSymbol.indexOf('[');
|
||||
let name = elementSymbol;
|
||||
if (bracketIndex > -1) {
|
||||
name = elementSymbol.slice(0, bracketIndex);
|
||||
}
|
||||
const attributes = interactiveElementsMap[elementSymbol].map(({ prop, value }) => JSXAttributeMock(prop, value));
|
||||
return JSXElementMock(name, attributes);
|
||||
});
|
||||
}
|
||||
|
||||
export function genInteractiveRoleElements(): Array<TJSXElementMock> {
|
||||
return [...interactiveRoles, 'button article', 'fakerole button article'].map((value): TJSXElementMock => JSXElementMock(
|
||||
'div',
|
||||
[JSXAttributeMock('role', value)],
|
||||
));
|
||||
}
|
||||
|
||||
export function genNonInteractiveElements(): Array<TJSXElementMock> {
|
||||
return Object.keys(nonInteractiveElementsMap).map((elementSymbol): TJSXElementMock => {
|
||||
const bracketIndex = elementSymbol.indexOf('[');
|
||||
let name = elementSymbol;
|
||||
if (bracketIndex > -1) {
|
||||
name = elementSymbol.slice(0, bracketIndex);
|
||||
}
|
||||
const attributes = nonInteractiveElementsMap[elementSymbol].map(({ prop, value }) => JSXAttributeMock(prop, value));
|
||||
return JSXElementMock(name, attributes);
|
||||
});
|
||||
}
|
||||
|
||||
export function genNonInteractiveRoleElements() {
|
||||
return [
|
||||
...nonInteractiveRoles,
|
||||
'article button',
|
||||
'fakerole article button',
|
||||
].map((value) => JSXElementMock('div', [JSXAttributeMock('role', value)]));
|
||||
}
|
||||
|
||||
export function genAbstractRoleElements() {
|
||||
return abstractRoles.map((value) => JSXElementMock('div', [JSXAttributeMock('role', value)]));
|
||||
}
|
||||
|
||||
export function genNonAbstractRoleElements() {
|
||||
return nonAbstractRoles.map((value) => JSXElementMock('div', [JSXAttributeMock('role', value)]));
|
||||
}
|
||||
|
||||
export function genIndeterminantInteractiveElements(): Array<TJSXElementMock> {
|
||||
return Object.keys(indeterminantInteractiveElementsMap).map((name) => {
|
||||
const attributes = indeterminantInteractiveElementsMap[name].map(({ prop, value }): TJSXElementMock => JSXAttributeMock(prop, value));
|
||||
return JSXElementMock(name, attributes);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue