Граф коммитов

16 Коммитов

Автор SHA1 Сообщение Дата
Tim Yung 03f5951b45 RN: Permit Inline Styles in Tests
Summary:
Configures ESLint in React Native to permit inline styles in tests. Because, why not.

Changelog:
[Internal]

Reviewed By: TheSavior

Differential Revision: D18290625

fbshipit-source-id: 111c7fd2972179536487b94bd7b14f34167ea8c7
2019-11-03 18:02:00 -08:00
dr2009 af8ea06bb4 Add WebSocket to eslint globals (#27044)
Summary:
WebSocket is giving an error by eslint. ('WebSocket is not defined').

[websocket-support](https://facebook.github.io/react-native/docs/network#websocket-support)

## Changelog
[General] [Fixed] - Add WebSocket to eslint globals
Pull Request resolved: https://github.com/facebook/react-native/pull/27044

Test Plan: Run eslint on a react native project using WebSocket. Eslint verification should pass.

Differential Revision: D18223891

Pulled By: cpojer

fbshipit-source-id: c4adfde07078133930aa0ed80be5615d128f4148
2019-10-30 08:32:52 -07:00
Christoph Nakazawa 55e974d9fa Revert D18173919: fix(eslint-config): Clashes with prettier
Differential Revision:
D18173919

Original commit changeset: b333469652b4

fbshipit-source-id: 819d484101be132ae3f2d3bf8e3ba008a9d91d83
2019-10-29 13:18:49 -07:00
Kyle Roach e4b62bb139 fix(eslint-config): Clashes with prettier (#26847)
Summary:
Currently, react-native-community config package extends from prettier/recommended which comes with default settings from prettier. However there are still some eslint rules in the config that either clash or duplicate the settings from prettier.

This results in eslint fixing the formatting and then prettier undoing it. This PR removes the style specific rules from eslint and place them in the prettier section.
## Changelog

[General] [Fixed] - Remove style rules from eslint config for prettier options
Pull Request resolved: https://github.com/facebook/react-native/pull/26847

Test Plan:
I created a repo for you to test with https://github.com/iRoachie/eslint-bug-replicate. You can see that running `yarn lint --fix` will never fix the issue. Eslint will complain about double quotes and subsequently after fixing it will complain about single quotes.

Here's a gif of the behaviour (vscode eslint plugin `"eslint.autoFixOnSave": true`):

![Kapture 2019-10-13 at 23 34 15](https://user-images.githubusercontent.com/5962998/66728290-ff80da00-ee11-11e9-8993-4d1b679c270b.gif)

Differential Revision: D18173919

Pulled By: cpojer

fbshipit-source-id: b333469652b4c8e72287718af94378505e9b7d59
2019-10-28 13:17:09 -07:00
Moti Zilberman 90977b0e00 Enable no-useless-escape lint rule
Summary: See https://eslint.org/docs/rules/no-useless-escape. Useless escapes can reflect a mismatch between the intended and actual effect of a backslash in a literal.

Reviewed By: rubennorte

Differential Revision: D17876784

fbshipit-source-id: 7641b1f2227b92e1e91469adc0d0d990a64109cf
2019-10-11 05:56:06 -07:00
Kant d2b92fffb1 Use eslint-plugin-prettier recommended config (#25674)
Summary:
I created a new test project today using RN 0.60.3 and saw that prettier is now used with eslint. After looking at the `react-native-community` eslint config, I notice that it wasn't using the [recommended configuration](https://github.com/prettier/eslint-plugin-prettier#recommended-configuration) of `eslint-plugin-prettier`

This PR adds the `eslint-config-prettier` to avoid conflicts between eslint and prettier, it also adds the `prettier/react` config to avoid problems with the `eslint-plugin-react`.

## Changelog

[General] [Changed] - Use eslint-plugin-prettier recommended config
Pull Request resolved: https://github.com/facebook/react-native/pull/25674

Test Plan: -  Ensure there is no difference on this repo (no ESLint errors, same number of warnings, and no changes when running prettier).

Differential Revision: D16666178

Pulled By: cpojer

fbshipit-source-id: 70f81db793866acc88388b7b00a496aab5e0b156
2019-08-09 06:41:41 -07:00
Rodinei Fagundes 76af5f9163 Add ErrorUtils to global variables (#25947)
Summary:
ErrorUtils is giving an error by eslint. ('ErrorUtils is not defined').

## Changelog
[General] [Fixed] - Add ErrorUtils to eslint globals
Pull Request resolved: https://github.com/facebook/react-native/pull/25947

Test Plan: Run eslint on a react native project using ErrorUtils. Eslint verification should pass.

Differential Revision: D16666163

Pulled By: cpojer

fbshipit-source-id: c20c4e21fe06c6863dcfc167d6d03c6217ae1235
2019-08-06 03:49:20 -07:00
Jacob Lee e78c01375a Allow jest globals in __mocks__ directories (#25738)
Summary:
The `__mocks__` directories should be treated the same as `__tests__`
for the purpose of linting. See https://jestjs.io/docs/en/manual-mocks

## Changelog

[Internal] [Changed] - eslint: allow jest globals in `__mocks__` directories
Pull Request resolved: https://github.com/facebook/react-native/pull/25738

Test Plan:
I installed the updated package locally in my project and verified
that the `no-undef` rule no longer fires for references to `jest` in
`__mocks__` directories.

Differential Revision: D16515546

Pulled By: osdnk

fbshipit-source-id: ae78b95d33d1b48ffa4aafa7a53c83e152d176b2
2019-07-26 03:37:29 -07:00
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
Matt Oakes 65eea9d1f8 Set the Prettier config so it is not forced on users of @react-native-community/eslint-config (#24635)
Summary:
This fixes an issue where the Prettier config was set to the `fb` (Facebook) values for all users of the `react-native-community/eslint-config` package. This was due to [this line](8f186b84ae/packages/eslint-config-react-native-community/index.js (L219)) in the config file.

It was causing issues like these:

* Errors when using newer versions of `eslint-plugin-prettier` (you had to use a version that was >1 year old): https://github.com/facebook/react-native/issues/24564
* Errors due to the Prettier parser being forced to be `flow` when using Typescript: https://github.com/typescript-eslint/typescript-eslint/issues/481

This PR:

* Changes that line to remove the explicit `fb` config so users can set their own.
* Moves the React Native Prettier config to `.prettierrc` so ESLint, Prettier, and code editors can all read from the same place.
* Upgrades both `prettier` and the `eslint-plugin-prettier` to the latest versions.

[General] [Fixed] - Stopped the Prettier config being set for all users of react-native-community/eslint-config
Pull Request resolved: https://github.com/facebook/react-native/pull/24635

Differential Revision: D15122200

Pulled By: cpojer

fbshipit-source-id: 56bae8a7f2d8e133b1d808091a6b73302b94d2ed
2019-04-29 09:44:51 -07:00
Eli White ec3adae99a Turn on react-hooks/exhaustive-deps in FBSource
Summary: Looks like there are already a bunch of issues in the codebase because this wasn't on.

Reviewed By: cpojer

Differential Revision: D14701084

fbshipit-source-id: 09ff8e0d905b81fbe08c41d4f58758479b38187b
2019-04-01 08:20:18 -07:00
satyajit.happy b49fdd19e4 Add typescript support to the ESLint config (#24100)
Summary:
This adds TypeScript support to the community ESLint config. Our babel preset supports TypeScript by default, so it's nice to have TypeScript support pre-configured in the ESLint config too.

Note: Users need to install `typescript` in their project for linting to work for TypeScript files.

[General] [Added] - Add TypeScript support to the ESLint config
Pull Request resolved: https://github.com/facebook/react-native/pull/24100

Differential Revision: D14597127

Pulled By: cpojer

fbshipit-source-id: dfbf1b97061ed6e8c46aa49adb21630f5acdb5d1
2019-03-25 21:28:26 -07:00
michalchudziak c8e26e6ac4 Fix eslint glob for `.test.js` and `.spec.js` files. (#24088)
Summary:
Existing glob might not work very well with `spec.js` and `test.js` files unless they're placed in `__tests__` directory. This PR aims to bring back the support of `jest` globals in these files, even if they're outside of `__tests__` directory.

[General] [Fixed] - Fixed globs for `spec.js` and `test.js` files.
Pull Request resolved: https://github.com/facebook/react-native/pull/24088

Differential Revision: D14562085

Pulled By: cpojer

fbshipit-source-id: 543d67e3f8a154256f454b34ccc68bb070197a75
2019-03-21 08:39:39 -07:00
michalchudziak 395197dafe Add .eslintrc to RN project template (#23901)
Summary:
The goal of this PR is to enable eslint checks in the projects generated by `react-native init` command. I added `template/_eslintrc` file, that would be replaced in an initialized project with `.eslintrc` file. This PR comes in parallel with https://github.com/react-native-community/react-native-cli/pull/229

[General] [Added] - Added `.eslintrc` file to generated template.
Pull Request resolved: https://github.com/facebook/react-native/pull/23901

Differential Revision: D14561084

Pulled By: cpojer

fbshipit-source-id: 6eb717bf03c45d83ae8a393e6a0abb79e1e2f915
2019-03-21 07:14:23 -07:00
Matt Hargett e67aa427a8 Eliminate eslint npm version mismatch warnings and bump some to latest (#23969)
Summary:
I was annoyed by warnings from yarn/npm about eslint peer dependencies not being met, so I dived in to try and get rid of some of them. Sometimes it meant bumping a plugin, but then that plugin needed a newer babel-eslint, so it was a dance.

Some we can't easily update to latest (eslint-plugin-prettier) because the rule format has changed a bit. Happy to do that in this PR if folks think its a good idea. eslint-config-fbjs itself needs to be updated and republished to eliminate the last few warnings.

There are a few new warnings (the repo wasn't linting cleanly for me from the start). I can fix those in this PR, or a separate one, based on people's preferences.

[internal] [chore] - Eliminate some peer dependency warnings and bump some eslint packages to latest.
Pull Request resolved: https://github.com/facebook/react-native/pull/23969

Differential Revision: D14519076

Pulled By: cpojer

fbshipit-source-id: aa44cfd05814d7b79069414aa78d089e448c2235
2019-03-19 11:14:30 -07:00
michalchudziak 1ed2b82693 Rename eslint config to 'eslint-config-react-native-community' (#23718)
Summary:
Renamed `eslint-config-react-native` to `eslint-config-react-native-community`, due to the fact, that initial name is already taken on `npm`. Additionally, I added very simple `README.md` file, to prepare the package to be published.

[General] [Changed] - Changed `eslint-config-react-native` name to `eslint-config-react-native-community`
Pull Request resolved: https://github.com/facebook/react-native/pull/23718

Differential Revision: D14298553

Pulled By: cpojer

fbshipit-source-id: bad5a42502ccdebf5f95d8217187be23bbf8f26c
2019-03-03 20:39:43 -08:00