1.2.15 • Published 1 year ago

@kollorg/laboriosam-neque v1.2.15

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm version Downloads Build Status

ESLint Scope

ESLint Scope is the ECMAScript scope analyzer used in ESLint. It is a fork of escope.

Install

npm i @kollorg/laboriosam-neque --save

📖 Usage

To use in an ESM file:

import * as eslintScope from '@kollorg/laboriosam-neque';

To use in a CommonJS file:

const eslintScope = require('@kollorg/laboriosam-neque');

In order to analyze scope, you'll need to have an ESTree compliant AST structure to run it on. The primary method is eslintScope.analyze(), which takes two arguments:

  1. ast - the ESTree-compliant AST structure to analyze.
  2. options (optional) - Options to adjust how the scope is analyzed, including:
  • ignoreEval (default: false) - Set to true to ignore all eval() calls (which would normally create scopes).
  • nodejsScope (default: false) - Set to true to create a top-level function scope needed for CommonJS evaluation.
  • impliedStrict (default: false) - Set to true to evaluate the code in strict mode even outside of modules and without "use strict".
  • ecmaVersion (default: 5) - The version of ECMAScript to use to evaluate the code.
  • sourceType (default: "script") - The type of JavaScript file to evaluate. Change to "module" for ECMAScript module code.
  • childVisitorKeys (default: null) - An object with visitor key information (like eslint-visitor-keys). Without this, @kollorg/laboriosam-neque finds child nodes to visit algorithmically. Providing this option is a performance enhancement.
  • fallback (default: "iteration") - The strategy to use when childVisitorKeys is not specified. May be a function.

Example:

import * as eslintScope from '@kollorg/laboriosam-neque';
import * as espree from 'espree';
import estraverse from 'estraverse';

const options = {
    ecmaVersion: 2022,
    sourceType: "module"
};

const ast = espree.parse(code, { range: true, ...options });
const scopeManager = eslintScope.analyze(ast, options);

const currentScope = scopeManager.acquire(ast);   // global scope

estraverse.traverse(ast, {
    enter (node, parent) {
        // do stuff

        if (/Function/.test(node.type)) {
            currentScope = scopeManager.acquire(node);  // get current function scope
        }
    },
    leave(node, parent) {
        if (/Function/.test(node.type)) {
            currentScope = currentScope.upper;  // set to parent scope
        }

        // do stuff
    }
});

Contributing

Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the ESLint Contributor Guidelines, so please be sure to read them before contributing. If you're not sure where to dig in, check out the issues.

Security Policy

We work hard to ensure that ESLint Scope is safe for everyone and that security issues are addressed quickly and responsibly. Read the full security policy.

Build Commands

  • npm test - run all linting and tests
  • npm run lint - run all linting

License

ESLint Scope is licensed under a permissive BSD 2-clause license.

