5.0.1 • Published 5 months ago

@veri.co/eslint-plugin-veri v5.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Eslint Plugin Veri

This package also shares common ESlint rules between different Veri projects.

What to include

Include common ESlint rules like basic Javascript, React and Node related rules that can be easily shared.

What not to include

Don't include rules that are specific to a technology that is only used in a single project. For example, don't include RealmJS related rules since at the time of writing this it's only used in Veri app. Hence no reason to share them with other projects.

How to use the shared linting rules

  1. Setup eslint in your project that is part of the monorepo.

  2. Inside the project, run:

    yarn add -D @veri.co/eslint-plugin-veri

  3. Then in .eslintrc add:

    plugins: [ "@veri.co/veri" ]

  4. To use presets, you also have to extend it:

    extends: [ "plugin:@veri.co/veri/node", "plugin:@veri.co/veri/react", "plugin:@veri.co/veri/react_native" ]

  5. Finally install required peer dependencies.

    • Node

      • yarn add -D eslint-plugin-jsx-falsy eslint-plugin-prettier eslint-plugin-simple-import-sort prettier eslint-plugin-node @waltari/eslint-plugin-ban-falsy-enum-values
    • React

      • yarn add -D eslint-plugin-react eslint-plugin-react-hooks
    • React Native

      • yarn add -D @react-native/eslint-config @react-native/eslint-plugin eslint-plugin-react-native

How to develop locally

  1. In eslint-plugin-veri folder run:

    yarn link

  2. Then in the projects folder you want to link it to e.g. app run:

    yarn link "@veri.co/eslint-plugin-veri"

  3. Now you can star making changes to config files which are under src/

  4. After you have done changes, build the configs

    yarn build

Now all the changes you make to eslint-plugin-veri are "copied" into the projects node_modules. Remember you still have to add "veri" to the plugins array in your .eslintrc file.

Note: You have to run yarn build every time you make some changes.

How to publish to npm

  1. Update package version number in package.json
  2. npm publish

Useful resources

Working with Abstract Syntax tree (AST)

Some useful resources are: https://astexplorer.net/ https://typescript-eslint.io/play/#ts=4.6.2&sourceType=module&showAST=es

In astexplorer you can even develop code for your rules and see in real time if they work with the AST. You can also add your own code and also see the resulting AST. Highly recommended to check it out if you start working with eslint rules.

In astexplorer try setting "ESLint v8" for Transform and "Typescript" for syntax. One difference between eslint-plugin-veri is that the rule listeners need to be "TSInterfaceDeclaration" instead of "InterfaceDeclaration" like in astexplorer in order to work. So make sure to append that "TS" prefix when working on eslint-plugin-veri on your computer, even though its not needed in astexplorer.

4.0.1

6 months ago

5.0.1

5 months ago

4.0.0

6 months ago

5.0.0

5 months ago

3.0.0

10 months ago

2.0.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago