@osf-global/linter
## Installation Make sure your NodeJS version is up to date, as requred in `package.json` in `engines` section.
Last updated a month ago by danechitoaie .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @osf-global/linter 
SYNC missed versions from official npm registry.

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.

Contributors

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

Current Tags

  • 4.1.0                                ...           latest (a month ago)

27 Versions

  • 4.1.0                                ...           a month ago
  • 4.0.3                                ...           6 months ago
  • 4.0.2                                ...           6 months ago
  • 4.0.1                                ...           6 months ago
  • 4.0.0                                ...           6 months ago
  • 3.2.0                                ...           7 months ago
  • 3.1.0                                ...           7 months ago
  • 3.0.1                                ...           7 months ago
  • 3.0.0                                ...           7 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.13                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 19
Last Day 0
Last Week 0
Last Month 0
Dependencies (13)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |