How to use the eslint-module-utils/declaredScope function in eslint-module-utils

To help you get started, we’ve selected a few eslint-module-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github benmosher / eslint-plugin-import / src / rules / no-deprecated.js View on Github external
'Identifier': function (node) {
        if (node.parent.type === 'MemberExpression' && node.parent.property === node) {
          return // handled by MemberExpression
        }

        // ignore specifier identifiers
        if (node.parent.type.slice(0, 6) === 'Import') return

        if (!deprecated.has(node.name)) return

        if (declaredScope(context, node.name) !== 'module') return
        context.report({
          node,
          message: message(deprecated.get(node.name)),
        })
      },
github benmosher / eslint-plugin-import / src / rules / namespace.js View on Github external
VariableDeclarator: function ({ id, init }) {
        if (init == null) return
        if (init.type !== 'Identifier') return
        if (!namespaces.has(init.name)) return

        // check for redefinition in intermediate scopes
        if (declaredScope(context, init.name) !== 'module') return

        // DFS traverse child namespaces
        function testKey(pattern, namespace, path = [init.name]) {
          if (!(namespace instanceof Exports)) return

          if (pattern.type !== 'ObjectPattern') return

          for (const property of pattern.properties) {
            if (
              property.type === 'ExperimentalRestProperty'
              || property.type === 'RestElement'
              || !property.key
            ) {
              continue
            }
github benmosher / eslint-plugin-import / src / rules / namespace.js View on Github external
'VariableDeclarator': function ({ id, init }) {
      if (init == null) return
      if (init.type !== 'Identifier') return
      if (!namespaces.has(init.name)) return

      // check for redefinition in intermediate scopes
      if (declaredScope(context, init.name) !== 'module') return

      // DFS traverse child namespaces
      function testKey(pattern, namespace, path = [init.name]) {
        if (!(namespace instanceof Exports)) return

        if (pattern.type !== 'ObjectPattern') return

        for (let property of pattern.properties) {

          if (property.key.type !== 'Identifier') {
            context.report({
              node: property,
              message: 'Only destructure top-level names.',
            })
            continue
          }