Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2025-02-03 17:20:53 +00:00
parent 3e913ef09d
commit 9660df3fcc
990 changed files with 74805 additions and 60149 deletions

View file

@ -18,6 +18,7 @@ const defaultPlugins = [
// 'nullishCoalescing', // TODO: update to babel 7
];
let plugins = [...defaultPlugins];
let isESM = false;
export function setParserName(name) {
parserName = name;
@ -33,8 +34,13 @@ export function changePlugins(pluginOrFn) {
}
}
export function setIsESM() {
isESM = true;
}
beforeEach(() => {
plugins = [...defaultPlugins];
isESM = false;
});
function parse(code) {
@ -43,7 +49,7 @@ function parse(code) {
}
if (parserName === 'babel') {
try {
return babelParser.parse(code, { plugins, sourceFilename: 'test.js' });
return babelParser.parse(code, { plugins, sourceFilename: 'test.js', ...(isESM && { sourceType: 'module' }) });
} catch (_) {
// eslint-disable-next-line no-console
console.warn(`Failed to parse with ${fallbackToBabylon ? 'babylon' : 'Babel'} parser.`);

View file

@ -92,5 +92,27 @@ describe('elementType tests', () => {
assert.equal(actual, expected);
});
it('works with nested fragments', () => {
const code = `
<Hello
role="checkbox"
frag={
<>
<div>Hello</div>
<>
<div>There</div>
</>
</>
}
/>
`;
const node = getOpeningElement(code);
const expected = 'Hello';
const actual = elementType(node);
assert.equal(actual, expected);
});
});
});

View file

@ -6,6 +6,7 @@ import {
describeIfNotBabylon,
changePlugins,
setParserName,
setIsESM,
} from '../helper';
import { getLiteralPropValue } from '../../src/getPropValue';
@ -497,6 +498,21 @@ describe('getLiteralPropValue', () => {
});
});
describeIfNotBabylon('import.meta', () => {
beforeEach(() => {
setIsESM();
});
it('should return null', () => {
const prop = extractProp('<div foo={import.meta.env.whyIsThisNotOnProcess} />');
const expected = null;
const actual = getLiteralPropValue(prop);
assert.deepEqual(actual, expected);
});
});
describeIfNotBabylon('Typescript', () => {
beforeEach(() => {
changePlugins((pls) => [...pls, 'typescript']);
@ -531,7 +547,7 @@ describe('getLiteralPropValue', () => {
});
it('should work with a this.props value', () => {
const prop = extractProp('<a href={this.props.href!}>Download</a>');
const prop = extractProp('<a href={this.props.href!}>Download</a>', 'href');
const expected = null;
const actual = getLiteralPropValue(prop);
assert.equal(actual, expected);

View file

@ -150,6 +150,28 @@ describe('getPropValue', () => {
assert.equal(actual, expected);
});
it('supports a prop value containing nested fragments', () => {
const propCode = `
<>
<div>Hello</div>
<>
<div>There</div>
</>
</>
`;
const code = `
<Hello
role="checkbox"
frag={${propCode}}
/>
`;
const prop = extractProp(code, 'frag');
const actual = getPropValue(prop);
assert.deepEqual(actual, propCode.trim());
});
});
describe('Identifier', () => {
@ -1148,6 +1170,13 @@ describe('getPropValue', () => {
assert.equal(actual, expected);
});
it('should return string representation of a TSNonNullExpression of form `function()!.property`', () => {
const prop = extractProp('<div foo={bar()!.bar} />');
const expected = 'bar()!.bar';
const actual = getPropValue(prop);
assert.equal(actual, expected);
});
it('should return string representation of a TSNonNullExpression of form `object!.property!`', () => {
const prop = extractProp('<div foo={bar!.bar!} />');
const actual = getPropValue(prop);