react-native-macos/packages/eslint-plugin-react-native-...
James Ide 33ee6f8b99 Add a lint rule to disallow Haste imports (#25058)
Summary:
This is an ESLint plugin that infers whether an import looks like a Haste module name. To keep the linter fast and simple, it does not look in the Haste map. Instead, it looks for uppercase characters in single-name import paths, since npm has disallowed uppercase letters in package names for a long time. There are some false negatives (e.g. "merge" is a Haste module and this linter rule would not pick it up) but those are about 1.1% of the module names in the RN repo, and unit tests and integration tests will fail anyway once Haste is turned off.

You can disable the lint rule on varying granular levels with ESLint's normal disabling/enabling mechanisms.

Also rewrote more Haste imports so that the linter passes (i.e. fixed lint errors as part of this PR).

## Changelog

[General] [Changed] - Add a lint rule to disallow Haste imports
Pull Request resolved: https://github.com/facebook/react-native/pull/25058

Differential Revision: D15515826

Pulled By: cpojer

fbshipit-source-id: d58a3c30dfe0887f8a530e3393af4af5a1ec1cac
2019-05-30 07:45:16 -07:00
..
README.md Add a lint rule to disallow Haste imports (#25058) 2019-05-30 07:45:16 -07:00
index.js Add a lint rule to disallow Haste imports (#25058) 2019-05-30 07:45:16 -07:00
no-haste-imports.js Add a lint rule to disallow Haste imports (#25058) 2019-05-30 07:45:16 -07:00
package.json Add a lint rule to disallow Haste imports (#25058) 2019-05-30 07:45:16 -07:00

README.md

eslint-plugin-react-native-community

This plugin is intended to be used in @react-native-community/eslint-plugin. You probably want to install that package instead.

Installation

yarn add --dev eslint @react-native-community/eslint-plugin

Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like

Usage

Add to your eslint config (.eslintrc, or eslintConfig field in package.json):

{
    "plugins": ["@react-native-community"]
}