Skip to content

Commit 15f5e35

Browse files
authored
Merge pull request #99 from G-Rath/add-prettier-to-eslint
Add prettier to eslint
2 parents d62fc1f + 855b5df commit 15f5e35

File tree

9 files changed

+46
-37
lines changed

9 files changed

+46
-37
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const jsConfig = require("@ajv-validator/config/.eslintrc_js")
22
const tsConfig = require("@ajv-validator/config/.eslintrc")
33

44
module.exports = {
5+
extends: ["plugin:prettier/recommended"],
56
env: {
67
es6: true,
78
node: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
"cross-env": "^7.0.3",
5858
"eslint": "^7.1.0",
5959
"eslint-config-prettier": "^6.15.0",
60+
"eslint-plugin-prettier": "^3.3.1",
6061
"husky": "^4.3.0",
6162
"lint-staged": "^10.5.2",
6263
"mocha": "^8.1.3",
6364
"nyc": "^15.0.1",
64-
"pre-commit": "^1.2.0",
6565
"prettier": "^2.2.1",
6666
"rimraf": "^3.0.2",
6767
"ts-node": "^9.1.0",

src/commands/ajv.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export default function (argv: ParsedArgs): AjvCore {
3131
if (invalid) process.exit(1)
3232
return ajv
3333

34-
function addSchemas(args: string | string[] | undefined, method: AjvMethod, fileType: string): void {
34+
function addSchemas(
35+
args: string | string[] | undefined,
36+
method: AjvMethod,
37+
fileType: string
38+
): void {
3539
if (!args) return
3640
const files = util.getFiles(args)
3741
files.forEach((file) => {

src/commands/compile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function execute(argv: ParsedArgs): boolean {
5050
const sch = openFile(file, `schema ${file}`)
5151
try {
5252
const id = sch?.$id
53-
ajv.addSchema(sch, id ? undefined : file )
53+
ajv.addSchema(sch, id ? undefined : file)
5454
const validate = ajv.getSchema(id || file)
5555
if (argv.o !== true) console.log(`schema ${file} is valid`)
5656
return validate
@@ -61,7 +61,7 @@ function execute(argv: ParsedArgs): boolean {
6161
}
6262
}
6363

64-
function getRefs(validators: AnyValidateFunction[], files: string[]): {[K in string]?: string} {
64+
function getRefs(validators: AnyValidateFunction[], files: string[]): {[K in string]?: string} {
6565
const refs: {[K in string]?: string} = {}
6666
validators.forEach((v, i) => {
6767
const ref = typeof v.schema == "object" ? v.schema.$id || files[i] : files[i]

src/commands/test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function execute(argv: ParsedArgs): boolean {
3333
const ajv = getAjv(argv)
3434
const validate = compile(ajv, argv.s)
3535
const shouldBeValid = !!argv.valid && argv.valid !== "false"
36-
return getFiles(argv.d).map(testDataFile).every((x) => x)
36+
return getFiles(argv.d)
37+
.map(testDataFile)
38+
.every((x) => x)
3739

3840
function testDataFile(file: string): boolean {
3941
const data = openFile(file, `data file ${file}`)

src/commands/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path = require("path")
44
import fs = require("fs")
55
import yaml = require("js-yaml")
66
import JSON5 = require("json5")
7-
import { AnyValidateFunction } from "ajv/dist/core"
7+
import {AnyValidateFunction} from "ajv/dist/core"
88

99
export function getFiles(args: string | string[]): string[] {
1010
let files: string[] = []

src/commands/validate.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default cmd
3131
function execute(argv: ParsedArgs): boolean {
3232
const ajv = getAjv(argv)
3333
const validate = compile(ajv, argv.s)
34-
return getFiles(argv.d).map(validateDataFile).every((x) => x)
34+
return getFiles(argv.d)
35+
.map(validateDataFile)
36+
.every((x) => x)
3537

3638
function validateDataFile(file: string): boolean {
3739
const data = openFile(file, `data file ${file}`)

test/migrate/schema_invalid.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type": "invalid",
33
"$schema": "http://json-schema.org/draft-07/schema"
4-
}
4+
}

test/valid_data.json5

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
[
2-
// todo: we're missing item 1
3-
{
4-
id: 2,
5-
name: 'An ice sculpture',
6-
price: 12.50,
7-
tags: ['cold', 'ice'],
8-
dimensions: {
9-
length: 7.0,
10-
width: 12.0,
11-
height: 9.5
12-
},
13-
warehouseLocation: {
14-
latitude: -78.75,
15-
longitude: 20.4
16-
}
2+
// todo: we're missing item 1
3+
{
4+
id: 2,
5+
name: "An ice sculpture",
6+
price: 12.5,
7+
tags: ["cold", "ice"],
8+
dimensions: {
9+
length: 7.0,
10+
width: 12.0,
11+
height: 9.5,
1712
},
18-
{
19-
id: 3,
20-
name: 'A blue mouse',
21-
price: 25.50,
22-
dimensions: {
23-
length: 3.1,
24-
width: 1.0,
25-
height: 1.0
26-
},
27-
warehouseLocation: {
28-
latitude: 54.4,
29-
longitude: -32.7
30-
}
31-
}
13+
warehouseLocation: {
14+
latitude: -78.75,
15+
longitude: 20.4,
16+
},
17+
},
18+
{
19+
id: 3,
20+
name: "A blue mouse",
21+
price: 25.5,
22+
dimensions: {
23+
length: 3.1,
24+
width: 1.0,
25+
height: 1.0,
26+
},
27+
warehouseLocation: {
28+
latitude: 54.4,
29+
longitude: -32.7,
30+
},
31+
},
3232
]

0 commit comments

Comments
 (0)