Skip to content

Commit

Permalink
chore: upgrade deps, add tests, update codeclimate config (#41)
Browse files Browse the repository at this point in the history
* chore: upgrade deps, add tests, update codeclimate config

* fix: github workflow update, npm packaging
  • Loading branch information
Patrik Kullman authored Apr 16, 2020
1 parent 9865492 commit 08445b0
Show file tree
Hide file tree
Showing 8 changed files with 6,548 additions and 2,881 deletions.
32 changes: 9 additions & 23 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,23 @@
version: "2"
checks:
argument-count:
enabled: true
config:
threshold: 4
enabled: false # handled by eslint rule "max-params"
complex-logic:
enabled: true
config:
threshold: 4
file-lines:
enabled: true
config:
threshold: 250
enabled: false # handled by eslint rule "max-lines"
method-complexity:
enabled: true
config:
threshold: 5
enabled: false # handled by eslint rule "complexity"
method-count:
enabled: true
config:
threshold: 20
method-lines:
enabled: true
config:
threshold: 30
enabled: false # handled by eslint rule "max-lines-per-function"
nested-control-flow:
enabled: true
config:
threshold: 4
enabled: false # handled by eslint rule "max-depth"
return-statements:
enabled: true
config:
Expand All @@ -39,13 +29,9 @@ checks:
enabled: true

plugins:
eslint:
enabled: true
channel: "eslint-5"
config:
sanitize_batch: false
extensions:
- .js
- .html
fixme:
enabled: true

exclude_patterns:
- "**/node_modules/"
- "coverage/"
30 changes: 30 additions & 0 deletions .github/karma-problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"problemMatcher": [{
"owner": "karma-eval",
"pattern": [{
"regexp": "^\\w+\\s\\d+\\.\\d+\\.\\d+\\s\\(\\w+\\s\\d+\\.\\d+\\.\\d+\\)\\sERROR$"
}, {
"regexp": "^\\s{2}(.*)$",
"message": 1
}, {
"regexp": "^\\s{2}at\\s([^:]*):(\\d+):(\\d+)$",
"file": 1,
"line": 2,
"column": 3
}]
}, {
"owner": "karma-test-error",
"pattern": [{
"regexp": "^\\w+\\s\\d+\\.\\d+\\.\\d+\\s\\(\\w+\\s\\d+\\.\\d+\\.\\d+\\)\\s(.*)FAILED$",
"code": 1
}, {
"regexp": "^\\t(.*)$",
"message": 1
}, {
"regexp": "^\\t {4}at\\s[^\\s]*\\s\\(([^:]*):(\\d+):(\\d+)\\)$",
"file": 1,
"line": 2,
"column": 3
}]
}]
}
11 changes: 5 additions & 6 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v1

- name: Use Node.js 10.x
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 10.x
node-version: 12.x

- name: Install
run: npm ci
Expand All @@ -26,9 +26,7 @@ jobs:
run: npx commitlint --from origin/master --to HEAD

- name: ESLint
run: npx github-actions-eslint-annotator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run lint

- name: Test and report
env:
Expand All @@ -42,7 +40,8 @@ jobs:
run: |
([[ -e $NEO_CC ]] || curl -L $NEO_CC_URL > $NEO_CC) && chmod +x $NEO_CC
$NEO_CC before-build
npm run test $([ -z "$SAUCE_ACCESS_KEY"] && echo "-- --skip-plugin sauce")
echo "::add-matcher::.github/karma-problem-matcher.json"
npm test
$NEO_CC after-build --exit-code $?
- name: Semantic release
Expand Down
19 changes: 9 additions & 10 deletions cosmoz-default-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,15 @@ export class DefaultTree extends Tree {
* @param {Object} nodeObj [this._treeData] (The object the search should be based on.)
* @param {String} pathLocatorSeparator [this.pathLocatorSeparator] (The string which separates the path.)
*/
getPathNodes(pathLocator, nodeObj, pathLocatorSeparator) {
const tree = nodeObj || this._treeData;

getPathNodes(pathLocator, nodeObj = this._treeData, pathLocatorSeparator = this.pathLocatorSeparator) {
if (!pathLocator) {
return tree;
return nodeObj;
}

return Object.keys(tree)
return Object.keys(nodeObj)
.map(key => {
const subTree = {};
subTree[key] = tree[key];
subTree[key] = nodeObj[key];
return this._getPathNodes(pathLocator, subTree, pathLocatorSeparator);
})
.filter(item => {
Expand All @@ -161,9 +159,9 @@ export class DefaultTree extends Tree {
.sort(this.constructor._sortPathNodes)[0];
}

_getPathNodes(pathLocator, nodeObj, pathLocatorSeparator = this.pathLocatorSeparator) {
_getPathNodes(pathLocator, nodeObj = this._treeData, pathLocatorSeparator = this.pathLocatorSeparator) {
const path = pathLocator.split(pathLocatorSeparator),
nodes = this._pathToNodes(path, nodeObj || this._treeData);
nodes = this._pathToNodes(path, nodeObj);

// Filter out undefined items of the start
while (nodes.length > 0 && nodes[0] === undefined) {
Expand Down Expand Up @@ -204,7 +202,7 @@ export class DefaultTree extends Tree {
) {
const pathNodes = this.getPathNodes(pathLocator, this._treeData, pathLocatorSeparator);

if (!pathNodes) {
if (!Array.isArray(pathNodes)) {
return;
}

Expand Down Expand Up @@ -241,7 +239,8 @@ export class DefaultTree extends Tree {
const node = this.getNodeByProperty(propertyValue, propertyName);

if (node) {
return this.getPathString(node.pathLocator || node.path, pathProperty, pathStringSeparator);
const path = node.pathLocator || node.path;
return this.getPathString(path, pathProperty, pathStringSeparator);
}
}

Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = config => {
//
// npm run test -- --grep test/foo/bar.test.js
// npm run test -- --grep test/bar/*
pattern: config.grep ? config.grep : 'test/**/*.test.js',
pattern: config.grep ? config.grep : 'test/*.test.js',
type: 'module'
}],

Expand Down
Loading

0 comments on commit 08445b0

Please sign in to comment.