Skip to content

Conversation

@dratwas
Copy link
Contributor

@dratwas dratwas commented Feb 28, 2019

Summary

Basing on discussion from this issue - react-native-community/discussions-and-proposals#65 we moved ESLint/Prettier config to its own package inside packages directory.
At this moment we had to left all eslint dependencies in root package.json since eslint-config-react-native is not published yet.

Changelog

[General] [Changed] - Move eslint/prettier config to packages/eslint-config-react-native

Test Plan

Lint returns same numbers as before
yarn lint output:

✖ 80 problems (0 errors, 80 warnings)

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 28, 2019
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@michalchudziak
Copy link
Contributor

Thanks, @dratwas!

@matt-oakes @cpojer could you take a look? We'll probably need your help with BUCK file if it's required.

Also, we were wondering if the new config should be included as a dependency in root package.json? For now, we just extended eslint config with a relative path to the package. We believe that it might not be the ideal solution. WDYT?

@matt-oakes
Copy link
Contributor

matt-oakes commented Feb 28, 2019

Looking good!

React Native has some custom prettier configuration in the root package.json (https://github.com/facebook/react-native/blob/master/package.json#L13-L20).

With this PR, the Prettier config for core React Native and users of this ESLint configuration would be different unless the users include the same Prettier configuration.

It is possible to specify the options in this ESLint config, however, it is not recommended because most editor plugins will not read the options and will give inconsistent results.

As I see it, there are three options:

  1. Ensure that all users of this ESLint config also have the same PRettier config included.
  2. Accept that the prettier config might be different across projects, but that it will at least be standard within the project.
  3. Change the React Native core to just use prettier with the standard configuration and no customisation to ensure that it is consistent by default.

@gengjiawen
Copy link
Contributor

@matt-oakes We have eslint-plugin-prettier, there should be no format collision

"eslint-plugin-prettier": "2.6.0",

@matt-oakes
Copy link
Contributor

@gengjiawen The plugin is there, but I think that the core React Native repository has some custom settings, seen here in the package.json https://github.com/facebook/react-native/blob/master/package.json#L13-L20.

These will be correctly picked up when the core React Native repository runs ESLint, but if a community module uses this ESLint config then they will, by default, get the standard Prettier configuration. To fully match the React Native code style, they will need to include the same configuration in their repository.

I should say, this is all guesswork on my part, I've not actually tested that this is the case, however, from the Prettier and eslint-plugin-prettier documentation, that should be the case.

@elicwhite
Copy link
Member

elicwhite commented Feb 28, 2019

We could also duplicate the config into the eslint config and ensure that it stays consistent, right?

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much, this is exactly what I had in mind to start.

  • I agree we should figure out how to make all projects use the same prettier config, at least in react-native-community. Maybe in a follow-up PR we can add the config to the eslint setup (even if that's not recommended) and add a README to this package that asks people to add the appropriate prettier config for their projects.
  • Did you ask the author of the npm package for the package name and are you able to publish to it? Otherwise I'll have to change the name prior to publishing (I may reuse the @react-native-community org).
  • I'll try to land and see if I have to make any changes internally.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 1, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @dratwas in e903d80.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added Merged This PR has been merged. and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Mar 1, 2019
blancham pushed a commit to kraaft-co/eslint-config-react-native that referenced this pull request Jan 13, 2026
…23688)

Summary:
Basing on discussion from this issue - react-native-community/discussions-and-proposals#65 we moved ESLint/Prettier config to its own package inside packages directory.
At this moment we had to left all `eslint` dependencies in root `package.json` since `eslint-config-react-native` is not published yet.

[General] [Changed] - Move eslint/prettier config to packages/eslint-config-react-native
Pull Request resolved: facebook/react-native#23688

Differential Revision: D14277068

Pulled By: cpojer

fbshipit-source-id: ef2d0b33210418318cc8324f15fedd84df0ef64d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Callstack Partner: Callstack Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants