4.41.0 • Published 3 days ago

@s-ui/lint v4.41.0

Weekly downloads
1,373
License
MIT
Repository
-
Last release
3 days ago

sui-lint

CLI to lint your code and make it compliant.

It provides:

  • Same js and sass style of code across all company.
  • Linting rules a reference package, not duplicated linting config in every project.
  • Implemented as a reusable CLI.

Installation

$ npm install @s-ui/lint --save-dev

CLI

When installed, a new CLI sui-lint is automatically available to lint your files according to SUI conventions.

Lint JS files

$ sui-lint js [options]

It lints all js|jsx files in your project, excluding .eslintignore and .gitignore file patterns.

Same options available in eslint except one: -c, --config. If you try to use this option, an exception will be thrown.

Format JS files

$ sui-lint js --fix [options]

Lint SASS files

$ sui-lint sass [options]

Lints all **/src/**/*.scss files in the project, excluding node_modules, lib, dist.

.gitignore file patterns are also excluded but interpretation may differ as only glob patterns are understood

Scope commands to staged files

$ sui-lint js --staged
$ sui-lint js --fix --staged
$ sui-lint sass --staged

Same command but applied only on staged files (obtained with git diff --cached --name-only --diff-filter=d command).

For integrations, prettier config is located in @s-ui/lint/.prettierrc.js.

Add fixes to the stage

$ sui-lint js --staged --add-fixes
$ sui-lint js --fix --staged --add-fixes

This option can only be used with --staged.

In fix mode like with sui-lint js --fix, the --add-fixes option will stage the files again (git add <file...>)

It's usefull to make your code autoformat before any commit.

IDE integration

Steps to integrate sui-lint with an IDE:

  1. Install (if needed) eslint/sassLint plugin in your IDE.
  2. Add these lines to package.json:
{
  "eslintConfig": {
    "extends": ["./node_modules/@s-ui/lint/eslintrc.js"]
  },
  "stylelint": {
    "extends": "./node_modules/@s-ui/lint/stylelint.config.js"
  }
}

Example package.json

{
  "name": "test-project",
  "version": "1.0.0",
  "scripts": {
    "lint": "npm run lint:js && npm run lint:sass",
    "lint:js": "sui-lint js",
    "lint:sass": "sui-lint sass"
  },
  "devDependencies": {
    "@s-ui/lint": "1.0.0-beta.1"
  },
  "eslintConfig": { "extends": "./node_modules/@s-ui/lint/eslintrc.js" },
  "stylelint": { "extends": "./node_modules/@s-ui/lint/stylelint.config.js" },
}

VSCode and prettier

Prettier is integrated in sui-lint thanks to specific eslint rules. If you want VSCode to format your code exactly as sui-lint js --fix would do, you need specific config.

prettier + eslint + stylelint

If you have installed prettier in VSCode you can launch it with CMD + Shift + P -> Format Document over an opened file to format it with prettier

By adding this line to your settings:

{
  "prettier.eslintIntegration": true,
  "prettier.stylelintIntegration": true
}

When you do CMD + Shift + P -> Format Document the format tool will use prettier-eslint^[prettier-eslint is a dependency of prettier-vscode] that will do a eslint --fix after formatting your JavaScript file with prettier

So this shortcut will format our files ( w/ prettier) according to our sui-lint rules.

you will need the eslintConfig and stylelintconfig properties added to the package.json as explained above

Eslint extension

Install VSCode ESLint extension, and set eslint.autoFixOnSave to true:

{
  "eslint.autoFixOnSave": true
}

Stylelint extension

Install VSCode Stylelint extension.

Conflict with formatOnSave

If you have prettier enabled, or the default VSCode formatter activated with editor.formatOnSave to true, it may conflict with the eslint.autoFixOnSave option.

{
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false,
  },
}

In case you have already the formatOnSave property disabled but want to get the functionality working for SCSS files, you'll need to activate it for SCSS file types in order to prettier fix your problems using stylelint. For this, you have to use the next config.

  "[scss]": {
    "editor.formatOnSave": true
  },
4.41.0

27 days ago

4.37.0

1 month ago

4.40.0

1 month ago

4.36.0-beta.12

1 month ago

4.36.0-beta.11

2 months ago

4.36.0-beta.10

2 months ago

4.36.0-beta.8

2 months ago

4.36.0-beta.9

2 months ago

4.36.0-beta.7

2 months ago

4.36.0-beta.4

2 months ago

4.36.0-beta.5

2 months ago

4.36.0-beta.6

2 months ago

4.36.0-beta.0

2 months ago

4.36.0-beta.1

2 months ago

4.36.0-beta.2

