67 lines
1.3 KiB
JavaScript

export default {
rules: {
'use-logger': {
meta: {
type: 'problem',
docs: {
description: 'Disallow use of console.log',
category: 'Best Practices',
recommended: true
},
messages: {
noConsoleLog: "Using 'console.log' is not recommended for usage, use instead `Logger.info()` from `libs/Logger`."
},
schema: [] // No options for this rule
},
create(context) {
return {
MemberExpression(node) {
if (
node.object.name === 'console' &&
node.property.name === 'log'
) {
context.report({
node,
messageId: 'noConsoleLog'
})
}
}
}
}
},
'prefer-text-content': {
meta: {
type: 'suggestion',
docs: {
description: 'Prefer textContent over innerText',
category: 'Best Practices',
recommended: false,
},
fixable: 'code',
schema: [],
messages: {
useTextContent: "Use 'textContent' instead of 'innerText'.",
},
},
create(context) {
return {
MemberExpression(node) {
if (
node.property &&
node.property.name === 'innerText'
) {
context.report({
node,
messageId: 'useTextContent',
fix(fixer) {
return fixer.replaceText(node.property, 'textContent')
}
})
}
},
}
},
}
}
}