Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info into the meta property of rules #122

Merged
merged 3 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/rules/array-foreach.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'suggestion',
docs: {
description: 'enforce `for..of` loops over `Array.forEach`',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/array-foreach.md'
koddsson marked this conversation as resolved.
Show resolved Hide resolved
},
schema: []
},

Expand Down
6 changes: 5 additions & 1 deletion lib/rules/async-currenttarget.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow `event.currentTarget` calls inside of async functions',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-currenttarget.md'
},
schema: []
},

Expand Down
6 changes: 5 additions & 1 deletion lib/rules/async-preventdefault.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow `event.preventDefault` calls inside of async functions',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/async-preventDefault.md'
},
schema: []
},

Expand Down
6 changes: 5 additions & 1 deletion lib/rules/authenticity-token.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow usage of CSRF tokens in JavaScript',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/authenticity-token.md'
},
schema: []
},

Expand Down
9 changes: 9 additions & 0 deletions lib/rules/get-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ function isValidAttribute(name) {

module.exports = function(context) {
return {
meta: {
type: 'problem',
docs: {
description: 'disallow wrong usage of attribute names',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/get-attribute.md'
},
fixable: 'code',
schema: []
},
CallExpression(node) {
if (!node.callee.property) return

Expand Down
6 changes: 5 additions & 1 deletion lib/rules/js-class-name.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'suggestion',
docs: {
description: 'enforce a naming convention for js- prefixed classes',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/js-class-name.md'
},
schema: []
},

Expand Down
10 changes: 8 additions & 2 deletions lib/rules/no-blur.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
module.exports = function(context) {
return {
meta: {
type: 'problem',
docs: {
description: 'disallow usage of `Element.prototype.blur()`',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-blur.md'
},
schema: []
},
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'blur') {
context.report(node, 'Do not use element.blur(), instead restore the focus of a previous element.')
}
}
}
}

module.exports.schema = []
8 changes: 8 additions & 0 deletions lib/rules/no-d-none.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow usage the `d-none` CSS class',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-d-none.md'
},
schema: []
},
create(context) {
return {
CallExpression(node) {
Expand Down
6 changes: 5 additions & 1 deletion lib/rules/no-dataset.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'enforce usage of `Element.prototype.getAttribute` instead of `Element.prototype.datalist`',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-dataset.md'
},
schema: []
},

Expand Down
6 changes: 5 additions & 1 deletion lib/rules/no-implicit-buggy-globals.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow implicit global variables',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-implicit-buggy-globals.md'
},
schema: []
},

Expand Down
9 changes: 7 additions & 2 deletions lib/rules/no-innerText.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'problem',
docs: {
description: 'disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent`',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-innerText.md'
},
fixable: 'code',
schema: []
},

create(context) {
Expand Down
7 changes: 6 additions & 1 deletion lib/rules/no-then.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module.exports = {
meta: {
docs: {}
type: 'suggestion',
docs: {
description: 'enforce using `async/await` syntax over Promises',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-then.md'
},
schema: []
},

create(context) {
Expand Down
9 changes: 7 additions & 2 deletions lib/rules/no-useless-passive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ const propIsPassiveTrue = prop => prop.key && prop.key.name === 'passive' && pro

module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'suggestion',
docs: {
description: 'disallow marking a event handler as passive when it has no effect',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/no-useless-passive.md'
},
fixable: 'code',
schema: []
},

create(context) {
Expand Down
8 changes: 6 additions & 2 deletions lib/rules/prefer-observers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ const observerMap = {
}
module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'suggestion',
docs: {
description: 'disallow poorly performing event listeners',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/prefer-observers.md'
},
schema: []
},

create(context) {
Expand Down
7 changes: 6 additions & 1 deletion lib/rules/require-passive-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const propIsPassiveTrue = prop => prop.key && prop.key.name === 'passive' && pro

module.exports = {
meta: {
docs: {}
type: 'suggestion',
docs: {
description: 'enforce marking high frequency event handlers as passive',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/require-passive-events.md'
},
schema: []
},

create(context) {
Expand Down
39 changes: 25 additions & 14 deletions lib/rules/unescaped-html-literal.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
module.exports = function(context) {
const htmlOpenTag = /^<[a-zA-Z]/
const message = 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.'
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow unesaped HTML literals',
url: 'https://github.com/github/eslint-plugin-github/blob/main/docs/rules/unescaped-html-literal.md'
},
schema: []
},

return {
Literal(node) {
if (!htmlOpenTag.test(node.value)) return
create(context) {
const htmlOpenTag = /^<[a-zA-Z]/
const message = 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.'

context.report({
node,
message
})
},
TemplateLiteral(node) {
if (!htmlOpenTag.test(node.quasis[0].value.raw)) return
return {
Literal(node) {
if (!htmlOpenTag.test(node.value)) return

if (!node.parent.tag || node.parent.tag.name !== 'html') {
context.report({
node,
message
})
},
TemplateLiteral(node) {
if (!htmlOpenTag.test(node.quasis[0].value.raw)) return

if (!node.parent.tag || node.parent.tag.name !== 'html') {
context.report({
node,
message
})
}
}
}
}
Expand Down