Skip to content

Commit

Permalink
refactor: replace test with includes
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Oct 15, 2024
1 parent 4a2358a commit d6530b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ export function nodeResolve(opts = {}) {
return importee;
}
// ignore IDs with null character, these belong to other plugins
if (/\0/.test(importee)) return null;
if (importee.includes('\0')) return null;

const { custom = {} } = resolveOptions;
const { 'node-resolve': { resolved: alreadyResolved } = {} } = custom;
if (alreadyResolved) {
return alreadyResolved;
}

if (/\0/.test(importer)) {
if (importer.includes('\0')) {
importer = undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/pluginutils/src/attachScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'sc
let newScope: AttachedScope | undefined;

// create new function scope
if (/Function/.test(node.type)) {
if (node.type.includes('Function')) {
const func = node as estree.Function;
newScope = new Scope({
parent: scope,
Expand All @@ -106,7 +106,7 @@ const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'sc
}

// create new block scope
if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {
if (node.type === 'BlockStatement' && !parent.type.includes('Function')) {
newScope = new Scope({
parent: scope,
block: true
Expand Down

0 comments on commit d6530b9

Please sign in to comment.