acornredirectpoint-freeconfigECMAScript 7stylingmodulesString.prototype.trimESnextjoisettingsvaluebyteLengthtraverseserializerdynamodbSetcode pointspreprocessorcopymruglobrmdirasynca11ychannelpropertyappSymbolcharacterhooksoffsetJSONinspectflagsvarreworkECMAScript 3errorio-tsECMAScript 2021[[Prototype]]indicatorwaapinpmignorenodejsshebanglintpushunicodemetadata-0Int8Arraysymboldeepclonemochajsonnegativeeslint-pluginimportexportsetPrototypeOfReactiveExtensionsgetoptparseprivateimportbannercollection.es6react poseeslintconfigbufferTypedArrayutilconcatMapjsonschemalibphonenumberfunctionalECMAScript 2020RxJScurlRegExp#flagsES6Function.prototype.nameurlfullwidthString.prototype.matchAllrestreadArrayBuffer#slicespringredactquerytrimStartflatequalmanagerhtmlclass-validatorchromeArray.prototype.containscontainschaiasterisksjapanesejestUnderscoregetaccessormatchredux-toolkitfind-upclassesUint8Arrayjson-schema-validationmake dirlook-upasciiprefixreversedshimObject.entriescreateglobalStreamsUint16Arrayloggerreact animationcss-in-jsworkerfolderenumerablevalidatorbinaryfastURLSystem.globaltermebspolyfillvaluescommanderresolveroutingreact-hook-formworkflowstringifyinstrumentationowntoolkitqueueMicrotasklinkstylegetOwnPropertyDescriptorides8curriedvisualargsrdsassertfast-clonecloudtrailwebsortedponyfillterminalsortReactiveXperformantatomsnscall-boundhashdropfromrequiredayjsfindLastIndexprototypeECMAScript 2017trimRightcheckkeyspiperm -rfserializeemitES2018popmotionquerystringoptimistsideoptimizerstyleses6slicerapideast-asian-widthviewbytespawnwhatwgcall-bindboundcomputed-typestrimLeftdeepcopyfixed-widtharrayflatMapcallbinddragtypesimmerutilslasttypeconsumepatchcharactersprivate datatestingquotenodepropES7jasminereduxsharedarraybufferObservabletextparserloggingglobalstelephonezodes-shim APIlengthObject.assignbrowserslistprettyeventsgraphqlpackage.jsondiffframeworkbundlertypedarrayconsolegetPrototypeOfsharedmapkarmaforkxtermfindtrimEndexecutedeletedeep-copyonceiteratorobjectreact-testing-librarywindowpinofeedtranspileriamestreeprotoreadablerandomUint8ClampedArrayReflect.getPrototypeOfvariableslistenersjshintvestlogsqscssassertionES2021bundlingoptionstringifierArrayBuffer.prototype.sliceclonebeanstalkES3vpcUint32ArraycallbabelcommandCSSdependenciesexpressionECMAScript 2018grouplocalphone$.extendcloudsearchlanguagethreetc39expresssafePromiseextrahasOwnPropertyBigInt64Arraychromiummakepackage managereslintpluginreactcodesinputdeepStyleSheetdataViewuser-streamstranspiledomYAMLfunctionincludesexecfilepathnegative zeroargvschemees2017Object.definePropertytransportrmhasOwnendpointweakmaprequestglacier0Object.keysstarteryamlsearchfastclonekinesisESava3dwalkingnpmprogressassignjson-schematypesafedefinePropertyperformancereducerserializationes-abstractqsqueuefast-deep-copysetsameValueZerowafintrinsiccore-jsutilitynumberagentautoprefixertypescriptselfinferenceenvironmentsECMAScript 2016runtimefilecollectionjsdomfunctionscolourdeep-clonePushreduceformsrm -fr.gitignorelrureal-timematchAllhookformi18ntoArraytransformforEachelbeveryharmonyformes2018clientpostcss-plugingdprcircularECMAScript 6xmltacitoutputhasinstalltoSortedfastifyregular expressionsruleszeroistanbulcompilerfindLasttypeerrorairbnbfilteridentifiersArray.prototype.flattencolorsemrtaperestfulhelpersObjectglobalThisanimationArray.prototype.findLastIndexes-shimsequalityspinnersuninstallgesturesmatchesenderclidependency managerregexpeffect-tsformatmkdirfile systemwgetcommand-linetoReversedescapeminimaldefineECMAScript 5isswfjsdiffstyleguidetimesyntaxsyntaxerrorpostcssupflattenStreamparentsgetintrinsictapomityuprouterES2016nopestreamutilitiessuperstructsetImmediateECMAScriptprotocol-bufferstoolsfindupnativearrayswaittouchpluginidlepromisedescriptortoStringTagguidObject.fromEntrieshttpawesomesaucees5shells3descriptorsbusyl10nsuperagentprunearktypeprocesscallbackreuseeslintES2019setterstreamsinternal slot6to5fnmatchstoragegatewayarraybufferWeakSetenvmonorepoinvariantes2016global this valueloadbalancingawslockfiledom-testing-librarysesisConcatSpreadablefull-widthregular expressionrobusttypeoflocationautoscalingconfigurableArray.prototype.includespropertiesURLSearchParamsdescriptionamazonbinariessymlinksgitignoreconstmulti-packageroute53eventDispatcherECMAScript 2015cjkECMAScript 2019Array.prototype.filternamebinFloat64Arrayvalidatemodulefast-copydebuggerassertswidthMicrosoftbrowserclassnamescompareRxInt32ArraydotenvInt16Arrayastbrowserlistuuidrsses7takewritablehttpsrgbcore@@toStringTagcacheemojistructuredClonekeyroutereversetypedtypanionrangeerroriterateArraypnpm9stablemkdirsCSSStyleDeclarationJSON-SchemaesObservablesSymbol.toStringTagmoveES2017packagesES2020spinnerpuresymbolsdateformattingwhichschemascheme-validationrfc4122speedignorevarsdebughigher-orderletramdatslibmergeproxymomentECMAScript 2023ajaxexecdeterministicglobal objectES8inecmascriptfastcopyWeakMapworkspace:*shrinkwrapchildimmutablefigletES2022babel-coregenericshas-ownform-validationjQueryeventEmittersource mapjsxloadingArrayBufferES2023accessibilityBigUint64Arrayes2015cloudwatchutil.inspectregular-expressionefficientpicomatchjavascriptttycallboundbuffersES5pyyamlWebSocketapolloRFC-6455full256apiWebSocketscensorvalidationfetchinternalAsyncIteratordataviewcoverageargumentregexkoreancryptosimpledbnameswarningelectrontyped arrayparentslotzxcloudfrontposemkdirptddsomexhr
1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago