diff --git a/src/StateSnapshot.js b/src/StateSnapshot.js index f9a6e7b..eb7546e 100644 --- a/src/StateSnapshot.js +++ b/src/StateSnapshot.js @@ -28,9 +28,11 @@ export default { }, }, create(context) { + // FIX: remove when dropping support for < v9 + const sourceCode = context.sourceCode || context.getSourceCode() return { Identifier(node) { - const scope = context.getScope(node) + const scope = sourceCode.getScope(node) if (isInComputed(node) && isInProperty(node)) { if ( diff --git a/src/index.js b/src/index.js index b5d5564..26e1a7a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,17 +1,30 @@ import StateSnapshot from './StateSnapshot' import AvoidThisInProxy from './AvoidThisInProxy' -export const rules = { - 'state-snapshot-rule': StateSnapshot, - 'avoid-this-in-proxy': AvoidThisInProxy, +const plugin = { + meta: { + name: 'eslint-plugin-valtio', + }, + rules: { + 'state-snapshot-rule': StateSnapshot, + 'avoid-this-in-proxy': AvoidThisInProxy, + }, + configs: {}, } -export const configs = { - recommended: { - plugins: ['valtio'], - rules: { - 'valtio/state-snapshot-rule': 'warn', - 'valtio/avoid-this-in-proxy': 'warn', +Object.assign(plugin, { + configs: { + recommended: { + plugins: ['valtio'], + rules: { + 'valtio/state-snapshot-rule': 'warn', + 'valtio/avoid-this-in-proxy': 'warn', + }, }, }, -} +}) + +module.exports = plugin + +export const configs = plugin.configs +export const rules = plugin.rules