Skip to content

Commit 5500ae9

Browse files
authored
Merge pull request #56 from leapfrogtechnology/prettier
Setup prettier and integrate format checking in the CI
2 parents c522c8a + 795aea1 commit 5500ae9

File tree

12 files changed

+46
-40
lines changed

12 files changed

+46
-40
lines changed

.nycrc.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
{
22
"extends": "@istanbuljs/nyc-config-typescript",
3-
"include": [
4-
"src"
5-
],
6-
"require": [
7-
"ts-node/register"
8-
],
3+
"include": ["src"],
4+
"require": ["ts-node/register"],
95
"cache": false,
106
"sourceMap": true,
117
"all": true,
128
"instrument": true,
13-
"reporter": [
14-
"lcov",
15-
"text",
16-
"text-summary"
17-
]
9+
"reporter": ["lcov", "text", "text-summary"]
1810
}

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lib/
2+
node_modules
3+
coverage
4+
.nyc_output
5+
.vscode
6+
.github
7+
CHANGELOG.md

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ node_js:
66
- 8
77

88
before_script:
9+
- yarn format:check
10+
- yarn lint
911
- yarn build
1012

1113
script:

examples/node-app-pg/src/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ const { connections } = require('../connections.sync-db.json');
1313

1414
const tables = await db.raw('SELECT * FROM utils.vw_table_names');
1515
const users = await db.raw('SELECT * FROM utils.vw_user_names');
16-
const [{ result: product }] = await db.raw(
17-
'SELECT utils.product(6, 7) AS result;'
18-
);
16+
const [{ result: product }] = await db.raw('SELECT utils.product(6, 7) AS result;');
1917
const [{ result: sum }] = await db.raw('SELECT dbo.sum(6, 7) AS result;');
20-
const [{ result: square }] = await db.raw(
21-
'SELECT dbo.square(6) AS result;'
22-
);
18+
const [{ result: square }] = await db.raw('SELECT dbo.square(6) AS result;');
2319
const [{ result: date }] = await db.raw('EXEC utils.get_date;');
2420

2521
console.log(

examples/node-mssql-programmatic-use/src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const { connections } = require('../connections.sync-db.json');
77

88
(async () => {
99
try {
10-
1110
// Getting knex instance of mssql database with id db1.
1211
const db = knex({
1312
client: 'mssql',
@@ -21,8 +20,14 @@ const { connections } = require('../connections.sync-db.json');
2120
const [{ result: square }] = await db.raw('SELECT dbo.square(6) AS result;');
2221
const [{ result: date }] = await db.raw('EXEC utils.get_date;');
2322

24-
console.log('\nList of table names in the database:\n', tables.map(({ name }) => name));
25-
console.log('\nList of user names in the database:\n', users.map(({ name }) => name));
23+
console.log(
24+
'\nList of table names in the database:\n',
25+
tables.map(({ name }) => name)
26+
);
27+
console.log(
28+
'\nList of user names in the database:\n',
29+
users.map(({ name }) => name)
30+
);
2631
console.log('\nCalculations:\n', {
2732
'Sum of 6 and 7': sum,
2833
'Product of 6 and 7': product,

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
"test:coverage": "nyc mocha --forbid-only \"test/**/*.test.ts\"",
4444
"watch": "tsc --watch",
4545
"changelog": "./release.sh changelog",
46-
"release": "./release.sh bump"
46+
"release": "./release.sh bump",
47+
"format": "prettier --write . '**/*.{ts,js,md,yaml,json}'",
48+
"format:check": "prettier --check . '**/*.{ts,js,md,yaml,json}'"
4749
},
4850
"dependencies": {
4951
"@istanbuljs/nyc-config-typescript": "^0.1.3",
@@ -71,6 +73,7 @@
7173
"codecov": "^3.5.0",
7274
"mocha": "^5",
7375
"nyc": "^14.1.1",
76+
"prettier": "1.19.1",
7477
"ts-node": "^8",
7578
"tslint": "^6.0.0",
7679
"tslint-config-leapfrog": "^1.0.3",

src/domain/ConnectionConfig.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ import * as Knex from 'knex';
33
/**
44
* Database connection configuration.
55
*/
6-
type KnexConnections = Knex.ConnectionConfig
7-
& Knex.MariaSqlConnectionConfig
8-
& Knex.MySqlConnectionConfig
9-
& Knex.MsSqlConnectionConfig
10-
& Knex.SocketConnectionConfig
11-
& Knex.Sqlite3ConnectionConfig;
6+
type KnexConnections = Knex.ConnectionConfig &
7+
Knex.MariaSqlConnectionConfig &
8+
Knex.MySqlConnectionConfig &
9+
Knex.MsSqlConnectionConfig &
10+
Knex.SocketConnectionConfig &
11+
Knex.Sqlite3ConnectionConfig;
1212

13-
type ConnectionConfig = KnexConnections
14-
& {
15-
id?: string;
16-
client: string;
17-
};
13+
type ConnectionConfig = KnexConnections & {
14+
id?: string;
15+
client: string;
16+
};
1817

1918
export default ConnectionConfig;

src/domain/RawBingingParams.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ type RawBindingParams = (
1313
| string[]
1414
| number[]
1515
| boolean[]
16-
| Knex.QueryBuilder)[];
16+
| Knex.QueryBuilder
17+
)[];
1718

1819
export interface ValueMap {
1920
[key: string]: Value | Knex.QueryBuilder;

test/env.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('UTIL: env', () => {
2323
expect(result).to.equal('Foo bar');
2424
});
2525

26-
it('should substitute an empty string in-place of the variable if the variable isn\'t defined.', () => {
26+
it('should substitute an empty string in-place of the variable if the variable is not defined.', () => {
2727
expect(expandEnvVars('${TEST_UNDEFINED_VARIABLE}')).to.equal('');
2828
expect(expandEnvVars('Substituted value = "${TEST_UNDEFINED_VARIABLE}"')).to.equal('Substituted value = ""');
2929
});

test/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
"compilerOptions": {
44
"noEmit": true
55
},
6-
"references": [
7-
{"path": ".."}
8-
]
6+
"references": [{ "path": ".." }]
97
}

0 commit comments

Comments
 (0)