Skip to content

Commit

Permalink
Add prettier, lint-staged, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
paularmstrong committed Feb 8, 2018
1 parent b9d2df5 commit 8bfdd98
Show file tree
Hide file tree
Showing 15 changed files with 815 additions and 331 deletions.
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"arrowParens": "always",
"printWidth": 120,
"singleQuote": true
}
43 changes: 23 additions & 20 deletions examples/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@ import { normalize } from '../../src';
import path from 'path';

let data = '';
const request = https.request({
host: 'api.github.com',
path: '/repos/paularmstrong/normalizr/issues',
method: 'get',
headers: {
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
}
}, (res) => {
res.on('data', (d) => {
data += d;
});
const request = https.request(
{
host: 'api.github.com',
path: '/repos/paularmstrong/normalizr/issues',
method: 'get',
headers: {
'user-agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
}
},
(res) => {
res.on('data', (d) => {
data += d;
});

res.on('end', () => {
const normalizedData = normalize(JSON.parse(data), schema.issueOrPullRequest);
const out = JSON.stringify(normalizedData, null, 2);
fs.writeFileSync(path.resolve(__dirname, './output.json'), out);
});
res.on('end', () => {
const normalizedData = normalize(JSON.parse(data), schema.issueOrPullRequest);
const out = JSON.stringify(normalizedData, null, 2);
fs.writeFileSync(path.resolve(__dirname, './output.json'), out);
});

res.on('error', (e) => {
console.log(e);
});
});
res.on('error', (e) => {
console.log(e);
});
}
);

request.end();
15 changes: 9 additions & 6 deletions examples/github/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ export const milestone = new schema.Entity('milestones', {

export const issue = new schema.Entity('issues', {
assignee: user,
assignees: [ user ],
assignees: [user],
labels: label,
milestone,
user
});

export const pullRequest = new schema.Entity('pullRequests', {
assignee: user,
assignees: [ user ],
assignees: [user],
labels: label,
milestone,
user
});

export const issueOrPullRequest = new schema.Array({
issues: issue,
pullRequests: pullRequest
}, (entity) => entity.pull_request ? 'pullRequests' : 'issues');
export const issueOrPullRequest = new schema.Array(
{
issues: issue,
pullRequests: pullRequest
},
(entity) => (entity.pull_request ? 'pullRequests' : 'issues')
);
Loading

0 comments on commit 8bfdd98

Please sign in to comment.