# @osf-global/linter

> ## Installation Make sure your NodeJS version is up to date, as requred in `package.json` in `engines` section.

Latest version **4.3.2** (published 2021-02-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @osf-global/linter
pnpm add @osf-global/linter
yarn add @osf-global/linter
bun add @osf-global/linter
```

Provides the commands `osf-fixer`, `osf-linter`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.3.2 |
| Published | 2021-02-10 |
| First published | 2019-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 28.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Daniel Anechitoaie |
| Maintainers | alexandru.bradescu, danechitoaie |

## Links

- npm: https://www.npmjs.com/package/@osf-global/linter
- Repository: https://github.com/OSFGlobal/OSF-Linter
- Homepage: https://github.com/OSFGlobal/OSF-Linter#readme
- Issues: https://github.com/OSFGlobal/OSF-Linter/issues
- npm.io page: https://npm.io/package/@osf-global/linter

## Dependencies (16)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [yargs](https://npm.io/package/yargs.md) ^13.2.4
- [eslint](https://npm.io/package/eslint.md) ^6.0.0
- [globby](https://npm.io/package/globby.md) ^9.2.0
- [lodash](https://npm.io/package/lodash.md) >=4.17.19
- [kind-of](https://npm.io/package/kind-of.md) >=6.0.3
- [dot-prop](https://npm.io/package/dot-prop.md) >=5.1.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.0.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^3.3.0
- [stylelint](https://npm.io/package/stylelint.md) ^13.9.0
- [isml-linter](https://npm.io/package/isml-linter.md) latest
- [babel-eslint](https://npm.io/package/babel-eslint.md) ^10.0.3
- [yargs-parser](https://npm.io/package/yargs-parser.md) >=13.1.2
- [stylelint-scss](https://npm.io/package/stylelint-scss.md) ^3.8.0
- [stylelint-config-standard](https://npm.io/package/stylelint-config-standard.md) ^18.3.0

## Recent versions

- 4.3.2 (latest) — 2021-02-10
- 4.3.1 — 2020-12-03
- 4.3.0 — 2020-11-16
- 4.2.0 — 2020-07-27
- 4.1.0 — 2020-04-30
- 4.0.3 — 2019-11-29
- 4.0.2 — 2019-11-25
- 4.0.1 — 2019-11-21
- 4.0.0 — 2019-11-19
- 3.2.0 — 2019-10-25
- 3.1.0 — 2019-10-17
- 3.0.1 — 2019-10-15
- 3.0.0 — 2019-10-14
- 2.2.0 — 2019-09-09
- 2.1.0 — 2019-06-25
- … 16 more at https://npm.io/package/@osf-global/linter/versions

## README

# OSF Linter

## Installation
Make sure your NodeJS version is up to date, as requred in `package.json` in `engines` section.

Use NVM to be able to easely install and use any version of NodeJS you need (https://github.com/coreybutler/nvm-windows for Windows or https://github.com/nvm-sh/nvm for MacOS/Linux)

Run `yarn add --dev @osf-global/linter` if you use Yarn (recommended) or `npm install --save-dev @osf-global/linter` if you use NPM

Edit your `package.json` file and add the following scripts:

```
"lint:js": "osf-linter --linter=JS",
"lint:scss": "osf-linter --linter=SCSS",
"lint:isml": "osf-linter --linter=ISML",
"fix:js": "osf-fixer --fixer=JS",
"fix:scss": "osf-fixer --fixer=SCSS",
"fix:isml": "osf-fixer --fixer=ISML"
```

For additional help messages you can also run `./node_modules/.bin/osf-linter --help` or `./node_modules/.bin/osf-fixer --help`

## Configuration
To configure OSF Linter and define the list of paths to be linted you will need to create a new file `osflinter.paths.js` next to your `package.json` file which should be at the root of your repo/project (if best practices are followed).

The contents of the `osflinter.paths.js` should look like the bellow example, with each linter (see `./node_modules/.bin/osf-linter --help` for the available linters and thieir respective names) exporting an array of path patterns used by the linter to check the files. See https://github.com/sindresorhus/globby#globbing-patterns for the syntax supported for the patterns.

```
module.exports.JS = [
    "cartridges/app_demo/**/*.js",  // include all JS files from the app_demo cartridge
    "!cartridges/app_demo/cartridge/client/default/js/specific-file.js" // exclude this JavaScript file using a path pattern that begins with "!"
];

module.exports.SCSS = [
    "cartridges/app_demo/cartridge/client/*/css/**/*.scss"
];

module.exports.ISML = [
    "cartridges/app_demo/cartridge/templates/**/*.isml"
];
```


## Next you need to create these three new files next to your `package.json` file which should be at the root of your repo/project:

### `.eslintrc.js` with the following contents:

```
module.exports = require("@osf-global/linter/config/.eslintrc");
```

If you want to customize the default rules you can do that by either setting the specific properties that you want directly on the `module.exports` object or by using a variable that you then reexport.

Ex:
```
module.exports = require("@osf-global/linter/config/.eslintrc");

# Using single quotes
module.exports.rules.quotes = ["error", "single"];
```

A good example is setting up default SFCC globals and adding support of ES6 for your client side code.

Ex:
```
module.exports = require("@osf-global/linter/config/.eslintrc");
module.exports.overrides = [
    // Setting up default SFCC globals
    {
        files: ["cartridges/*/cartridge/{controllers,models,scripts}/**/*.js"],
        globals: {
            dw: true,
            customer: true,
            session: true,
            request: true,
            response: true,
            empty: true,
            PIPELET_ERROR: true,
            PIPELET_NEXT: true,
            webreferences: true
        }
    },

    // Adding support for ES6 code in the client folder for your cartridge
    {
        files: ["cartridges/*/cartridge/client/*/js/**/*.js"],
        parser: "babel-eslint",
        parserOptions: {
            ecmaVersion: 6,
            sourceType: "module",
            allowImportExportEverywhere: false
        },
        env: {
            browser: true,
            commonjs: true,
            es6: true,
            jquery: true
        },
        globals: {
            __webpack_public_path__: true
        }
    }
];
```


### `.stylelintrc.js` with the following contents:

```
module.exports = require("@osf-global/linter/config/.stylelintrc");
```

If you want to customize the default rules you can do that by either setting the specific properties that you want directly on the `module.exports` object or by using a variable that you then reexport.

Ex:
```
module.exports = require("@osf-global/linter/config/.stylelintrc");

# Using two spaces for indentation
module.exports.rules.indentation = 2;
```

### `.ismllintrc.js` with the following contents:

```
module.exports = require("@osf-global/linter/config/.ismllintrc");
```

If you want to customize the default rules you can do that by either setting the specific properties that you want directly on the `module.exports` object or by using a variable that you then reexport.

Ex:
```
module.exports = require("@osf-global/linter/config/.ismllintrc");

# Using two spaces for indentation
module.exports.rules.indent = {value: 2};
```

You can find all available rules and configurations for Isml Linter [here][url-isml-linter].

## Contributors
See https://github.com/OSFGlobal/OSF-Linter/graphs/contributors for a list of people that contributed to this project

[url-isml-linter]:  <https://www.npmjs.com/package/isml-linter>

---
_Source: https://npm.io/package/@osf-global/linter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
