Skip to content

Commit 0c979f1

Browse files
committed
Add rule no-noninteractive-element-handlers
1 parent ba8db40 commit 0c979f1

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-env jest */
2+
/**
3+
* @fileoverview $DESCRIPTION
4+
* @author $AUTHOR
5+
*/
6+
7+
// -----------------------------------------------------------------------------
8+
// Requirements
9+
// -----------------------------------------------------------------------------
10+
11+
import { RuleTester } from 'eslint';
12+
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
13+
import rule from '../../../src/rules/no-noninteractive-element-handlers';
14+
15+
// -----------------------------------------------------------------------------
16+
// Tests
17+
// -----------------------------------------------------------------------------
18+
19+
const ruleTester = new RuleTester();
20+
21+
const expectedError = {
22+
message: '',
23+
type: 'JSXOpeningElement',
24+
};
25+
26+
ruleTester.run('no-noninteractive-element-handlers', rule, {
27+
valid: [
28+
{ code: '<div />;' },
29+
].map(parserOptionsMapper),
30+
invalid: [].map(parserOptionsMapper),
31+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# no-noninteractive-element-handlers
2+
3+
Write a useful explanation here!
4+
5+
#### References
6+
1.
7+
8+
## Rule details
9+
10+
This rule takes no arguments.
11+
12+
### Succeed
13+
```jsx
14+
<div />
15+
```
16+
17+
### Fail
18+
```jsx
19+
20+
```

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = {
2222
'no-access-key': require('./rules/no-access-key'),
2323
'no-autofocus': require('./rules/no-autofocus'),
2424
'no-distracting-elements': require('./rules/no-distracting-elements'),
25+
'no-noninteractive-element-handlers': require('./rules/no-noninteractive-element-handlers'),
2526
'no-onchange': require('./rules/no-onchange'),
2627
'no-redundant-roles': require('./rules/no-redundant-roles'),
2728
'no-static-element-interactions': require('./rules/no-static-element-interactions'),
@@ -59,6 +60,7 @@ module.exports = {
5960
'jsx-a11y/no-access-key': 'error',
6061
'jsx-a11y/no-autofocus': 'error',
6162
'jsx-a11y/no-distracting-elements': 'error',
63+
'jsx-a11y/no-noninteractive-element-handlers': 'error',
6264
'jsx-a11y/no-onchange': 'error',
6365
'jsx-a11y/no-redundant-roles': 'error',
6466
'jsx-a11y/no-static-element-interactions': 'warn',
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @fileoverview $DESCRIPTION
3+
* @author $AUTHOR
4+
* @flow
5+
*/
6+
7+
// ----------------------------------------------------------------------------
8+
// Rule Definition
9+
// ----------------------------------------------------------------------------
10+
11+
import type { JSXOpeningElement } from 'ast-types-flow';
12+
import { generateObjSchema } from '../util/schemas';
13+
14+
const errorMessage = '';
15+
16+
const schema = generateObjSchema();
17+
18+
module.exports = {
19+
meta: {
20+
docs: {},
21+
schema: [schema],
22+
},
23+
24+
create: (context: ESLintContext) => ({
25+
JSXOpeningElement: (node: JSXOpeningElement) => {
26+
context.report({
27+
node,
28+
message: errorMessage,
29+
});
30+
},
31+
}),
32+
};

0 commit comments

Comments
 (0)