Skip to content

Commit ef01959

Browse files
committed
Reverts back to 6076fe5
This reverts the following commits: - 131a75d (tag: v6.0.0, tag: v5.1.0) Added thanks to mjaltamirano in CHANGELOG - e621917 Removed two references to href-no-hash in README - 91c6b46 Removed v2 for peer dependency ESLint - a146175 Remove href-no-hash rule - 5755a1d 6.0.0 - 67813b7 Changelog for v6.0.0 - d7cfe54 Merge pull request #259 from mjaltamirano/label-has-for-update
1 parent 131a75d commit ef01959

File tree

11 files changed

+325
-111
lines changed

11 files changed

+325
-111
lines changed

CHANGELOG.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
6.0.0 / 2017-06-05
2-
=================
3-
- [new] Add rule `anchor-is-valid`. See documentation for configuration options. Thanks @AlmeroSteyn.
4-
- [breaking] `href-no-hash` replaced with `anchor-is-valid` in the recommended and strict configs. Use the `invalidHref` aspect (active by default) in `anchor-is-valid` to continue to apply the behavior provided by `href-no-hash`.
5-
- [breaking] Removed support for ESLint peer dependency at version ^2.10.2.
6-
- [update] The rule `label-has-for` now allows inputs nested in label tags. Previously it was strict about requiring a `for` attribute. Thanks @ignatiusreza and @mjaltamirano.
7-
- [update] New configuration for `interactive-supports-focus`. Recommended and strict configs for now contain a trimmed-down whitelist of roles that will be checked.
8-
- [fix] Incompatibility between node version 4 and 5. Thanks @evilebottnawi.
9-
- [fix] Missing README entry for `media-has-caption`. Thanks @ismail-syed.
10-
- [fix] README updates explaining recommended and strict configs. Thanks @Donaldini.
11-
- [fix] Updated to [email protected], which includes new ARIA 1.1 properties. Previously, the `aria-props` rule incorrectly threw errors for these new properties.
12-
131
5.0.3 / 2017-05-16
142
==================
153
- [fix] Remove `flow` directory from `.npmignore` to accommodate explicit imports from `v5.0.2`.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Add `plugin:jsx-a11y/recommended` or `plugin:jsx-a11y/strict` in `extends`:
103103
- [aria-unsupported-elements](docs/rules/aria-unsupported-elements.md): Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
104104
- [click-events-have-key-events](docs/rules/click-events-have-key-events.md): Enforce a clickable non-interactive element has at least one keyboard event listener.
105105
- [heading-has-content](docs/rules/heading-has-content.md): Enforce heading (`h1`, `h2`, etc) elements contain accessible content.
106+
- [href-no-hash](docs/rules/href-no-hash.md): Enforce an anchor element's `href` prop value is not just `#`.
106107
- [html-has-lang](docs/rules/html-has-lang.md): Enforce `<html>` element has `lang` prop.
107108
- [iframe-has-title](docs/rules/iframe-has-title.md): Enforce iframe elements have a title attribute.
108109
- [img-redundant-alt](docs/rules/img-redundant-alt.md): Enforce `<img>` alt prop does not contain the word "image", "picture", or "photo".
@@ -133,14 +134,14 @@ Rule | Recommended | Strict
133134
[accessible-emoji](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md) | error | error
134135
[alt-text](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md) | error | error
135136
[anchor-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md) | error | error
136-
[anchor-is-valid](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md) | error | error
137137
[aria-activedescendant-has-tabindex](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md) | error | error
138138
[aria-props](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md) | error | error
139139
[aria-proptypes](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md) | error | error
140140
[aria-role](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md) | error | error
141141
[aria-unsupported-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md) | error | error
142142
[click-events-have-key-events](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md) | error | error
143143
[heading-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md) | error | error
144+
[href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md) | error | error
144145
[html-has-lang](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md) | error | error
145146
[iframe-has-title](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md) | error | error
146147
[img-redundant-alt](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md) | error | error

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const componentsAndSpecialLinkAndNoHrefAspect = [{
8686
ruleTester.run('anchor-is-valid', rule, {
8787
valid: [
8888
// DEFAULT ELEMENT 'a' TESTS
89-
{ code: '<Anchor />;' },
9089
{ code: '<a {...props} />' },
9190
{ code: '<a href="foo" />' },
9291
{ code: '<a href={foo} />' },
@@ -251,6 +250,7 @@ ruleTester.run('anchor-is-valid', rule, {
251250
{ code: '<a href="javascript:void(0)" />', options: noHrefPreferButtonAspect },
252251
{ code: '<a href={"javascript:void(0)"} />', options: noHrefPreferButtonAspect },
253252

253+
254254
// SHOULD BE BUTTON
255255
{ code: '<a onClick={() => void 0} />', options: invalidHrefAspect },
256256
{ code: '<a href="#" onClick={() => void 0} />', options: noHrefAspect },
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/* eslint-env jest */
2+
/**
3+
* @fileoverview Enforce links may not point to just #.
4+
* @author Ethan Cohen
5+
*/
6+
7+
// -----------------------------------------------------------------------------
8+
// Requirements
9+
// -----------------------------------------------------------------------------
10+
11+
import { RuleTester } from 'eslint';
12+
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
13+
import rule from '../../../src/rules/href-no-hash';
14+
15+
// -----------------------------------------------------------------------------
16+
// Tests
17+
// -----------------------------------------------------------------------------
18+
19+
const ruleTester = new RuleTester();
20+
21+
const expectedError = {
22+
message: 'Links must not point to "#". Use a more descriptive href or use a button instead.',
23+
type: 'JSXOpeningElement',
24+
};
25+
26+
const components = [{
27+
components: ['Anchor', 'Link'],
28+
}];
29+
const specialLink = [{
30+
specialLink: ['hrefLeft', 'hrefRight'],
31+
}];
32+
const componentsAndSpecialLink = [{
33+
components: ['Anchor'],
34+
specialLink: ['hrefLeft'],
35+
}];
36+
37+
ruleTester.run('href-no-hash', rule, {
38+
valid: [
39+
// DEFAULT ELEMENT 'a' TESTS
40+
{ code: '<Anchor />;' },
41+
{ code: '<a {...props} />' },
42+
{ code: '<a href="foo" />' },
43+
{ code: '<a href={foo} />' },
44+
{ code: '<a href="/foo" />' },
45+
{ code: '<a href={`${undefined}`} />' },
46+
{ code: '<div href="foo" />' },
47+
{ code: '<a href={`${undefined}foo`}/>' },
48+
{ code: '<a href={`#${undefined}foo`}/>' },
49+
{ code: '<a href={`#foo`}/>' },
50+
{ code: '<a href={"foo"}/>' },
51+
{ code: '<a href="#foo" />' },
52+
{ code: '<UX.Layout>test</UX.Layout>' },
53+
{ code: '<a href={this} />' },
54+
55+
// CUSTOM ELEMENT TEST FOR ARRAY OPTION
56+
{ code: '<Anchor />;', options: components },
57+
{ code: '<Anchor {...props} />', options: components },
58+
{ code: '<Anchor href="foo" />', options: components },
59+
{ code: '<Anchor href={foo} />', options: components },
60+
{ code: '<Anchor href="/foo" />', options: components },
61+
{ code: '<Anchor href={`${undefined}`} />', options: components },
62+
{ code: '<div href="foo" />', options: components },
63+
{ code: '<Anchor href={`${undefined}foo`}/>', options: components },
64+
{ code: '<Anchor href={`#${undefined}foo`}/>', options: components },
65+
{ code: '<Anchor href={`#foo`}/>', options: components },
66+
{ code: '<Anchor href={"foo"}/>', options: components },
67+
{ code: '<Anchor href="#foo" />', options: components },
68+
{ code: '<Link />;', options: components },
69+
{ code: '<Link {...props} />', options: components },
70+
{ code: '<Link href="foo" />', options: components },
71+
{ code: '<Link href={foo} />', options: components },
72+
{ code: '<Link href="/foo" />', options: components },
73+
{ code: '<Link href={`${undefined}`} />', options: components },
74+
{ code: '<div href="foo" />', options: components },
75+
{ code: '<Link href={`${undefined}foo`}/>', options: components },
76+
{ code: '<Link href={`#${undefined}foo`}/>', options: components },
77+
{ code: '<Link href={`#foo`}/>', options: components },
78+
{ code: '<Link href={"foo"}/>', options: components },
79+
{ code: '<Link href="#foo" />', options: components },
80+
81+
// CUSTOM PROP TESTS
82+
{ code: '<a />;', options: specialLink },
83+
{ code: '<a {...props} />', options: specialLink },
84+
{ code: '<a hrefLeft="foo" />', options: specialLink },
85+
{ code: '<a hrefLeft={foo} />', options: specialLink },
86+
{ code: '<a hrefLeft="/foo" />', options: specialLink },
87+
{ code: '<a hrefLeft={`${undefined}`} />', options: specialLink },
88+
{ code: '<div hrefLeft="foo" />', options: specialLink },
89+
{ code: '<a hrefLeft={`${undefined}foo`}/>', options: specialLink },
90+
{ code: '<a hrefLeft={`#${undefined}foo`}/>', options: specialLink },
91+
{ code: '<a hrefLeft={`#foo`}/>', options: specialLink },
92+
{ code: '<a hrefLeft={"foo"}/>', options: specialLink },
93+
{ code: '<a hrefLeft="#foo" />', options: specialLink },
94+
{ code: '<UX.Layout>test</UX.Layout>', options: specialLink },
95+
{ code: '<a hrefRight={this} />', options: specialLink },
96+
{ code: '<a />;', options: specialLink },
97+
{ code: '<a {...props} />', options: specialLink },
98+
{ code: '<a hrefRight="foo" />', options: specialLink },
99+
{ code: '<a hrefRight={foo} />', options: specialLink },
100+
{ code: '<a hrefRight="/foo" />', options: specialLink },
101+
{ code: '<a hrefRight={`${undefined}`} />', options: specialLink },
102+
{ code: '<div hrefRight="foo" />', options: specialLink },
103+
{ code: '<a hrefRight={`${undefined}foo`}/>', options: specialLink },
104+
{ code: '<a hrefRight={`#${undefined}foo`}/>', options: specialLink },
105+
{ code: '<a hrefRight={`#foo`}/>', options: specialLink },
106+
{ code: '<a hrefRight={"foo"}/>', options: specialLink },
107+
{ code: '<a hrefRight="#foo" />', options: specialLink },
108+
{ code: '<UX.Layout>test</UX.Layout>', options: specialLink },
109+
{ code: '<a hrefRight={this} />', options: specialLink },
110+
111+
// CUSTOM BOTH COMPONENTS AND SPECIALLINK TESTS
112+
{ code: '<Anchor />;', options: componentsAndSpecialLink },
113+
{ code: '<Anchor {...props} />', options: componentsAndSpecialLink },
114+
{ code: '<Anchor hrefLeft="foo" />', options: componentsAndSpecialLink },
115+
{ code: '<Anchor hrefLeft={foo} />', options: componentsAndSpecialLink },
116+
{ code: '<Anchor hrefLeft="/foo" />', options: componentsAndSpecialLink },
117+
{ code: '<Anchor hrefLeft={`${undefined}`} />', options: componentsAndSpecialLink },
118+
{ code: '<div hrefLeft="foo" />', options: componentsAndSpecialLink },
119+
{ code: '<Anchor hrefLeft={`${undefined}foo`}/>', options: componentsAndSpecialLink },
120+
{ code: '<Anchor hrefLeft={`#${undefined}foo`}/>', options: componentsAndSpecialLink },
121+
{ code: '<Anchor hrefLeft={`#foo`}/>', options: componentsAndSpecialLink },
122+
{ code: '<Anchor hrefLeft={"foo"}/>', options: componentsAndSpecialLink },
123+
{ code: '<Anchor hrefLeft="#foo" />', options: componentsAndSpecialLink },
124+
{ code: '<UX.Layout>test</UX.Layout>', options: componentsAndSpecialLink },
125+
].map(parserOptionsMapper),
126+
invalid: [
127+
// DEFAULT ELEMENT 'a' TESTS
128+
{ code: '<a href="#" />', errors: [expectedError] },
129+
{ code: '<a href={"#"} />', errors: [expectedError] },
130+
{ code: '<a href={`#${undefined}`} />', errors: [expectedError] },
131+
132+
// CUSTOM ELEMENT TEST FOR ARRAY OPTION
133+
{ code: '<Link href="#" />', errors: [expectedError], options: components },
134+
{ code: '<Link href={"#"} />', errors: [expectedError], options: components },
135+
{
136+
code: '<Link href={`#${undefined}`} />',
137+
errors: [expectedError],
138+
options: components,
139+
},
140+
{ code: '<Anchor href="#" />', errors: [expectedError], options: components },
141+
{ code: '<Anchor href={"#"} />', errors: [expectedError], options: components },
142+
{
143+
code: '<Anchor href={`#${undefined}`} />',
144+
errors: [expectedError],
145+
options: components,
146+
},
147+
148+
// CUSTOM PROP TESTS
149+
{ code: '<a hrefLeft="#" />', errors: [expectedError], options: specialLink },
150+
{ code: '<a hrefLeft={"#"} />', errors: [expectedError], options: specialLink },
151+
{
152+
code: '<a hrefLeft={`#${undefined}`} />',
153+
errors: [expectedError],
154+
options: specialLink,
155+
},
156+
{ code: '<a hrefRight="#" />', errors: [expectedError], options: specialLink },
157+
{ code: '<a hrefRight={"#"} />', errors: [expectedError], options: specialLink },
158+
{
159+
code: '<a hrefRight={`#${undefined}`} />',
160+
errors: [expectedError],
161+
options: specialLink,
162+
},
163+
164+
// CUSTOM BOTH COMPONENTS AND SPECIALLINK TESTS
165+
{ code: '<Anchor hrefLeft="#" />', errors: [expectedError], options: componentsAndSpecialLink },
166+
{ code: '<Anchor hrefLeft={"#"} />', errors: [expectedError], options: componentsAndSpecialLink },
167+
{
168+
code: '<Anchor hrefLeft={`#${undefined}`} />',
169+
errors: [expectedError],
170+
options: componentsAndSpecialLink,
171+
},
172+
].map(parserOptionsMapper),
173+
});

0 commit comments

Comments
 (0)