/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
compiler/packages/babel-plugin-react-compiler/src/__tests__/test-utils/validateNoUseBeforeDefine.ts
41 строка
1 KB
Jan Kassens
Compiler: unfork prettier config (#30205)
19 июл 2024, 00:00
Не верифицирован
19 июл 2024, 00:00
fd2b3e1
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // @ts-ignore-line import {Linter} from '../../../node_modules/eslint/lib/linter'; // @ts-ignore-line import * as HermesESLint from 'hermes-eslint'; // @ts-ignore-line import {NoUseBeforeDefineRule} from '../..'; const ESLINT_CONFIG: Linter.Config = { parser: 'hermes-eslint', parserOptions: { sourceType: 'module', }, rules: { 'custom-no-use-before-define': [ 'error', {variables: false, functions: false}, ], }, }; /** * Post-codegen pass to validate that the generated code does not introduce bugs. * Note that the compiler currently incorrectly reorders code in some cases: this * step detects this using ESLint's no-use-before-define rule at its strictest * setting. */ export default function validateNoUseBeforeDefine( source: string, ): Array<{line: number; column: number; message: string}> | null { const linter = new Linter(); linter.defineParser('hermes-eslint', HermesESLint); linter.defineRule('custom-no-use-before-define', NoUseBeforeDefineRule); return linter.verify(source, ESLINT_CONFIG); }