generated from avior/template-web-astro
chore: up to date to latest standards
This commit is contained in:
66
hooks/eslint-plugin/index.js
Normal file
66
hooks/eslint-plugin/index.js
Normal file
@ -0,0 +1,66 @@
|
||||
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')
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user