@getluko/eslint-plugin-react-native
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

@getluko/eslint-plugin-react-native

This library was generated with Nx.

Building

Run nx build eslint-plugin-react-native to build the library.

Running unit tests

Run nx test eslint-plugin-react-native to execute the unit tests via Jest.

@getluko/eslint-plugin-mobile-guidelines

Installation

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

Configuration

.eslintrc.js

module.exports = {
  plugins: ['@getluko/react-native'],
  rules: {
    '@getluko/react-native/lower-dash-case-test-id': 1,
    '@getluko/react-native/i18n-avoid-global-imports: 2,
  }

Rules

@getluko/react-native/lower-dash-case-test-id

Allows you to enforce a consistent naming pattern for testID prop which expect a lower dash case.

  // bad ❌
  return (
    <Element
      testID="ElementTestID"
    />
  );

  // good ✅
  return (
    <Element
      testID="element-test-id"
    />
  );

@getluko/react-native/i18n-avoid-global-imports

Allows you to enforce i18n by avoiding global imports. it allows changing language dynamically without restarting the app.

  // bad ❌
  const key = i18n.t('key');
  return (
    <Text>{key}</Text>
  )

  // good ✅
  const getKey = () => i18n.t('key');
  return (
    <Text>{getKey()}</Text>
  );

Package Sidebar

Install

npm i @getluko/eslint-plugin-react-native

Weekly Downloads

25

Version

0.1.2

License

MIT

Unpacked Size

15.4 kB

Total Files

26

Last publish

Collaborators

  • demain-es