@sngular/lint-staged-config

1.0.0 • Public • Published

@sngular/lint-staged-config

Sharable lint-staged config enforcing SNGULAR style guidelines.

Getting started

Install

npm install --save-dev @sngular/lint-staged-config

Configure

With ESLint

echo "module.exports = require('@sngular/lint-staged-config');" > lint-staged.config.cjs

With ESLint & Prettier

echo "module.exports = require('@sngular/lint-staged-config/prettier.cjs');" > lint-staged.config.cjs

Hook

After that you can use husky to add a pre-commit hook to lint your code before each commit:

npx husky add .husky/pre-commit 'npx --no -- lint-staged'

Different paths for .git file and package.json

husky install must be run in the same directory as .git, but you can change directory during prepare script and pass a different directory. If your .git file and package.json are in different folders, you will have to specific the package.json directory in both the prepare script and the husky hooks.

In this example, the .git file is one level below the folder with the package.json (located at /front).

{
	"scripts": {
		"prepare": "cd .. && husky install front/.husky"
	}
}

If you had a pre-commit hook, you would need to specify the directory as follows:

# ...
cd front
npm test

Scripts

Based on the selected configuration, it will execute different actions according to the following rules:

With ESLint

  • *.{js,cjs,mjs,jsx,ts,tsx}
    • eslint --fix

With ESLint & Prettier

  • *.{js,cjs,mjs,jsx,ts,tsx}
    • eslint --fix
    • prettier --write
  • *.{md,html,css,yml,yaml}
    • prettier --write

Readme

Keywords

none

Package Sidebar

Install

npm i @sngular/lint-staged-config

Weekly Downloads

5

Version

1.0.0

License

none

Unpacked Size

18.2 kB

Total Files

6

Last publish

Collaborators

  • je.garcia
  • sngularbot
  • jorgecasar