Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc687f5

Browse files
authored
Merge branch 'main' into set-correct-meta-info-on-rules
2 parents 5e2959d + 25c29a0 commit bc687f5

10 files changed

+3970
-1104
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# eslint-plugin-github
22

3+
[![Node CI](https://github.com/github/eslint-plugin-github/actions/workflows/nodejs.yml/badge.svg)](https://github.com/github/eslint-plugin-github/actions/workflows/nodejs.yml)
4+
35
## Installation
46

57
```sh

lib/formatters/stylish-fixes.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ try {
1212
}
1313
const getRuleURI = require('eslint-rule-documentation')
1414

15-
module.exports = function(results) {
15+
module.exports = function (results) {
1616
let output = '\n'
1717
let errors = 0
1818
let warnings = 0
@@ -82,8 +82,5 @@ function diff(a, b) {
8282
fs.writeFileSync(aPath, a, {encoding: 'utf8'})
8383
fs.writeFileSync(bPath, b, {encoding: 'utf8'})
8484
const result = childProcess.spawnSync('diff', ['-U5', aPath, bPath], {encoding: 'utf8'})
85-
return result.stdout
86-
.split('\n')
87-
.slice(2)
88-
.join('\n')
85+
return result.stdout.split('\n').slice(2).join('\n')
8986
}

lib/rules/get-attribute.js

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,36 @@ function isValidAttribute(name) {
1717
return validSVGAttributeSet.has(name) || (validAttributeName.test(name) && !invalidSVGAttributeSet.has(name))
1818
}
1919

20-
module.exports = function(context) {
21-
return {
22-
meta: {
23-
type: 'problem',
24-
docs: {
25-
description: 'disallow wrong usage of attribute names',
26-
url: require('../url')(module)
27-
},
28-
fixable: 'code',
29-
schema: []
20+
module.exports = {
21+
meta: {
22+
type: 'problem',
23+
docs: {
24+
description: 'disallow wrong usage of attribute names',
25+
url: require('../url')(module)
3026
},
31-
CallExpression(node) {
32-
if (!node.callee.property) return
33-
34-
const calleeName = node.callee.property.name
35-
if (!attributeCalls.test(calleeName)) return
36-
37-
const attributeNameNode = node.arguments[0]
38-
if (!attributeNameNode) return
39-
40-
if (!isValidAttribute(attributeNameNode.value)) {
41-
context.report({
42-
meta: {
43-
fixable: 'code'
44-
},
45-
node: attributeNameNode,
46-
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
47-
fix(fixer) {
48-
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
49-
}
50-
})
27+
fixable: 'code',
28+
schema: []
29+
},
30+
create(context) {
31+
return {
32+
CallExpression(node) {
33+
if (!node.callee.property) return
34+
35+
const calleeName = node.callee.property.name
36+
if (!attributeCalls.test(calleeName)) return
37+
38+
const attributeNameNode = node.arguments[0]
39+
if (!attributeNameNode) return
40+
41+
if (!isValidAttribute(attributeNameNode.value)) {
42+
context.report({
43+
node: attributeNameNode,
44+
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
45+
fix(fixer) {
46+
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
47+
}
48+
})
49+
}
5150
}
5251
}
5352
}

lib/rules/no-blur.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(context) {
1+
module.exports = function (context) {
22
return {
33
meta: {
44
type: 'problem',

lib/rules/no-useless-passive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515

1616
create(context) {
1717
return {
18-
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
18+
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
1919
const [name, listener, options] = node.arguments
2020
if (name.type !== 'Literal') return
2121
if (passiveEventListenerNames.has(name.value)) return

lib/rules/prefer-observers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414

1515
create(context) {
1616
return {
17-
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
17+
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
1818
const [name] = node.arguments
1919
if (name.type !== 'Literal') return
2020
if (!(name.value in observerMap)) return

lib/rules/require-passive-events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414

1515
create(context) {
1616
return {
17-
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
17+
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
1818
const [name, listener, options] = node.arguments
1919
if (!listener) return
2020
if (name.type !== 'Literal') return

0 commit comments

Comments
 (0)