Home / File/ no-primitive-constructors-test.internal.js — react Source File

no-primitive-constructors-test.internal.js — react Source File

Architecture documentation for no-primitive-constructors-test.internal.js, a javascript file in the react codebase.

Entity Profile

Source Code

/**
 * 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.
 *
 * @emails react-core
 */

'use strict';

const rule = require('../no-primitive-constructors');
const {RuleTester} = require('eslint');
const ruleTester = new RuleTester();

ruleTester.run('eslint-rules/no-primitive-constructors', rule, {
  valid: ['!!obj', '+string'],
  invalid: [
    {
      code: 'Boolean(obj)',
      errors: [
        {
          message:
            'Do not use the Boolean constructor. To cast a value to a boolean, use double negation: !!value',
        },
      ],
    },
    {
      code: 'new String(obj)',
      errors: [
        {
          message:
            "Do not use `new String()`. Use String() without new (or '' + value for perf-sensitive code).",
        },
      ],
    },
    {
      code: 'Number(string)',
      errors: [
        {
          message:
            'Do not use the Number constructor. To cast a value to a number, use the plus operator: +value',
        },
      ],
    },
  ],
});

Frequently Asked Questions

What does no-primitive-constructors-test.internal.js do?
no-primitive-constructors-test.internal.js is a source file in the react codebase, written in javascript.
Where is no-primitive-constructors-test.internal.js in the architecture?
no-primitive-constructors-test.internal.js is located at scripts/eslint-rules/__tests__/no-primitive-constructors-test.internal.js (directory: scripts/eslint-rules/__tests__).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free