-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: eslint * feat: custom deepmerge * chore: ci * chore: add case * chore: add badge * fix: travis url * 0.1.9 * chore: eslint ignore coverage
- Loading branch information
Showing
11 changed files
with
118 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
const { eslintTS } = require('./lib/eslintTS'); | ||
const { eslint, deepmerge } = require('./lib'); | ||
|
||
module.exports = eslintTS; | ||
const eslintConfig = deepmerge(eslint, { | ||
env: { | ||
jest: true | ||
} | ||
}); | ||
|
||
module.exports = eslintConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sudo: required | ||
language: node_js | ||
node_js: | ||
- '10' | ||
script: | ||
- npm run lint | ||
- npm run test | ||
after_success: | ||
- npm run coverage | ||
cache: | ||
directories: | ||
- node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = function(target, source) { | ||
// deep clone | ||
const newObj = JSON.parse(JSON.stringify(target)); | ||
|
||
Object.keys(source).forEach((key) => { | ||
const type = Object.prototype.toString.call(source[key]); | ||
|
||
if (type === '[object Array]') { | ||
newObj[key] = [...target[key], ...source[key]]; | ||
} else if (type === '[object Object]') { | ||
newObj[key] = {...target[key], ...source[key]}; | ||
} else { | ||
newObj[key] = source[key]; | ||
} | ||
}); | ||
|
||
return newObj; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ module.exports = { | |
], | ||
rules: { | ||
"no-empty-source": null, | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { deepmerge, eslint } = require('../lib'); | ||
|
||
it('set one rule should be replaced', () => { | ||
const result = deepmerge(eslint, { | ||
rules: { | ||
"comma-dangle": [1, "never"], | ||
}, | ||
}); | ||
|
||
expect(result.rules['comma-dangle']).toEqual([1, "never"]); | ||
}); | ||
|
||
it('root should be replaced', () => { | ||
const result = deepmerge(eslint, { | ||
root: false, | ||
}); | ||
|
||
expect(result.root).toEqual(false); | ||
}); | ||
|
||
it('parserOptions should be merged', () => { | ||
const result = deepmerge(eslint, { | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
ecmaFeatures: { | ||
js: true, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(result.parserOptions.ecmaVersion).toEqual(2017); | ||
expect(result.parserOptions.ecmaFeatures).toEqual({ | ||
js: true, | ||
}); | ||
expect(result.parserOptions.ecmaFeatures.jsx).toEqual(undefined); | ||
}); | ||
|
||
it('plugins should be merged', () => { | ||
const result = deepmerge(eslint, { | ||
plugins: ['react-xxx'], | ||
}); | ||
expect(result.plugins[0]).toEqual('react-hooks'); | ||
expect(result.plugins[1]).toEqual('react-xxx'); | ||
}); |