_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q17700
onSignInConfirmPhoneVerification
train
function onSignInConfirmPhoneVerification() { var verificationId = $('#signin-phone-verification-id').val(); var verificationCode = $('#signin-phone-verification-code').val(); var credential = firebase.auth.PhoneAuthProvider.credential( verificationId, verificationCode); signInOrLinkCredential(credential)...
javascript
{ "resource": "" }
q17701
onLinkReauthVerifyPhoneNumber
train
function onLinkReauthVerifyPhoneNumber() { var phoneNumber = $('#link-reauth-phone-number').val(); var provider = new firebase.auth.PhoneAuthProvider(auth); // Clear existing reCAPTCHA as an existing reCAPTCHA could be targeted for a // sign-in operation. clearApplicationVerifier(); // Initialize a reCAPTCH...
javascript
{ "resource": "" }
q17702
onUpdateConfirmPhoneVerification
train
function onUpdateConfirmPhoneVerification() { if (!activeUser()) { alertError('You need to sign in before linking an account.'); return; } var verificationId = $('#link-reauth-phone-verification-id').val(); var verificationCode = $('#link-reauth-phone-verification-code').val(); var credential = fireba...
javascript
{ "resource": "" }
q17703
onReauthConfirmPhoneVerification
train
function onReauthConfirmPhoneVerification() { var verificationId = $('#link-reauth-phone-verification-id').val(); var verificationCode = $('#link-reauth-phone-verification-code').val(); var credential = firebase.auth.PhoneAuthProvider.credential( verificationId, verificationCode); activeUser().reauthentic...
javascript
{ "resource": "" }
q17704
signInOrLinkCredential
train
function signInOrLinkCredential(credential) { if (currentTab == '#user-section') { if (!activeUser()) { alertError('You need to sign in before linking an account.'); return; } activeUser().linkWithCredential(credential) .then(function(result) { logAdditionalUserInfo(result); ...
javascript
{ "resource": "" }
q17705
onChangeEmail
train
function onChangeEmail() { var email = $('#changed-email').val(); activeUser().updateEmail(email).then(function() { refreshUserData(); alertSuccess('Email changed!'); }, onAuthError); }
javascript
{ "resource": "" }
q17706
onSendSignInLinkToEmail
train
function onSendSignInLinkToEmail() { var email = $('#sign-in-with-email-link-email').val(); auth.sendSignInLinkToEmail(email, getActionCodeSettings()).then(function() { alertSuccess('Email sent!'); }, onAuthError); }
javascript
{ "resource": "" }
q17707
onSendSignInLinkToEmailCurrentUrl
train
function onSendSignInLinkToEmailCurrentUrl() { var email = $('#sign-in-with-email-link-email').val(); var actionCodeSettings = { 'url': window.location.href, 'handleCodeInApp': true }; auth.sendSignInLinkToEmail(email, actionCodeSettings).then(function() { if ('localStorage' in window && window['lo...
javascript
{ "resource": "" }
q17708
onSendPasswordResetEmail
train
function onSendPasswordResetEmail() { var email = $('#password-reset-email').val(); auth.sendPasswordResetEmail(email, getActionCodeSettings()).then(function() { alertSuccess('Email sent!'); }, onAuthError); }
javascript
{ "resource": "" }
q17709
onConfirmPasswordReset
train
function onConfirmPasswordReset() { var code = $('#password-reset-code').val(); var password = $('#password-reset-password').val(); auth.confirmPasswordReset(code, password).then(function() { alertSuccess('Password has been changed!'); }, onAuthError); }
javascript
{ "resource": "" }
q17710
onFetchSignInMethodsForEmail
train
function onFetchSignInMethodsForEmail() { var email = $('#fetch-sign-in-methods-email').val(); auth.fetchSignInMethodsForEmail(email).then(function(signInMethods) { log('Sign in methods for ' + email + ' :'); log(signInMethods); if (signInMethods.length == 0) { alertSuccess('Sign In Methods for ' ...
javascript
{ "resource": "" }
q17711
onLinkWithEmailAndPassword
train
function onLinkWithEmailAndPassword() { var email = $('#link-email').val(); var password = $('#link-password').val(); activeUser().linkWithCredential( firebase.auth.EmailAuthProvider.credential(email, password)) .then(onAuthUserCredentialSuccess, onAuthError); }
javascript
{ "resource": "" }
q17712
onLinkWithGenericIdPCredential
train
function onLinkWithGenericIdPCredential() { var providerId = $('#link-generic-idp-provider-id').val(); var idToken = $('#link-generic-idp-id-token').val(); var accessToken = $('#link-generic-idp-access-token').val(); var provider = new firebase.auth.OAuthProvider(providerId); activeUser().linkWithCredential( ...
javascript
{ "resource": "" }
q17713
onUnlinkProvider
train
function onUnlinkProvider() { var providerId = $('#unlinked-provider-id').val(); activeUser().unlink(providerId).then(function(user) { alertSuccess('Provider unlinked from user.'); refreshUserData(); }, onAuthError); }
javascript
{ "resource": "" }
q17714
onApplyActionCode
train
function onApplyActionCode() { var code = $('#email-verification-code').val(); auth.applyActionCode(code).then(function() { alertSuccess('Email successfully verified!'); refreshUserData(); }, onAuthError); }
javascript
{ "resource": "" }
q17715
getIdToken
train
function getIdToken(forceRefresh) { if (activeUser() == null) { alertError('No user logged in.'); return; } if (activeUser().getIdToken) { activeUser().getIdToken(forceRefresh).then(alertSuccess, function() { log("No token"); }); } else { activeUser().getToken(forceRefresh).then(alertS...
javascript
{ "resource": "" }
q17716
getIdTokenResult
train
function getIdTokenResult(forceRefresh) { if (activeUser() == null) { alertError('No user logged in.'); return; } activeUser().getIdTokenResult(forceRefresh).then(function(idTokenResult) { alertSuccess(JSON.stringify(idTokenResult)); }, onAuthError); }
javascript
{ "resource": "" }
q17717
onGetRedirectResult
train
function onGetRedirectResult() { auth.getRedirectResult().then(function(response) { log('Redirect results:'); if (response.credential) { log('Credential:'); log(response.credential); } else { log('No credential'); } if (response.user) { log('User\'s id:'); log(respons...
javascript
{ "resource": "" }
q17718
logAdditionalUserInfo
train
function logAdditionalUserInfo(response) { if (response.additionalUserInfo) { if (response.additionalUserInfo.username) { log(response.additionalUserInfo['providerId'] + ' username: ' + response.additionalUserInfo.username); } if (response.additionalUserInfo.profile) { log(response.a...
javascript
{ "resource": "" }
q17719
populateActionCodes
train
function populateActionCodes() { var emailForSignIn = null; var signInTime = 0; if ('localStorage' in window && window['localStorage'] !== null) { try { // Try to parse as JSON first using new storage format. var emailForSignInData = JSON.parse(window.localStorage.getItem('emailForSignIn...
javascript
{ "resource": "" }
q17720
onCopyActiveUser
train
function onCopyActiveUser() { tempAuth.updateCurrentUser(activeUser()).then(function() { alertSuccess('Copied active user to temp Auth'); }, function(error) { alertError('Error: ' + error.code); }); }
javascript
{ "resource": "" }
q17721
onCopyLastUser
train
function onCopyLastUser() { // If last user is null, NULL_USER error will be thrown. auth.updateCurrentUser(lastUser).then(function() { alertSuccess('Copied last user to Auth'); }, function(error) { alertError('Error: ' + error.code); }); }
javascript
{ "resource": "" }
q17722
onApplyAuthSettingsChange
train
function onApplyAuthSettingsChange() { try { auth.settings.appVerificationDisabledForTesting = $("input[name=enable-app-verification]:checked").val() == 'No'; alertSuccess('Auth settings changed'); } catch (error) { alertError('Error: ' + error.code); } }
javascript
{ "resource": "" }
q17723
train
function() { if (!self.initialized_) { self.initialized_ = true; // Listen to Auth events on iframe. self.oauthSignInHandler_.addAuthEventListener(self.authEventHandler_); } }
javascript
{ "resource": "" }
q17724
train
function() { // The developer may have tried to previously run gapi.load and failed. // Run this to fix that. fireauth.util.resetUnloadedGapiModules(); var loader = /** @type {function(string, !Object)} */ ( fireauth.util.getObjectRef('gapi.load')); loader('gapi.iframes', { ...
javascript
{ "resource": "" }
q17725
createBuildTask
train
function createBuildTask(filename, prefix, suffix) { return () => gulp .src([ `${closureLibRoot}/closure/goog/**/*.js`, `${closureLibRoot}/third_party/closure/goog/**/*.js`, 'src/**/*.js' ], { base: '.' }) .pipe(sourcemaps.init()) .pipe( closureCompiler({ ...
javascript
{ "resource": "" }
q17726
defaultVersionMatcher
train
function defaultVersionMatcher(raw) { // sanity check if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null try { // look for something that looks like semver var rx = /([0-9]+\.[0-9]+\.[0-9]+)/ var match = ramda.match(rx, raw) if (match.length > 0) { return match[0] } else { re...
javascript
{ "resource": "" }
q17727
enforce
train
function enforce(opts = {}) { // opts to pass in var optional = opts.optional || false var range = opts.range var whichExec = opts.which var packageName = opts.packageName || opts.which var versionCommand = opts.versionCommand var installMessage = opts.installMessage var versionMatcher = opts.versionMat...
javascript
{ "resource": "" }
q17728
printNotMetMessage
train
function printNotMetMessage(installedVersion) { console.log('Ignite CLI requires ' + packageName + ' ' + range + ' to be installed.') if (installedVersion) { console.log('') console.log('You currently have ' + installedVersion + ' installed.') } console.log('') console.log(installMessage...
javascript
{ "resource": "" }
q17729
getVersion
train
function getVersion() { // parse the version number try { // find the executable var resolvedPath = which.sync(whichExec) // grab the raw output var result = shell.exec(`"${resolvedPath}" ${versionCommand}`, { silent: true }) var rawOut = ramda.trim(result.stdout || '') var ...
javascript
{ "resource": "" }
q17730
triggerCharacter
train
function triggerCharacter({ char = '@', allowSpaces = false, startOfLine = false, }) { return $position => { // Matching expressions used for later const escapedChar = `\\${char}` const suffix = new RegExp(`\\s${escapedChar}$`) const prefix = startOfLine ? '^' : '' const regexp = allowSpace...
javascript
{ "resource": "" }
q17731
networkIdleCallback
train
function networkIdleCallback(fn, options = {timeout: 0}) { // Call the function immediately if required features are absent if ( !('MessageChannel' in window) || !('serviceWorker' in navigator) || !navigator.serviceWorker.controller ) { DOMContentLoad.then(() => fn({didTimeout: false})); retur...
javascript
{ "resource": "" }
q17732
handleMessage
train
function handleMessage(event) { if (!event.data) { return; } switch (event.data) { case 'NETWORK_IDLE_ENQUIRY_RESULT_IDLE': case 'NETWORK_IDLE_CALLBACK': networkIdleCallback.__callbacks__.forEach(callback => { networkIdleCallback.__popCallback__(callback, false); }); break; ...
javascript
{ "resource": "" }
q17733
mapValues
train
function mapValues(obj, iteratee) { const result = {} for (const k in obj) { result[k] = iteratee(obj[k]) } return result }
javascript
{ "resource": "" }
q17734
heuristic
train
function heuristic() { if (this.type === typeEnum.unit) { // Remove the excess. return Math.max(0, this.cache.size - this.capacity) } else if (this.type === typeEnum.heap) { if (getHeapSize() >= this.capacity) { console.log('LRU HEURISTIC heap:', getHeapSize()) // Remove half o...
javascript
{ "resource": "" }
q17735
parseVersion
train
function parseVersion(versionString) { versionString = versionString.toLowerCase().replace('-', '.') const versionList = [] versionString.split('.').forEach(versionPart => { const parsedPart = /(\d*)([a-z]*)(\d*)/.exec(versionPart) if (parsedPart[1]) { versionList.push(parseInt(parsedPart[1])) }...
javascript
{ "resource": "" }
q17736
sortDjangoVersions
train
function sortDjangoVersions(versions) { return versions.sort((a, b) => { if ( parseDjangoVersionString(a).major === parseDjangoVersionString(b).major ) { return ( parseDjangoVersionString(a).minor - parseDjangoVersionString(b).minor ) } else { return ( parseDjangoVe...
javascript
{ "resource": "" }
q17737
parseClassifiers
train
function parseClassifiers(parsedData, pattern) { const results = [] for (let i = 0; i < parsedData.info.classifiers.length; i++) { const matched = pattern.exec(parsedData.info.classifiers[i]) if (matched && matched[1]) { results.push(matched[1].toLowerCase()) } } return results }
javascript
{ "resource": "" }
q17738
fixLink
train
function fixLink (name, str) { /* In 6.x some API start with `xpack.` when in master they do not. We * can safely ignore that for link generation. */ name = name.replace(/^xpack\./, '') const override = LINK_OVERRIDES[name] if (override) return override if (!str) return '' /* Replace references to the gu...
javascript
{ "resource": "" }
q17739
getLeft
train
function getLeft(node) { let left = node.left; while (isConcatenation(left)) { left = left.right; } return left; }
javascript
{ "resource": "" }
q17740
getRight
train
function getRight(node) { let right = node.right; while (isConcatenation(right)) { right = right.left; } return right; }
javascript
{ "resource": "" }
q17741
createDisableDirectives
train
function createDisableDirectives(type, loc, value) { const ruleIds = Object.keys(commentParser.parseListConfig(value)); const directiveRules = ruleIds.length ? ruleIds : [null]; return directiveRules.map(ruleId => ({ type, line: loc.line, column: loc.column + 1, ruleId })); }
javascript
{ "resource": "" }
q17742
normalizeVerifyOptions
train
function normalizeVerifyOptions(providedOptions) { const isObjectOptions = typeof providedOptions === "object"; const providedFilename = isObjectOptions ? providedOptions.filename : providedOptions; return { filename: typeof providedFilename === "string" ? providedFilename : "<input>", allo...
javascript
{ "resource": "" }
q17743
resolveParserOptions
train
function resolveParserOptions(parserName, providedOptions, enabledEnvironments) { const parserOptionsFromEnv = enabledEnvironments .filter(env => env.parserOptions) .reduce((parserOptions, env) => ConfigOps.merge(parserOptions, env.parserOptions), {}); const mergedParserOptions = ConfigOps.merg...
javascript
{ "resource": "" }
q17744
resolveGlobals
train
function resolveGlobals(providedGlobals, enabledEnvironments) { return Object.assign( {}, ...enabledEnvironments.filter(env => env.globals).map(env => env.globals), providedGlobals ); }
javascript
{ "resource": "" }
q17745
analyzeScope
train
function analyzeScope(ast, parserOptions, visitorKeys) { const ecmaFeatures = parserOptions.ecmaFeatures || {}; const ecmaVersion = parserOptions.ecmaVersion || 5; return eslintScope.analyze(ast, { ignoreEval: true, nodejsScope: ecmaFeatures.globalReturn, impliedStrict: ecmaFeatures...
javascript
{ "resource": "" }
q17746
getScope
train
function getScope(scopeManager, currentNode) { // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope. const inner = currentNode.type !== "Program"; for (let node = currentNode; node; node = node.parent) { const scope = scopeManager.acquire(n...
javascript
{ "resource": "" }
q17747
markVariableAsUsed
train
function markVariableAsUsed(scopeManager, currentNode, parserOptions, name) { const hasGlobalReturn = parserOptions.ecmaFeatures && parserOptions.ecmaFeatures.globalReturn; const specialScope = hasGlobalReturn || parserOptions.sourceType === "module"; const currentScope = getScope(scopeManager, currentNode)...
javascript
{ "resource": "" }
q17748
createRuleListeners
train
function createRuleListeners(rule, ruleContext) { try { return rule.create(ruleContext); } catch (ex) { ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`; throw ex; } }
javascript
{ "resource": "" }
q17749
getAncestors
train
function getAncestors(node) { const ancestorsStartingAtParent = []; for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) { ancestorsStartingAtParent.push(ancestor); } return ancestorsStartingAtParent.reverse(); }
javascript
{ "resource": "" }
q17750
isRedundantSemi
train
function isRedundantSemi(semiToken) { const nextToken = sourceCode.getTokenAfter(semiToken); return ( !nextToken || astUtils.isClosingBraceToken(nextToken) || astUtils.isSemicolonToken(nextToken) ); }
javascript
{ "resource": "" }
q17751
isEndOfArrowBlock
train
function isEndOfArrowBlock(lastToken) { if (!astUtils.isClosingBraceToken(lastToken)) { return false; } const node = sourceCode.getNodeByRangeIndex(lastToken.range[0]); return ( node.type === "BlockStatement" && node.parent...
javascript
{ "resource": "" }
q17752
isOnSameLineWithNextToken
train
function isOnSameLineWithNextToken(node) { const prevToken = sourceCode.getLastToken(node, 1); const nextToken = sourceCode.getTokenAfter(node); return !!nextToken && astUtils.isTokenOnSameLine(prevToken, nextToken); }
javascript
{ "resource": "" }
q17753
maybeAsiHazardAfter
train
function maybeAsiHazardAfter(node) { const t = node.type; if (t === "DoWhileStatement" || t === "BreakStatement" || t === "ContinueStatement" || t === "DebuggerStatement" || t === "ImportDeclaration" || t === "Expor...
javascript
{ "resource": "" }
q17754
maybeAsiHazardBefore
train
function maybeAsiHazardBefore(token) { return ( Boolean(token) && OPT_OUT_PATTERN.test(token.value) && token.value !== "++" && token.value !== "--" ); }
javascript
{ "resource": "" }
q17755
isOneLinerBlock
train
function isOneLinerBlock(node) { const parent = node.parent; const nextToken = sourceCode.getTokenAfter(node); if (!nextToken || nextToken.value !== "}") { return false; } return ( !!parent && parent.type === "B...
javascript
{ "resource": "" }
q17756
normalizeOptions
train
function normalizeOptions(options = {}) { const hasGroups = options.groups && options.groups.length > 0; const groups = hasGroups ? options.groups : DEFAULT_GROUPS; const allowSamePrecedence = options.allowSamePrecedence !== false; return { groups, allowSamePrecedence }; }
javascript
{ "resource": "" }
q17757
includesBothInAGroup
train
function includesBothInAGroup(groups, left, right) { return groups.some(group => group.indexOf(left) !== -1 && group.indexOf(right) !== -1); }
javascript
{ "resource": "" }
q17758
shouldIgnore
train
function shouldIgnore(node) { const a = node; const b = node.parent; return ( !includesBothInAGroup(options.groups, a.operator, b.operator) || ( options.allowSamePrecedence && astUtils.getPrecedence(a) === astUt...
javascript
{ "resource": "" }
q17759
isMixedWithParent
train
function isMixedWithParent(node) { return ( node.operator !== node.parent.operator && !astUtils.isParenthesised(sourceCode, node) ); }
javascript
{ "resource": "" }
q17760
reportBothOperators
train
function reportBothOperators(node) { const parent = node.parent; const left = (parent.left === node) ? node : parent; const right = (parent.left !== node) ? node : parent; const message = "Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'."; ...
javascript
{ "resource": "" }
q17761
check
train
function check(node) { if (TARGET_NODE_TYPE.test(node.parent.type) && isMixedWithParent(node) && !shouldIgnore(node) ) { reportBothOperators(node); } }
javascript
{ "resource": "" }
q17762
isLoneBlock
train
function isLoneBlock(node) { return node.parent.type === "BlockStatement" || node.parent.type === "Program" || // Don't report blocks in switch cases if the block is the only statement of the case. node.parent.type === "SwitchCase" && !(node.parent.consequent...
javascript
{ "resource": "" }
q17763
markLoneBlock
train
function markLoneBlock() { if (loneBlocks.length === 0) { return; } const block = context.getAncestors().pop(); if (loneBlocks[loneBlocks.length - 1] === block) { loneBlocks.pop(); } }
javascript
{ "resource": "" }
q17764
getContinueContext
train
function getContinueContext(state, label) { if (!label) { return state.loopContext; } let context = state.loopContext; while (context) { if (context.label === label) { return context; } context = context.upper; } /* istanbul ignore next: foolproof (...
javascript
{ "resource": "" }
q17765
getBreakContext
train
function getBreakContext(state, label) { let context = state.breakContext; while (context) { if (label ? context.label === label : context.breakable) { return context; } context = context.upper; } /* istanbul ignore next: foolproof (syntax error) */ return null;...
javascript
{ "resource": "" }
q17766
getReturnContext
train
function getReturnContext(state) { let context = state.tryContext; while (context) { if (context.hasFinalizer && context.position !== "finally") { return context; } context = context.upper; } return state; }
javascript
{ "resource": "" }
q17767
getThrowContext
train
function getThrowContext(state) { let context = state.tryContext; while (context) { if (context.position === "try" || (context.hasFinalizer && context.position === "catch") ) { return context; } context = context.upper; } return state; }
javascript
{ "resource": "" }
q17768
removeConnection
train
function removeConnection(prevSegments, nextSegments) { for (let i = 0; i < prevSegments.length; ++i) { const prevSegment = prevSegments[i]; const nextSegment = nextSegments[i]; remove(prevSegment.nextSegments, nextSegment); remove(prevSegment.allNextSegments, nextSegment); ...
javascript
{ "resource": "" }
q17769
checkComputedProperty
train
function checkComputedProperty(node, value) { if ( validIdentifier.test(value) && (allowKeywords || keywords.indexOf(String(value)) === -1) && !(allowPattern && allowPattern.test(value)) ) { const formattedValue = node.property.type...
javascript
{ "resource": "" }
q17770
validateNode
train
function validateNode(node, leftSide) { /* * When the left part of a binary expression is a single expression wrapped in * parentheses (ex: `(a) + b`), leftToken will be the last token of the expression * and operatorToken will be the closing parenthesis. ...
javascript
{ "resource": "" }
q17771
loadJSConfigFile
train
function loadJSConfigFile(filePath) { debug(`Loading JS config file: ${filePath}`); try { return importFresh(filePath); } catch (e) { debug(`Error reading JavaScript file: ${filePath}`); e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`; throw e; } }
javascript
{ "resource": "" }
q17772
loadPackageJSONConfigFile
train
function loadPackageJSONConfigFile(filePath) { debug(`Loading package.json config file: ${filePath}`); try { return loadJSONConfigFile(filePath).eslintConfig || null; } catch (e) { debug(`Error reading package.json file: ${filePath}`); e.message = `Cannot read config file: ${filePath...
javascript
{ "resource": "" }
q17773
configMissingError
train
function configMissingError(configName) { const error = new Error(`Failed to load config "${configName}" to extend from.`); error.messageTemplate = "extend-config-missing"; error.messageData = { configName }; return error; }
javascript
{ "resource": "" }
q17774
writeJSONConfigFile
train
function writeJSONConfigFile(config, filePath) { debug(`Writing JSON config file: ${filePath}`); const content = stringify(config, { cmp: sortByKey, space: 4 }); fs.writeFileSync(filePath, content, "utf8"); }
javascript
{ "resource": "" }
q17775
writeYAMLConfigFile
train
function writeYAMLConfigFile(config, filePath) { debug(`Writing YAML config file: ${filePath}`); // lazy load YAML to improve performance when not used const yaml = require("js-yaml"); const content = yaml.safeDump(config, { sortKeys: true }); fs.writeFileSync(filePath, content, "utf8"); }
javascript
{ "resource": "" }
q17776
writeJSConfigFile
train
function writeJSConfigFile(config, filePath) { debug(`Writing JS config file: ${filePath}`); let contentToWrite; const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; try { const CLIEngine = require("../cli-engine"); const linter = new CLIEn...
javascript
{ "resource": "" }
q17777
write
train
function write(config, filePath) { switch (path.extname(filePath)) { case ".js": writeJSConfigFile(config, filePath); break; case ".json": writeJSONConfigFile(config, filePath); break; case ".yaml": case ".yml": writeYAMLC...
javascript
{ "resource": "" }
q17778
getEslintCoreConfigPath
train
function getEslintCoreConfigPath(name) { if (name === "eslint:recommended") { /* * Add an explicit substitution for eslint:recommended to * conf/eslint-recommended.js. */ return path.resolve(__dirname, "../../conf/eslint-recommended.js"); } if (name === "eslint:a...
javascript
{ "resource": "" }
q17779
applyExtends
train
function applyExtends(config, configContext, filePath) { const extendsList = Array.isArray(config.extends) ? config.extends : [config.extends]; // Make the last element in an array take the highest precedence const flattenedConfig = extendsList.reduceRight((previousValue, extendedConfigReference) => { ...
javascript
{ "resource": "" }
q17780
isExistingFile
train
function isExistingFile(filename) { try { return fs.statSync(filename).isFile(); } catch (err) { if (err.code === "ENOENT") { return false; } throw err; } }
javascript
{ "resource": "" }
q17781
checkMetaProperty
train
function checkMetaProperty(node, metaName, propertyName) { return node.meta.name === metaName && node.property.name === propertyName; }
javascript
{ "resource": "" }
q17782
getVariableOfArguments
train
function getVariableOfArguments(scope) { const variables = scope.variables; for (let i = 0; i < variables.length; ++i) { const variable = variables[i]; if (variable.name === "arguments") { /* * If there was a parameter which is named "arguments", the * im...
javascript
{ "resource": "" }
q17783
isOneLiner
train
function isOneLiner(node) { const first = sourceCode.getFirstToken(node), last = sourceCode.getLastToken(node); return first.loc.start.line === last.loc.end.line; }
javascript
{ "resource": "" }
q17784
getElseKeyword
train
function getElseKeyword(node) { return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken); }
javascript
{ "resource": "" }
q17785
needsSemicolon
train
function needsSemicolon(closingBracket) { const tokenBefore = sourceCode.getTokenBefore(closingBracket); const tokenAfter = sourceCode.getTokenAfter(closingBracket); const lastBlockNode = sourceCode.getNodeByRangeIndex(tokenBefore.range[0]); if (astUtils.isSemicolonToken...
javascript
{ "resource": "" }
q17786
prepareCheck
train
function prepareCheck(node, body, name, opts) { const hasBlock = (body.type === "BlockStatement"); let expected = null; if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) { expected = true; } else if (multiOnly...
javascript
{ "resource": "" }
q17787
prepareIfChecks
train
function prepareIfChecks(node) { const preparedChecks = []; for (let currentNode = node; currentNode; currentNode = currentNode.alternate) { preparedChecks.push(prepareCheck(currentNode, currentNode.consequent, "if", { condition: true })); if (currentNode.alterna...
javascript
{ "resource": "" }
q17788
getCommentLineNums
train
function getCommentLineNums(comments) { const lines = []; comments.forEach(token => { const start = token.loc.start.line; const end = token.loc.end.line; lines.push(start, end); }); return lines; }
javascript
{ "resource": "" }
q17789
codeAroundComment
train
function codeAroundComment(token) { let currentToken = token; do { currentToken = sourceCode.getTokenBefore(currentToken, { includeComments: true }); } while (currentToken && astUtils.isCommentToken(currentToken)); if (currentToken && astUtils.isTokenOnS...
javascript
{ "resource": "" }
q17790
isParentNodeType
train
function isParentNodeType(parent, nodeType) { return parent.type === nodeType || (parent.body && parent.body.type === nodeType) || (parent.consequent && parent.consequent.type === nodeType); }
javascript
{ "resource": "" }
q17791
isCommentAtParentStart
train
function isCommentAtParentStart(token, nodeType) { const parent = getParentNodeOfToken(token); return parent && isParentNodeType(parent, nodeType) && token.loc.start.line - parent.loc.start.line === 1; }
javascript
{ "resource": "" }
q17792
isCommentAtParentEnd
train
function isCommentAtParentEnd(token, nodeType) { const parent = getParentNodeOfToken(token); return parent && isParentNodeType(parent, nodeType) && parent.loc.end.line - token.loc.end.line === 1; }
javascript
{ "resource": "" }
q17793
isCommentAtBlockEnd
train
function isCommentAtBlockEnd(token) { return isCommentAtParentEnd(token, "ClassBody") || isCommentAtParentEnd(token, "BlockStatement") || isCommentAtParentEnd(token, "SwitchCase") || isCommentAtParentEnd(token, "SwitchStatement"); }
javascript
{ "resource": "" }
q17794
report
train
function report(nodeOrToken) { context.report({ node: nodeOrToken, messageId: "unexpected", fix(fixer) { /* * Expand the replacement range to include the surrounding * tokens to avoid conflicting w...
javascript
{ "resource": "" }
q17795
checkForPartOfClassBody
train
function checkForPartOfClassBody(firstToken) { for (let token = firstToken; token.type === "Punctuator" && !astUtils.isClosingBraceToken(token); token = sourceCode.getTokenAfter(token) ) { if (astUtils.isSemicolonToken(token)) { ...
javascript
{ "resource": "" }
q17796
usedMemberSyntax
train
function usedMemberSyntax(node) { if (node.specifiers.length === 0) { return "none"; } if (node.specifiers[0].type === "ImportNamespaceSpecifier") { return "all"; } if (node.specifiers.length === 1) { return "sin...
javascript
{ "resource": "" }
q17797
isLastNode
train
function isLastNode(node) { const token = sourceCode.getTokenAfter(node); return !token || (token.type === "Punctuator" && token.value === "}"); }
javascript
{ "resource": "" }
q17798
getLastCommentLineOfBlock
train
function getLastCommentLineOfBlock(commentStartLine) { const currentCommentEnd = commentEndLine[commentStartLine]; return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd; }
javascript
{ "resource": "" }
q17799
checkForBlankLine
train
function checkForBlankLine(node) { /* * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will * sometimes be second-last if there is a semicolon on a different line. */ const lastToken = getLastToke...
javascript
{ "resource": "" }