Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1 from esender/eslint
Browse files Browse the repository at this point in the history
introduce eslint
  • Loading branch information
esender authored Oct 23, 2016
2 parents 147a70d + 787d17a commit 182f6b6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 44 deletions.
9 changes: 0 additions & 9 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ engines:
enabled: true
config:
languages:
- ruby
- javascript
- python
- php
eslint:
enabled: true
fixme:
enabled: true
ratings:
paths:
- "**.inc"
- "**.js"
- "**.jsx"
- "**.module"
- "**.php"
- "**.py"
- "**.rb"
exclude_paths:
- test/
8 changes: 3 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
parserOptions:
sourceType: module

ecmaFeatures:
modules: true
jsx: true

env:
amd: true
browser: true
es6: true
jquery: true
node: true

# http://eslint.org/docs/rules/
Expand Down Expand Up @@ -57,7 +56,6 @@ rules:
no-case-declarations: 2
no-div-regex: 2
no-else-return: 0
no-empty-label: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default bushido.createPaths([
addResource('content')
]),
addResource('pages')
])
]);
```

```javascript
Expand All @@ -34,6 +34,5 @@ paths.pages(4).path // => '/pages/4'

paths.books.pages.paragraphs.path // => '/books/pages/paragraphs'
paths.books(3).pages(5).paragraphs(7).path // => '/books/3/pages/5/paragraphs/7'
paths.books(6).pages.paragrahps.path // => '/books/6/pages/paragraphs'
paths.books(6).pages.paragraphs.path // => '/books/6/pages/paragraphs'
```

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "./src/index.js",
"scripts": {
"lint": "eslint --ext .js ./src ./test",
"test": "mocha -c --require babel-register ./test/**.js",
"test_watch": "mocha -w -c --require babel-register ./test/**.js"
},
Expand All @@ -14,6 +15,7 @@
"babel-preset-stage-0": "^6.16.0",
"babel-register": "^6.16.3",
"chai": "^3.5.0",
"eslint": "^3.8.1",
"mocha": "^3.1.2"
}
}
31 changes: 14 additions & 17 deletions src/add_resource.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
function addResource(resourceName, subResources) {
function carredResource (parentPath = '') {
let path = `${parentPath}/${resourceName}`;
function addResource(resourceName, subResources = []) {
function carriedResource(parentPath = '') {
const path = `${parentPath}/${resourceName}`;

function resource(id) {
let paths = {};
const paths = {};

paths.path = `${path}/${id}`;

if(subResources) {
subResources.forEach( resource => {
paths[resource.resourceName] = resource(paths.path);
});
}
subResources.forEach((subResource) => {
paths[subResource.resourceName] = subResource(paths.path);
});

return paths;
}

resource.path = path;

if (subResources) {
subResources.forEach( subResource => {
resource[subResource.resourceName] = subResource(path);
});
}
subResources.forEach((subResource) => {
resource[subResource.resourceName] = subResource(path);
});

return resource;
}

carredResource.resourceName = resourceName;
return carredResource;
carriedResource.resourceName = resourceName;

return carriedResource;
}

export default addResource;
export default addResource;
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import addResource from './add_resource';

class Bushido {
constructor() {}

createPaths(resources) {
let paths = {};
resources.forEach( resource => {
const paths = {};

resources.forEach((resource) => {
paths[resource.resourceName] = resource();
});

Expand Down
7 changes: 4 additions & 3 deletions test/add_resource_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import addResource from '../src/add_resource';
import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import addResource from '../src/add_resource';

describe('addResource', function(){
describe('addResource', () => {
describe('without subResources', () => {
let carredResource;

Expand All @@ -19,7 +20,7 @@ describe('addResource', function(){

describe('set parent resource', () => {
let resource;

beforeEach(() => {
resource = carredResource();
});
Expand Down
7 changes: 4 additions & 3 deletions test/index_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Bushido, { addResource } from '../src/index';
import { expect } from 'chai';
import { beforeEach, describe, it } from 'mocha';
import Bushido, { addResource } from '../src/index';

describe('Bushido', function(){
describe('Bushido', () => {
let helper;

beforeEach(() => {
let bushido = new Bushido();
const bushido = new Bushido();
helper = bushido.createPaths([
addResource('books', [
addResource('pages', [
Expand Down

0 comments on commit 182f6b6

Please sign in to comment.