Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssimon committed Feb 15, 2019
0 parents commit 171f03b
Show file tree
Hide file tree
Showing 15 changed files with 1,392 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": true,
"extends": [
"@jenssimon/base"
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
yarn-error.log
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jens Simon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
[![NPM version][npm-image]][npm-url] [![Downloads][npm-downloads-image]][npm-url] [![Dependencies][deps-image]][deps-url] [![devDependencies][deps-dev-image]][deps-dev-url] [![peerDependencies][deps-peer-image]][deps-peer-url] [![star this repo][gh-stars-image]][gh-url] [![fork this repo][gh-forks-image]][gh-url] ![Code Style][codestyle-image]

# eslint-config-sfcc

> A collection of shareable ESLint configurations for Salesforce Commerce Cloud (SFCC)
## Installation

```sh
$ yarn add @jenssimon/eslint-config-sfcc
```

## General

All configurations are based on the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript#readme) and a set of additions ([@jenssimon/eslint-config-base](https://github.com/jenssimon/eslint-config-base#readme)).

This package contains a recommended configuration and a configuration that matches the original ESLint configuration for the Storefront Reference Architecture (SFRA) with adjustments to validate with newer ESLint versions.

## Configurations

### Standard configuration

This configuration is recommended for every custom cartridge. It is based on ([@jenssimon/eslint-config-base](https://github.com/jenssimon/eslint-config-base#readme)).

```json
{
"extends": [
"@jenssimon/sfcc"
]
}
```

#### Standard confiuration (controllers)

This is a configuration suitable for the `controllers` folder of a cartridge. The main reason is to add the rule of [eslint-plugin-sitegenesis](https://www.npmjs.com/package/eslint-plugin-sitegenesis).

```json
{
"extends": [
"@jenssimon/sfcc/controllers"
]
}
```

### Configuration for SFRA

This configuration matches the original ESLint configuration for the Storefront Reference Architecture (SFRA) with adjustments to validate with newer ESLint versions.
It's only thought to be used with `app_storefront_base`.

```json
{
"extends": [
"@jenssimon/sfcc/sfra"
]
}
```

There is also a configuration for client side JS that extends the configuration mentioned above.

```json
{
"extends": [
"@jenssimon/sfcc/sfra-storefront"
]
}
```

## License

MIT © 2019 [Jens Simon](https://github.com/jenssimon)

[npm-url]: https://www.npmjs.com/package/@jenssimon/eslint-config-sfcc
[npm-image]: https://badgen.net/npm/v/@jenssimon/eslint-config-sfcc
[npm-downloads-image]: https://badgen.net/npm/dt/@jenssimon/eslint-config-sfcc

[deps-url]: https://david-dm.org/jenssimon/eslint-config-sfcc
[deps-image]: https://badgen.net/david/dep/jenssimon/eslint-config-sfcc

[deps-dev-url]: https://david-dm.org/jenssimon/eslint-config-sfcc?type=dev
[deps-dev-image]: https://badgen.net/david/dev/jenssimon/eslint-config-sfcc

[deps-peer-url]: https://david-dm.org/jenssimon/eslint-config-sfcc?type=peer
[deps-peer-image]: https://badgen.net/david/peer/jenssimon/eslint-config-sfcc

[gh-url]: https://github.com/jenssimon/eslint-config-sfcc
[gh-stars-image]: https://badgen.net/github/stars/jenssimon/eslint-config-sfcc
[gh-forks-image]: https://badgen.net/github/forks/jenssimon/eslint-config-sfcc

[codestyle-image]: https://badgen.net/badge/code%20style/airbnb/f2a
1 change: 1 addition & 0 deletions controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/controllers');
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib');
6 changes: 6 additions & 0 deletions lib/controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: ['sitegenesis'],
rules: {
'sitegenesis/no-global-require': ['error'],
},
};
55 changes: 55 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
module.exports = {
parser: 'babel-eslint',
extends: [
'airbnb-base',
'@jenssimon/base',
],
env: {
commonjs: true,
es6: true,
browser: false,
},
globals: {
dw: true,
customer: true,
session: true,
request: true,
response: true,
empty: true,
PIPELET_ERROR: true,
PIPELET_NEXT: true,
global: true,
webreferences: true,
webreferences2: true,
APIException: true,
ConversionError: true,
Fault: true,
IOError: true,
Iterator: true,
QName: true,
StopIteration: true,
SystemError: true,
XML: true,
XMLList: true,
XMLStreamError: true,
},
rules: {
'comma-dangle': ['error', 'always-multiline'],
'consistent-return': 'off',
'global-require': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-dynamic-require': 'off',
'new-cap': 'off',
'no-var': 'off',
'no-restricted-globals': 'off',
'object-shorthand': 'off',
'prefer-arrow-callback': 'off',
'prefer-const': 'off',
'prefer-destructuring': 'off',
'prefer-rest-params': 'off',
'prefer-spread': 'off',
'prefer-template': 'off',
strict: 'off',
},
};
23 changes: 23 additions & 0 deletions lib/sfra/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
extends: [
'airbnb-base/legacy',
],
rules: {
'import/no-unresolved': 'off',
indent: ['error', 4, { SwitchCase: 1, VariableDeclarator: 1 }],
'func-names': 'off',
'require-jsdoc': 'error',
'valid-jsdoc': ['error', {
preferType: {
Boolean: 'boolean', Number: 'number', object: 'Object', String: 'string',
},
requireReturn: false,
}],
'vars-on-top': 'off',
'global-require': 'off',
'no-shadow': ['error', { allow: ['err', 'callback'] }],

// fix configuration for newer ESLint versions
'linebreak-style': 'off',
},
};
5 changes: 5 additions & 0 deletions lib/sfra/storefront.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.export = {
rules: {
'no-restricted-globals': 'off',
},
};
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@jenssimon/eslint-config-sfcc",
"version": "1.0.0",
"description": "A collection of shareable ESLint configurations for Salesforce Commerce Cloud (SFCC)",
"main": "index.js",
"author": "Jens Simon <https://github.com/jenssimon>",
"keywords": [
"eslint",
"eslintconfig",
"sfcc",
"demandware",
"salesforce",
"commercecloud",
"sfra"
],
"repository": {
"type": "git",
"url": "https://github.com/jenssimon/eslint-config-sfcc"
},
"license": "MIT",
"scripts": {
"lint": "eslint --fix ./"
},
"peerDependencies": {
"@jenssimon/eslint-config-base": "^1.0.1",
"babel-eslint": ">=10.0.1",
"eslint": ">=5.13.0",
"eslint-config-airbnb-base": ">=13.1.0",
"eslint-plugin-sitegenesis": "^1.0.0"
},
"devDependencies": {
"@jenssimon/eslint-config-base": "^1.0.1",
"eslint": "^5.13.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-eslint-comments": "^3.0.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-promise": "^4.0.1"
},
"private": false
}
1 change: 1 addition & 0 deletions sfra-storefront.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/sfra/storefront');
1 change: 1 addition & 0 deletions sfra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.export = require('./lib/sfra');
Loading

0 comments on commit 171f03b

Please sign in to comment.