Skip to content

Commit

Permalink
[tests] add test for es6-react prettier formated
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Mollweide committed Jul 18, 2017
1 parent 3367b38 commit 9843c0f
Show file tree
Hide file tree
Showing 61 changed files with 1,802 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"lint": "npm run lint:js",
"lint:js": "node_modules/.bin/eslint .",
"test": "npm run lint",
"prettier": "yarn prettier:es5 && yarn prettier:es5node && yarn prettier:es6",
"prettier": "npm run prettier:es5 && npm run prettier:es5node && npm run prettier:es6 && npm run prettier:es6react",
"prettier:es5": "node_modules/.bin/prettier --write \"test/es5-disable-styles/**/*.js\"",
"prettier:es5node": "node_modules/.bin/prettier --write \"test/es5-node-disable-styles/**/*.js\"",
"prettier:es6": "node_modules/.bin/prettier --write \"test/es6-disable-styles/**/*.js\""
"prettier:es6": "node_modules/.bin/prettier --write \"test/es6-disable-styles/**/*.js\"",
"prettier:es6react": "node_modules/.bin/prettier --write \"test/es6-react-disable-styles/**/*.js\""
},
"keywords": [
"code checker",
Expand Down
6 changes: 6 additions & 0 deletions test/es6-react-disable-styles/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: [
"../../configurations/es6-react.js",
"../../configurations/es6-react-disable-styles.js",
],
};
30 changes: 30 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/aria-props.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// DESCRIPTION = Enforce all aria-* props are valid.
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint react/jsx-indent: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
<div id="address_label">Enter your address</div>;
<input aria-labeledby="address_label" />;
*/

// Good
<div id="address_label">Enter your address</div>;
<input aria-labelledby="address_label" />;
// END!>
27 changes: 27 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/aria-proptypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// DESCRIPTION = Enforce ARIA state and property values are valid.
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
<span aria-hidden="yes">foo</span>;
*/

// Good
<span aria-hidden="true">foo</span>;
// END!>
33 changes: 33 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/aria-role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// DESCRIPTION = Require ARIA roles to be valid and non-abstract
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/self-closing-comp: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
/* eslint react/jsx-indent: 0*/
// <!START
// Bad
/*
<div role="datepicker"></div>;
<div role="range"></div>;
<div role=""></div>;
*/

// Good
<div role="button" />;
<div role={role} />;
<div />;
// END!>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint max-len: 0*/
// DESCRIPTION = Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes.
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
<meta aria-hidden="false" charSet="UTF-8" />;
*/

// Good
<meta charSet="UTF-8" />;
// END!>
31 changes: 31 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/href-no-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// DESCRIPTION = disallow href "#"
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
/* eslint react/jsx-indent: 0*/
// <!START
// Bad
<a href="#" />;
<a href={"#"} />;
<a href={"#"} />;

// Good
<a href="https://github.com" />;
<a href="#section" />;
<a href="foo" />;
<a href={undefined} />;
// END!>
31 changes: 31 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/img-has-alt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// DESCRIPTION = Require <img> to have a non-empty `alt` prop, or role="presentation"
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
function Foo(src) {
return <img src={src} />;
}
*/

// Good
function Foo({ alt, src }) {
return <img alt={alt} src={src} />;
}
// END!>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// DESCRIPTION = Prevent img alt text from containing redundant words like "image", "picture", or "photo"
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
/* eslint react/jsx-indent: 0*/
// <!START
// Bad
/*
<img alt="Photo of foo being weird." src="foo" />;
<img alt="Image of me at a bar!" src="bar" />;
<img alt="Picture of baz fixing a bug." src="baz" />;
*/

// Good
<img alt="Foo eating a sandwich." src="foo" />;
<img aria-hidden alt="Picture of me taking a photo of an image" src="bar" />;
<img alt={`Baz taking a ${photo}`} src="baz" />;
// END!>
31 changes: 31 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/label-has-for.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// DESCRIPTION = require that JSX labels use "htmlFor"
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
function Foo(props) {
return <label {...props} />;
}
*/

// Good
function Foo({ htmlFor, props }) {
return <label htmlFor={htmlFor} {...props} />;
}
// END!>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// DESCRIPTION = require that mouseover/out come with focus/blur, for keyboard-only users
// STATUS = 0

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint react/jsx-sort-props: 0*/
/* eslint object-shorthand: 0*/
/* eslint react/jsx-indent: 0*/
// <!START
// Bad
<div onMouseOver={() => {}} />;
<div onMouseOut={() => {}} />;
<div onMouseOver={() => {}} />;
<div onMouseOut={() => {}} />;

// Good
<div onMouseOver={() => {}} onFocus={() => {}} />;
<div onMouseOut={() => {}} onBlur={() => {}} />;
<div onMouseOver={() => {}} onFocus={() => {}} />;
<div onMouseOut={() => {}} onBlur={() => {}} />;
// END!>
27 changes: 27 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/no-access-key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// DESCRIPTION = Prevent use of `accessKey`
// STATUS = 2

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
/*
<div accessKey="h" />;
*/

// Good
<div />;
// END!>
31 changes: 31 additions & 0 deletions test/es6-react-disable-styles/rules/react-a11y/no-onchange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// DESCRIPTION = require onBlur instead of onChange
// STATUS = 0

/* eslint require-jsdoc: 0*/
/* eslint no-use-before-define: 0*/
/* eslint no-undef: 0*/
/* eslint no-unused-vars: 0*/
/* eslint no-unreachable: 0*/
/* eslint no-empty: 0*/
/* eslint no-empty-function: 0*/
/* eslint no-shadow: 0*/
/* eslint no-redeclare: 0*/
/* eslint no-unused-expressions: 0*/
/* eslint react/react-in-jsx-scope: 0*/
/* eslint react/prefer-stateless-function: 0*/
/* eslint react/prefer-es6-class: 0*/
/* eslint react/prop-types: 0*/
/* eslint object-shorthand: 0*/
// <!START
// Bad
<select onChange={updateModel} />;

// Good
<select onBlur={updateModel}>
<option />
</select>;

<select>
<option onBlur={handleOnBlur} onChange={handleOnChange} />
</select>;
// END!>
Loading

0 comments on commit 9843c0f

Please sign in to comment.