1.0.5 • Published 1 year ago

@aikon/aikon-configs v1.0.5

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Aikon Config library

Shared AIKON configuration files

Reusable ESLint, Prettier, Typescript, and other config files

How to use

First step: Isntall

First add the package:

yarn add -D @aikon/aikon-config jest

Attention: @aikon/aikon-config must always be added as a devDependencies. If added as dependencies you may have build errors.

Attention 2: @aikon/aikon-config will install prittier, lint and all necessary plugins. Therefore the project must not install any additional packages. Only @aikon/aikon-config is needed

Why install jest?

The lint settings are ready to work with jest (which is being implemented little by little in the libs). So, if you don't install jest, when trying to run lint some errors will happen.

Second step: Config

Inside the project you must create the prittier and lint configuration files.

For lint you must create a file named .eslintrc.js:

// .eslintrc.js
module.exports = require("@aikon/aikon-configs/eslint-config-aikon");
// OR (if you want to use this on react projects)
module.exports = require("@aikon/aikon-configs/eslint-config-react-aikon");

For prettier you must create a file named .prettierrc.js:

// .prettierrc.js
module.exports = require("@aikon/aikon-configs/prettier-config-aikon");

Attention: Both lint and prettier have several naming options for configuration files. Make sure there are no other files as this can lead to miss function/erros.

Use inside this monorepo.

When we are using this package inside some other package inside this monorepo the installation is a little different. In these cases we should not use yarn, just add "@aikon/aikon-configs": "*" as to devDependencies, and also add jest. But attention, this is only valid for packages inside this monorepo.

Common Mistakes

If you're having trouble running lint or prittier, here are some common issues.

Incompatible versions of eslint.

If the lib already had a version of eslint installed and when installing @aikon/aikon-configs you just deleted the eslint (and its plugins) from the package.json file you may end up with incompatible versions of eslint.

The quickest way to fix this error is to verify that no eslint (and no plugins) are in package.json nor package-lock.json or yarn.lock. If this is the case, you can delete the eslint and its plugins from "the lock file", and then run yarn install (Usually deleting the entire lock-file solves the problem but beware that it is not possible to do this in all projects).

Error with jest.

As mentioned in the installation session, lint is already configured to work correctly with jest. So, if you're seeing this error, it's possible you haven't installed jest. To fix just run yarn add -D jest.

It is not necessary to have any tests created, only the package must be installed.

Build erros

If after adding @aikon/aikon-configs you are having errors in the build, check if it is in dependencies. If it is, move it to devDependencies. @aikon/aikon-configs it should only be a devDependencies never an dependencies.