Skip to content

Commit 449382a

Browse files
committed
feat: give a facelift
1 parent d160abd commit 449382a

35 files changed

+112
-76
lines changed

.README/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Table
22

3-
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat)](https://travis-ci.org/gajus/table)
4-
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat)](https://www.npmjs.com/package/table)
5-
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-brightgreen.svg?style=flat)](https://github.com/gajus/canonical)
3+
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table)
4+
[![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table)
5+
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table)
6+
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
7+
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)
68

79
{"gitdown": "contents"}
810

.babelrc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
{
2-
"presets": [
3-
["env", {"targets": {"node": "4"}}]
4-
],
52
"env": {
6-
"development": {
3+
"test": {
74
"plugins": [
85
"istanbul"
96
]
107
}
11-
}
8+
},
9+
"plugins": [
10+
"transform-export-default-name"
11+
],
12+
"presets": [
13+
[
14+
"@babel/env",
15+
{
16+
"targets": {
17+
"node": 6
18+
}
19+
}
20+
]
21+
]
1222
}

.travis.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
language: node_js
2-
before_install:
3-
- npm config set depth 0
4-
- npm install --global npm@3
5-
script:
6-
- npm run lint
7-
- npm run test
82
node_js:
9-
- 10
3+
- node
104
- 8
5+
- 6
6+
script:
7+
- export NODE_ENV=test
8+
- npm run build
9+
- npm run test
10+
- npm run lint
11+
- nyc --silent npm run test
12+
- nyc report --reporter=text-lcov | coveralls
13+
- nyc check-coverage --lines 70
14+
after_success:
15+
- export NODE_ENV=production
16+
- npm run build
17+
- semantic-release
1118
notifications:
1219
email: false
1320
sudo: false

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/)
1+
Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<a name="table"></a>
22
# Table
33

4-
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat)](https://travis-ci.org/gajus/table)
5-
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat)](https://www.npmjs.com/package/table)
6-
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-brightgreen.svg?style=flat)](https://github.com/gajus/canonical)
4+
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table)
5+
[![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table)
6+
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table)
7+
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
8+
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)
79

810
* [Table](#table)
911
* [Features](#table-features)

package.json

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,41 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"ajv": "^6.2.0",
9-
"lodash": "^4.17.4",
8+
"ajv": "^6.5.3",
9+
"lodash": "^4.17.10",
1010
"slice-ansi": "1.0.0",
1111
"string-width": "^2.1.1"
1212
},
1313
"description": "Formats data into a string table.",
1414
"devDependencies": {
15+
"@babel/cli": "^7.0.0",
16+
"@babel/core": "^7.0.0",
17+
"@babel/node": "^7.0.0",
18+
"@babel/preset-env": "^7.0.0",
19+
"@babel/register": "^7.0.0",
1520
"ajv-cli": "^3.0.0",
16-
"ajv-keywords": "^3.1.0",
17-
"babel": "^6.23.0",
18-
"babel-cli": "^6.26.0",
19-
"babel-core": "^6.26.3",
20-
"babel-plugin-istanbul": "^4.1.5",
21-
"babel-preset-env": "^1.7.0",
22-
"babel-register": "^6.26.0",
21+
"ajv-keywords": "^3.2.0",
22+
"babel-plugin-istanbul": "^5.0.1",
23+
"babel-plugin-transform-export-default-name": "^2.0.4",
2324
"chai": "^4.1.2",
24-
"chalk": "^2.3.1",
25-
"eslint": "^4.7.2",
26-
"eslint-config-canonical": "^9.3.1",
27-
"gitdown": "^2.5.1",
28-
"husky": "^0.14.3",
29-
"mocha": "^5.0.0",
30-
"nyc": "^11.2.1",
31-
"sinon": "^4.0.0"
25+
"chalk": "^2.4.1",
26+
"coveralls": "^3.0.2",
27+
"eslint": "^5.5.0",
28+
"eslint-config-canonical": "^12.0.0",
29+
"gitdown": "^2.5.3",
30+
"husky": "^1.0.0-rc.13",
31+
"mocha": "^5.2.0",
32+
"nyc": "^13.0.1",
33+
"semantic-release": "^15.9.12",
34+
"sinon": "^6.1.5"
3235
},
3336
"engines": {
34-
"node": ">=4.0.0"
37+
"node": ">=8.0.0"
38+
},
39+
"husky": {
40+
"hooks": {
41+
"pre-commit": "npm run lint && npm run test && npm run build && npm run create-readme && git add README.md && git commit --amend --no-edit --no-verify"
42+
}
3543
},
3644
"keywords": [
3745
"ascii",
@@ -45,12 +53,14 @@
4553
"name": "table",
4654
"nyc": {
4755
"include": [
48-
"src/*.js"
56+
"src/**/*.js"
4957
],
5058
"instrument": false,
51-
"lines": 70,
59+
"reporter": [
60+
"text-lcov"
61+
],
5262
"require": [
53-
"babel-register"
63+
"@babel/register"
5464
],
5565
"sourceMap": false
5666
},
@@ -59,13 +69,11 @@
5969
"url": "https://github.com/gajus/table"
6070
},
6171
"scripts": {
62-
"build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run make-validators",
63-
"lint": "npm run build && eslint ./src ./tests",
64-
"make-readme": "gitdown ./.README/README.md --output-file ./README.md",
65-
"make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js",
66-
"precommit": "npm run lint && npm run test",
67-
"prepublish": "NODE_ENV=production npm run build",
68-
"test": "npm run build && nyc --check-coverage mocha"
72+
"build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run create-validators",
73+
"create-readme": "gitdown ./.README/README.md --output-file ./README.md",
74+
"create-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js",
75+
"lint": "npm run build && eslint ./src ./test",
76+
"test": "nyc --check-coverage mocha"
6977
},
70-
"version": "4.0.3"
78+
"version": "1.0.0"
7179
}

src/calculateMaximumColumnWidthIndex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default (rows) => {
1111
throw new Error('Dataset must have at least one row.');
1212
}
1313

14-
const columns = Array(rows[0].length).fill(0);
14+
const columns = new Array(rows[0].length).fill(0);
1515

1616
rows.forEach((row) => {
1717
const columnWidthIndex = calculateCellWidthIndex(row);

src/calculateRowHeightIndex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default (rows, config) => {
1414
const rowSpanIndex = [];
1515

1616
rows.forEach((cells) => {
17-
const cellHeightIndex = Array(tableWidth).fill(1);
17+
const cellHeightIndex = new Array(tableWidth).fill(1);
1818

1919
cells.forEach((value, index1) => {
2020
if (!_.isNumber(config.columns[index1].width)) {

src/mapDataUsingRowHeightIndex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default (unmappedRows, rowHeightIndex, config) => {
1313

1414
const mappedRows = unmappedRows.map((cells, index0) => {
1515
const rowHeight = _.times(rowHeightIndex[index0], () => {
16-
return Array(tableWidth).fill('');
16+
return new Array(tableWidth).fill('');
1717
});
1818

1919
// rowHeight

test/.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
},
5+
"rules": {
6+
"filenames/match-regex": 0
7+
}
8+
}

0 commit comments

Comments
 (0)