Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update "space-before-function-paren" linting rule and its description. Closes #3 #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"mocha": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"sourceType": "module"
"ecmaVersion": 2018
},
"plugins": [
"json"
Expand All @@ -21,8 +25,12 @@
"quotes": ["error","single"],
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": "error",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always" }
],
"no-undef": "off",
"no-unused-vars": "off"
}
}
}
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,46 @@ function hello () {
console.log('hello');
}
```
- Put a space between a function name and its arguments when you declare it (not when you call it).
- Put a space before the parentheses when you write anonymous functions.
```js
// Bad
function log(str) {
const callback = function(str) {
console.log(str);
}

// Good
function log (str) {
const callback = function (str) {
console.log(str);
}
```
- Don't put a space before the parentheses when you write named functions or call the function.
```js
// Bad
function callback (str) => {
console.log(str);
}

callback ('hello, world!');

// Good
function callback(str) => {
console.log(str);
}

callback('hello, world!');
```
- Put a space after `async` keyword for asynchronous functions.
```js
// Bad
const callback = async(str) => {
await Promise.resolve(str);
}

// Good
const callback = async (str) => {
await Promise.resolve(str);
}
```
- Put a space before blocks, and around keywords.
```js
// Bad
Expand Down
5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

const gulp = require('gulp');
const $ = require('gulp-load-plugins')();

// Utility to ignore Node modules and Bower components
// when generating the glob patterns array for gulp.src()
function addDefSrcIgnore (srcArr) {
function addDefSrcIgnore(srcArr) {
return srcArr.concat([
'!node_modules{,/**}',
'!private{,/**}',
Expand All @@ -15,7 +14,7 @@ function addDefSrcIgnore (srcArr) {
}

// JavaScript and JSON linter
function lintJs () {
function lintJs() {
return gulp.src(addDefSrcIgnore(['**/*.js', '**/*.json']), {dot: true})
.pipe($.eslint({dotfiles: true}))
.pipe($.eslint.format())
Expand Down
27 changes: 21 additions & 6 deletions linters/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@
"mocha": true
},
"extends": "eslint:recommended",
"parserOptions": {"sourceType": "module"},
"plugins": ["json"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"plugins": [
"json"
],
"rules": {
"indent": ["error", 2],
"indent": ["error",2],
"keyword-spacing": "error",
"linebreak-style": "error",
"quotes": ["error","single"],
"no-extra-boolean-cast": "off",
"quotes": ["error", "single"],
"semi": "error",
"space-before-blocks": "error",
"space-before-function-paren": "error"
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always" }
],
"no-undef": "off",
"no-unused-vars": "off"
}
}
}
Loading