Skip to content

Instantly share code, notes, and snippets.

@PauloLuan
Created February 2, 2022 13:57
Show Gist options
  • Save PauloLuan/c9e8515fd317aec6ae004f0c40cceee1 to your computer and use it in GitHub Desktop.
Save PauloLuan/c9e8515fd317aec6ae004f0c40cceee1 to your computer and use it in GitHub Desktop.
React Native ESLINT config

eslint-config-universe

Shared ESLint configs for Node, Web, and universal Expo projects.

Installation

yarn add --dev eslint-config-universe eslint prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser

Usage

Import this config into your own ESLint configuration using the extends option. ESLint checks both package.json and .eslintrc.* files for its configuration:

package.json

{
  "eslintConfig": {
    "extends": "universe/native"
  }
}

.eslintrc.js

// Choose from universe/native, universe/node, universe/web
module.exports = {
  extends: 'universe/native',
};

Customizing Prettier

If you would like to customize the Prettier settings, create a file named .prettierrc in your project directory. An example of Prettier configuration file:

{
  "semi": false,
  "tabWidth": 2,
  "singleQuote": true,
  "bracketSameLine": true,
  "trailingComma": "es5"
}

Read more about configuring prettier and all of the available options.

Support for Different Platforms

There are several configs for different platforms. They are:

  • universe: the basic config for JavaScript projects for which there isn't a more specific config
  • universe/native: the config for React Native projects, including Expo projects, with support for React and JSX
  • universe/web: the config for code that runs in web browsers, with support for React and JSX
  • universe/node: the config for code that runs in Node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment