Skip to content

Commit de25830

Browse files
authored
Merge pull request #451 from ljharb/eslint_5
[New] eslint ^5 support
2 parents a54f52f + adc0d80 commit de25830

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+177
-177
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"flowtype"
99
],
1010
rules: {
11-
'no-template-curly-in-string': 'off'
11+
'max-len': 'off',
12+
'no-template-curly-in-string': 'off',
1213
}
1314
}

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ cache:
1111
yarn: true
1212
directories:
1313
- node_modules
14+
before_script:
15+
- if [ -n "${ESLINT-}" ]; then npm uninstall --no-save eslint-config-airbnb-base && npm install --no-save "eslint@${ESLINT}"; fi
1416
script:
1517
- if [ "${FLOW-}" = true ]; then npm run flow; fi
1618
- if [ "${LINT-}" = true ]; then npm run lint; fi
@@ -21,13 +23,22 @@ sudo: false
2123
env:
2224
global:
2325
- TEST=true
26+
matrix:
27+
- ESLINT=5
28+
- ESLINT=4
29+
- ESLINT=3
2430
matrix:
2531
fast_finish: true
2632
include:
2733
- node_js: "node"
2834
env: FLOW=true TEST=false
2935
- node_js: "node"
3036
env: LINT=true TEST=false
37+
exclude:
38+
- node_js: "5"
39+
env: ESLINT=5
40+
- node_js: "4"
41+
env: ESLINT=5
3142
allow_failures:
3243
- node_js: "9"
3344
- node_js: "7"

__mocks__/genInteractives.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ const nonInteractiveRoles = roleNames
140140

141141
export function genElementSymbol(openingElement: Object) {
142142
return (
143-
openingElement.name.name +
144-
(openingElement.attributes.length > 0
143+
openingElement.name.name + (openingElement.attributes.length > 0
145144
? `${openingElement.attributes
146145
.map(attr => `[${attr.name.name}="${attr.value.value}"]`)
147146
.join('')}`
148-
: '')
147+
: ''
148+
)
149149
);
150150
}
151151

@@ -156,15 +156,16 @@ export function genInteractiveElements() {
156156
if (bracketIndex > -1) {
157157
name = elementSymbol.slice(0, bracketIndex);
158158
}
159-
const attributes = interactiveElementsMap[elementSymbol].map(({ prop, value }) =>
160-
JSXAttributeMock(prop, value));
159+
const attributes = interactiveElementsMap[elementSymbol].map(({ prop, value }) => JSXAttributeMock(prop, value));
161160
return JSXElementMock(name, attributes);
162161
});
163162
}
164163

165164
export function genInteractiveRoleElements() {
166-
return [...interactiveRoles, 'button article', 'fakerole button article'].map(value =>
167-
JSXElementMock('div', [JSXAttributeMock('role', value)]));
165+
return [...interactiveRoles, 'button article', 'fakerole button article'].map(value => JSXElementMock(
166+
'div',
167+
[JSXAttributeMock('role', value)],
168+
));
168169
}
169170

170171
export function genNonInteractiveElements() {
@@ -174,15 +175,17 @@ export function genNonInteractiveElements() {
174175
if (bracketIndex > -1) {
175176
name = elementSymbol.slice(0, bracketIndex);
176177
}
177-
const attributes = nonInteractiveElementsMap[elementSymbol].map(({ prop, value }) =>
178-
JSXAttributeMock(prop, value));
178+
const attributes = nonInteractiveElementsMap[elementSymbol].map(({ prop, value }) => JSXAttributeMock(prop, value));
179179
return JSXElementMock(name, attributes);
180180
});
181181
}
182182

183183
export function genNonInteractiveRoleElements() {
184-
return [...nonInteractiveRoles, 'article button', 'fakerole article button'].map(value =>
185-
JSXElementMock('div', [JSXAttributeMock('role', value)]));
184+
return [
185+
...nonInteractiveRoles,
186+
'article button',
187+
'fakerole article button',
188+
].map(value => JSXElementMock('div', [JSXAttributeMock('role', value)]));
186189
}
187190

188191
export function genAbstractRoleElements() {
@@ -195,8 +198,7 @@ export function genNonAbstractRoleElements() {
195198

196199
export function genIndeterminantInteractiveElements() {
197200
return Object.keys(indeterminantInteractiveElementsMap).map((name) => {
198-
const attributes = indeterminantInteractiveElementsMap[name].map(({ prop, value }) =>
199-
JSXAttributeMock(prop, value));
201+
const attributes = indeterminantInteractiveElementsMap[name].map(({ prop, value }) => JSXAttributeMock(prop, value));
200202
return JSXElementMock(name, attributes);
201203
});
202204
}

__tests__/src/rules/anchor-is-valid-test.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ import rule from '../../../src/rules/anchor-is-valid';
1818

1919
const ruleTester = new RuleTester();
2020

21-
const preferButtonErrorMessage = 'Anchor used as a button. ' +
22-
'Anchors are primarily expected to navigate. ' +
23-
'Use the button element instead.';
21+
const preferButtonErrorMessage = 'Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead.';
2422

25-
const noHrefErrorMessage = 'The href attribute is required on an anchor. ' +
26-
'Provide a valid, navigable address as the href value.';
23+
const noHrefErrorMessage = 'The href attribute is required on an anchor. Provide a valid, navigable address as the href value.';
2724

28-
const invalidHrefErrorMessage = 'The href attribute requires a valid address. ' +
29-
'Provide a valid, navigable address as the href value.';
25+
const invalidHrefErrorMessage = 'The href attribute requires a valid address. Provide a valid, navigable address as the href value.';
3026

3127
const preferButtonexpectedError = {
3228
message: preferButtonErrorMessage,

__tests__/src/rules/aria-activedescendant-has-tabindex-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import rule from '../../../src/rules/aria-activedescendant-has-tabindex';
1818
const ruleTester = new RuleTester();
1919

2020
const expectedError = {
21-
message: 'An element that manages focus with `aria-activedescendant` ' +
22-
'must be tabbable',
21+
message: 'An element that manages focus with `aria-activedescendant` must be tabbable',
2322
type: 'JSXOpeningElement',
2423
};
2524

__tests__/src/rules/aria-proptypes-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import { aria } from 'aria-query';
1212
import { RuleTester } from 'eslint';
1313
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
14-
import rule, { validityCheck } from '../../../src/rules/aria-proptypes';
14+
import rule from '../../../src/rules/aria-proptypes';
15+
16+
const { validityCheck } = rule;
1517

1618
// -----------------------------------------------------------------------------
1719
// Tests

__tests__/src/rules/click-events-have-key-events-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import rule from '../../../src/rules/click-events-have-key-events';
1818

1919
const ruleTester = new RuleTester();
2020

21-
const errorMessage = 'Visible, non-interactive elements with click handlers' +
22-
' must have at least one keyboard listener.';
21+
const errorMessage = 'Visible, non-interactive elements with click handlers must have at least one keyboard listener.';
2322

2423
const expectedError = {
2524
message: errorMessage,

__tests__/src/rules/img-redundant-alt-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ const array = [{
2424
const ruleTester = new RuleTester();
2525

2626
const expectedError = {
27-
message: 'Redundant alt attribute. Screen-readers already announce `img` tags as an image. ' +
28-
'You don\'t need to use the words `image`, `photo,` or `picture` ' +
29-
'(or any specified custom words) in the alt prop.',
27+
message: 'Redundant alt attribute. Screen-readers already announce `img` tags as an image. You don’t need to use the words `image`, `photo,` or `picture` (or any specified custom words) in the alt prop.',
3028
type: 'JSXOpeningElement',
3129
};
3230

__tests__/src/rules/interactive-supports-focus-test.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,13 @@ function template(strings, ...keys) {
3535
const ruleName = 'interactive-supports-focus';
3636
const type = 'JSXOpeningElement';
3737
const codeTemplate = template`<${0} role="${1}" ${2}={() => void 0} />`;
38-
const tabindexTemplate =
39-
template`<${0} role="${1}" ${2}={() => void 0} tabIndex="0" />`;
38+
const tabindexTemplate = template`<${0} role="${1}" ${2}={() => void 0} tabIndex="0" />`;
4039
const tabbableTemplate = template`Elements with the '${0}' interactive role must be tabbable.`;
4140
const focusableTemplate = template`Elements with the '${0}' interactive role must be focusable.`;
4241

43-
const recommendedOptions =
44-
(configs.recommended.rules[`jsx-a11y/${ruleName}`][1] || {});
42+
const recommendedOptions = configs.recommended.rules[`jsx-a11y/${ruleName}`][1] || {};
4543

46-
const strictOptions =
47-
(configs.strict.rules[`jsx-a11y/${ruleName}`][1] || {});
44+
const strictOptions = configs.strict.rules[`jsx-a11y/${ruleName}`][1] || {};
4845

4946
const alwaysValid = [
5047
{ code: '<div />' },
@@ -170,25 +167,29 @@ const triggeringHandlers = [
170167
...eventHandlersByType.keyboard,
171168
];
172169

173-
const passReducer = (roles, handlers, messageTemplate) =>
174-
staticElements.reduce((elementAcc, element) =>
175-
elementAcc.concat(roles.reduce((roleAcc, role) =>
176-
roleAcc.concat(handlers
177-
.map(handler => ({
178-
code: messageTemplate(element, role, handler),
179-
}))), [])), []);
180-
181-
const failReducer = (roles, handlers, messageTemplate) =>
182-
staticElements.reduce((elementAcc, element) =>
183-
elementAcc.concat(roles.reduce((roleAcc, role) =>
184-
roleAcc.concat(handlers
185-
.map(handler => ({
186-
code: codeTemplate(element, role, handler),
187-
errors: [{
188-
type,
189-
message: messageTemplate(role),
190-
}],
191-
}))), [])), []);
170+
const passReducer = (roles, handlers, messageTemplate) => (
171+
staticElements.reduce((elementAcc, element) => (
172+
elementAcc.concat(roles.reduce((roleAcc, role) => (
173+
roleAcc.concat(handlers.map(handler => ({
174+
code: messageTemplate(element, role, handler),
175+
})))
176+
), []))
177+
), [])
178+
);
179+
180+
const failReducer = (roles, handlers, messageTemplate) => (
181+
staticElements.reduce((elementAcc, element) => (
182+
elementAcc.concat(roles.reduce((roleAcc, role) => (
183+
roleAcc.concat(handlers.map(handler => ({
184+
code: codeTemplate(element, role, handler),
185+
errors: [{
186+
type,
187+
message: messageTemplate(role),
188+
}],
189+
})))
190+
), []))
191+
), [])
192+
);
192193

193194
ruleTester.run(`${ruleName}:recommended`, rule, {
194195
valid: [

__tests__/src/rules/no-access-key-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import rule from '../../../src/rules/no-access-key';
1919
const ruleTester = new RuleTester();
2020

2121
const expectedError = {
22-
message: 'No access key attribute allowed. Inconsistencies ' +
23-
'between keyboard shortcuts and keyboard comments used by screenreader ' +
24-
'and keyboard only users create a11y complications.',
22+
message: 'No access key attribute allowed. Inconsistencies between keyboard shortcuts and keyboard comments used by screenreader and keyboard only users create a11y complications.',
2523
type: 'JSXOpeningElement',
2624
};
2725

0 commit comments

Comments
 (0)