Skip to content

Commit fc7f344

Browse files
authored
Merge pull request webpack#6766 from montogeek/misc/add-schemas-eslint-prettier
misc: Add schemas to ESLint and Prettier commands
2 parents 166a6b9 + 57ea856 commit fc7f344

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@
102102
"build:examples": "cd examples && node buildAll.js",
103103
"pretest": "npm run lint-files",
104104
"lint-files": "npm run lint && npm run schema-lint",
105-
"lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
105+
"lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
106106
"fix": "npm run lint -- --fix",
107-
"pretty-files": "prettier \"lib/**.*\" \"bin/**.*\" \"hot/**.*\" \"buildin/**.*\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" --write",
107+
"pretty-files": "prettier \"lib/**.*\" \"bin/**.*\" \"hot/**.*\" \"buildin/**.*\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\" --write",
108108
"schema-lint": "mocha test/*.lint.js --opts test/lint-mocha.opts",
109109
"benchmark": "mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.benchmark.js -R spec",
110110
"cover": "npm run cover:init && npm run cover:all && npm run cover:report",

schemas/ajv.absolutePath.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
"use strict";
22

33
const getErrorFor = (shouldBeAbsolute, data, schema) => {
4-
const message = shouldBeAbsolute ?
5-
`The provided value ${JSON.stringify(data)} is not an absolute path!`
6-
: `A relative path is expected. However the provided value ${JSON.stringify(data)} is an absolute path!`;
4+
const message = shouldBeAbsolute
5+
? `The provided value ${JSON.stringify(data)} is not an absolute path!`
6+
: `A relative path is expected. However the provided value ${JSON.stringify(
7+
data
8+
)} is an absolute path!`;
79

810
return {
911
keyword: "absolutePath",
1012
params: { absolutePath: data },
1113
message: message,
12-
parentSchema: schema,
14+
parentSchema: schema
1315
};
1416
};
15-
module.exports = (ajv) => ajv.addKeyword("absolutePath", {
16-
errors: true,
17-
type: "string",
18-
compile(expected, schema) {
19-
function callback(data) {
20-
const passes = expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
21-
if(!passes) {
22-
callback.errors = [getErrorFor(expected, data, schema)];
17+
module.exports = ajv =>
18+
ajv.addKeyword("absolutePath", {
19+
errors: true,
20+
type: "string",
21+
compile(expected, schema) {
22+
function callback(data) {
23+
const passes = expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
24+
if (!passes) {
25+
callback.errors = [getErrorFor(expected, data, schema)];
26+
}
27+
return passes;
2328
}
24-
return passes;
29+
callback.errors = [];
30+
return callback;
2531
}
26-
callback.errors = [];
27-
return callback;
28-
}
29-
});
32+
});

0 commit comments

Comments
 (0)