2 months ago

4.36.0-beta.3

2 months ago

4.36.0

4 months ago

4.35.0

5 months ago

4.34.0

6 months ago

4.33.0

11 months ago

4.34.0-typescript.0

11 months ago

4.32.0

11 months ago

4.31.0

11 months ago

4.30.0

12 months ago

4.29.0-jest.0

1 year ago

4.29.0

1 year ago

4.25.0

2 years ago

4.21.0

2 years ago

4.26.0

2 years ago

4.24.0

2 years ago

4.23.0

2 years ago

4.28.0

2 years ago

4.22.0

2 years ago

4.27.0

2 years ago

4.18.0

2 years ago

4.17.0

2 years ago

4.20.0

2 years ago

4.19.0

2 years ago

4.14.0

2 years ago

4.13.0

2 years ago

4.16.0

2 years ago

4.12.0

2 years ago

4.15.0

2 years ago

4.11.0-beta.3

2 years ago

4.11.0

2 years ago

4.10.0

2 years ago

4.11.0-beta.1

2 years ago

4.11.0-beta.2

2 years ago

4.11.0-beta.0

2 years ago

4.9.0

2 years ago

4.4.0

2 years ago

4.0.0

2 years ago

3.47.0

2 years ago

3.44.0-beta.10

2 years ago

3.44.0

2 years ago

4.8.0

2 years ago

4.7.0

2 years ago

4.3.0

2 years ago

3.45.0

2 years ago

4.6.0

2 years ago

4.2.0

2 years ago

3.46.0

2 years ago

4.5.0

2 years ago

4.1.0

2 years ago

3.43.0

2 years ago

3.40.0

2 years ago

3.41.0

2 years ago

3.42.0

2 years ago

3.39.0

2 years ago

3.36.0

3 years ago

3.38.0

3 years ago

3.36.0-beta.14

3 years ago

3.36.0-beta.15

3 years ago

3.36.0-beta.16

3 years ago

3.39.0-beta.1

3 years ago

3.36.0-beta.12

3 years ago

3.39.0-beta.0

3 years ago

3.36.0-beta.13

3 years ago

3.37.0

3 years ago

3.37.0-beta.1

3 years ago

3.37.0-beta.0

3 years ago

3.36.0-beta.9

3 years ago

3.36.0-beta.8

3 years ago

3.36.0-beta.10

3 years ago

3.35.0

3 years ago

3.35.0-beta.1

3 years ago

3.34.0

3 years ago

3.33.1-beta.3

3 years ago

3.33.1-beta.4

3 years ago

3.33.1-beta.1

3 years ago

3.33.1-beta.2

3 years ago

3.33.1-beta.0

3 years ago

3.33.0

3 years ago

3.32.0

3 years ago

3.32.0-alpha.2

3 years ago

3.32.0-alpha.1

3 years ago

3.32.0-alpha.0

3 years ago

3.31.0

3 years ago

3.30.0

3 years ago

3.29.0

3 years ago

3.28.0

3 years ago

3.26.0

3 years ago

3.25.0

4 years ago

3.24.0

4 years ago

3.23.0

4 years ago

3.22.0

4 years ago

3.21.0

4 years ago

3.20.0

4 years ago

3.19.0

4 years ago

3.18.0

4 years ago

3.18.0-beta.1

4 years ago

3.18.0-beta.0

4 years ago

3.17.0

4 years ago

3.16.0

4 years ago

3.15.0

4 years ago

3.14.0

4 years ago

3.13.0

4 years ago

3.13.0-beta.4

4 years ago

3.13.0-beta.3

4 years ago

3.13.0-beta.2

4 years ago

3.13.0-beta.1

4 years ago

3.13.0-beta.0

4 years ago

3.12.0

4 years ago

3.11.0

5 years ago

3.10.0

5 years ago

3.9.0

5 years ago

3.8.0

5 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.0-beta.0

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0-beta.0

5 years ago

3.0.0

5 years ago

2.25.1

5 years ago

2.25.0

5 years ago

2.24.0

5 years ago

2.23.0

5 years ago

2.22.0

5 years ago

2.21.0

5 years ago

2.20.0

5 years ago

2.19.0

6 years ago

2.18.0

6 years ago

2.17.1

6 years ago

2.18.0-beta.0

6 years ago

2.17.0

6 years ago

2.16.0

6 years ago

2.15.0

6 years ago

2.14.0

6 years ago

2.13.0

6 years ago

2.12.0

6 years ago

2.11.0

6 years ago

2.10.0

6 years ago

2.9.0

6 years ago

2.8.0

6 years ago

2.7.0

6 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.0

7 years ago