Skip to content

Commit

Permalink
feat(core): support for v9 configs
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Nov 5, 2024
1 parent f18e602 commit 6812789
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/StateSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
33 changes: 23 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6812789

Please sign in to comment.