Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 2 additions & 5 deletions lib/formatters/stylish-fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ try {
}
const getRuleURI = require('eslint-rule-documentation')

module.exports = function(results) {
module.exports = function (results) {
let output = '\n'
let errors = 0
let warnings = 0
Expand Down Expand Up @@ -82,8 +82,5 @@ function diff(a, b) {
fs.writeFileSync(aPath, a, {encoding: 'utf8'})
fs.writeFileSync(bPath, b, {encoding: 'utf8'})
const result = childProcess.spawnSync('diff', ['-U5', aPath, bPath], {encoding: 'utf8'})
return result.stdout
.split('\n')
.slice(2)
.join('\n')
return result.stdout.split('\n').slice(2).join('\n')
}
46 changes: 24 additions & 22 deletions lib/rules/get-attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@ function isValidAttribute(name) {
return validSVGAttributeSet.has(name) || (validAttributeName.test(name) && !invalidSVGAttributeSet.has(name))
}

module.exports = function(context) {
return {
CallExpression(node) {
if (!node.callee.property) return

const calleeName = node.callee.property.name
if (!attributeCalls.test(calleeName)) return

const attributeNameNode = node.arguments[0]
if (!attributeNameNode) return

if (!isValidAttribute(attributeNameNode.value)) {
context.report({
meta: {
fixable: 'code'
},
node: attributeNameNode,
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
fix(fixer) {
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
}
})
module.exports = {
meta: {
fixable: 'code'
},
create(context) {
return {
CallExpression(node) {
if (!node.callee.property) return

const calleeName = node.callee.property.name
if (!attributeCalls.test(calleeName)) return

const attributeNameNode = node.arguments[0]
if (!attributeNameNode) return

if (!isValidAttribute(attributeNameNode.value)) {
context.report({
node: attributeNameNode,
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
fix(fixer) {
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
}
})
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-blur.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(context) {
module.exports = function (context) {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'blur') {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-useless-passive.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {

create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
const [name, listener, options] = node.arguments
if (name.type !== 'Literal') return
if (passiveEventListenerNames.has(name.value)) return
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-observers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {

create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
const [name] = node.arguments
if (name.type !== 'Literal') return
if (!(name.value in observerMap)) return
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/require-passive-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {

create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
const [name, listener, options] = node.arguments
if (!listener) return
if (name.type !== 'Literal') return
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/unescaped-html-literal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(context) {
module.exports = function (context) {
const htmlOpenTag = /^<[a-zA-Z]/
const message = 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.'

Expand Down
Loading