@parcel/validator-eslint 2.0.0-nightly.97 → 2.0.0-nightly.970
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/EslintValidator.js +56 -16
- package/package.json +17 -7
- package/src/EslintValidator.js +24 -16
- package/.babelrc +0 -4
package/lib/EslintValidator.js
CHANGED
|
@@ -5,22 +5,60 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function _plugin() {
|
|
9
|
+
const data = require("@parcel/plugin");
|
|
10
|
+
|
|
11
|
+
_plugin = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _diagnostic() {
|
|
19
|
+
const data = require("@parcel/diagnostic");
|
|
20
|
+
|
|
21
|
+
_diagnostic = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _eslint() {
|
|
29
|
+
const data = _interopRequireDefault(require("eslint"));
|
|
30
|
+
|
|
31
|
+
_eslint = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _assert() {
|
|
39
|
+
const data = _interopRequireDefault(require("assert"));
|
|
40
|
+
|
|
41
|
+
_assert = function () {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
49
|
|
|
10
50
|
let cliEngine = null;
|
|
11
51
|
|
|
12
|
-
var _default = new _plugin.Validator({
|
|
52
|
+
var _default = new (_plugin().Validator)({
|
|
13
53
|
async validate({
|
|
14
|
-
asset
|
|
15
|
-
options
|
|
54
|
+
asset
|
|
16
55
|
}) {
|
|
17
|
-
let eslint = await options.packageManager.require('eslint', asset.filePath);
|
|
18
|
-
|
|
19
56
|
if (!cliEngine) {
|
|
20
|
-
cliEngine = new
|
|
57
|
+
cliEngine = new (_eslint().default.CLIEngine)({});
|
|
21
58
|
}
|
|
22
59
|
|
|
23
60
|
let code = await asset.getCode();
|
|
61
|
+
(0, _assert().default)(cliEngine != null);
|
|
24
62
|
let report = cliEngine.executeOnText(code, asset.filePath);
|
|
25
63
|
let validatorResult = {
|
|
26
64
|
warnings: [],
|
|
@@ -31,26 +69,28 @@ var _default = new _plugin.Validator({
|
|
|
31
69
|
for (let result of report.results) {
|
|
32
70
|
if (!result.errorCount && !result.warningCount) continue;
|
|
33
71
|
let codeframe = {
|
|
72
|
+
filePath: asset.filePath,
|
|
34
73
|
code: result.source,
|
|
35
74
|
codeHighlights: result.messages.map(message => {
|
|
75
|
+
let start = {
|
|
76
|
+
line: message.line,
|
|
77
|
+
column: message.column
|
|
78
|
+
};
|
|
36
79
|
return {
|
|
37
|
-
start
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
end: {
|
|
80
|
+
start,
|
|
81
|
+
// Parse errors have no ending
|
|
82
|
+
end: message.endLine != null ? {
|
|
42
83
|
line: message.endLine,
|
|
43
84
|
column: message.endColumn
|
|
44
|
-
},
|
|
45
|
-
message: message.message
|
|
85
|
+
} : start,
|
|
86
|
+
message: (0, _diagnostic().escapeMarkdown)(message.message)
|
|
46
87
|
};
|
|
47
88
|
})
|
|
48
89
|
};
|
|
49
90
|
let diagnostic = {
|
|
50
91
|
origin: '@parcel/validator-eslint',
|
|
51
92
|
message: `ESLint found **${result.errorCount}** __errors__ and **${result.warningCount}** __warnings__.`,
|
|
52
|
-
|
|
53
|
-
codeFrame: codeframe
|
|
93
|
+
codeFrames: [codeframe]
|
|
54
94
|
};
|
|
55
95
|
|
|
56
96
|
if (result.errorCount > 0) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/validator-eslint",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.970+5a80fbe4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
+
"funding": {
|
|
9
|
+
"type": "opencollective",
|
|
10
|
+
"url": "https://opencollective.com/parcel"
|
|
11
|
+
},
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
10
14
|
"url": "https://github.com/parcel-bundler/parcel.git"
|
|
@@ -12,13 +16,19 @@
|
|
|
12
16
|
"main": "lib/EslintValidator.js",
|
|
13
17
|
"source": "src/EslintValidator.js",
|
|
14
18
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
16
|
-
"parcel": "
|
|
19
|
+
"node": ">= 12.0.0",
|
|
20
|
+
"parcel": "2.0.0-nightly.968+5a80fbe4"
|
|
17
21
|
},
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"@parcel/plugin": "2.0.0-nightly.
|
|
20
|
-
"@parcel/utils": "2.0.0-nightly.
|
|
21
|
-
"chalk": "^
|
|
23
|
+
"@parcel/plugin": "2.0.0-nightly.970+5a80fbe4",
|
|
24
|
+
"@parcel/utils": "2.0.0-nightly.970+5a80fbe4",
|
|
25
|
+
"chalk": "^4.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"eslint": "^6.0.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"eslint": "^6.0.0"
|
|
22
32
|
},
|
|
23
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "5a80fbe4af8797d0aab248a66f5254f42f00e83e"
|
|
24
34
|
}
|
package/src/EslintValidator.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {Validator} from '@parcel/plugin';
|
|
3
|
-
import type
|
|
3
|
+
import {type DiagnosticCodeFrame, escapeMarkdown} from '@parcel/diagnostic';
|
|
4
|
+
import eslint from 'eslint';
|
|
5
|
+
import invariant from 'assert';
|
|
4
6
|
|
|
5
7
|
let cliEngine = null;
|
|
6
8
|
|
|
7
|
-
export default new Validator({
|
|
8
|
-
async validate({asset
|
|
9
|
-
let eslint = await options.packageManager.require('eslint', asset.filePath);
|
|
9
|
+
export default (new Validator({
|
|
10
|
+
async validate({asset}) {
|
|
10
11
|
if (!cliEngine) {
|
|
11
12
|
cliEngine = new eslint.CLIEngine({});
|
|
12
13
|
}
|
|
13
14
|
let code = await asset.getCode();
|
|
15
|
+
|
|
16
|
+
invariant(cliEngine != null);
|
|
14
17
|
let report = cliEngine.executeOnText(code, asset.filePath);
|
|
15
18
|
|
|
16
19
|
let validatorResult = {
|
|
@@ -23,18 +26,24 @@ export default new Validator({
|
|
|
23
26
|
if (!result.errorCount && !result.warningCount) continue;
|
|
24
27
|
|
|
25
28
|
let codeframe: DiagnosticCodeFrame = {
|
|
29
|
+
filePath: asset.filePath,
|
|
26
30
|
code: result.source,
|
|
27
31
|
codeHighlights: result.messages.map(message => {
|
|
32
|
+
let start = {
|
|
33
|
+
line: message.line,
|
|
34
|
+
column: message.column,
|
|
35
|
+
};
|
|
28
36
|
return {
|
|
29
|
-
start
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
start,
|
|
38
|
+
// Parse errors have no ending
|
|
39
|
+
end:
|
|
40
|
+
message.endLine != null
|
|
41
|
+
? {
|
|
42
|
+
line: message.endLine,
|
|
43
|
+
column: message.endColumn,
|
|
44
|
+
}
|
|
45
|
+
: start,
|
|
46
|
+
message: escapeMarkdown(message.message),
|
|
38
47
|
};
|
|
39
48
|
}),
|
|
40
49
|
};
|
|
@@ -42,8 +51,7 @@ export default new Validator({
|
|
|
42
51
|
let diagnostic = {
|
|
43
52
|
origin: '@parcel/validator-eslint',
|
|
44
53
|
message: `ESLint found **${result.errorCount}** __errors__ and **${result.warningCount}** __warnings__.`,
|
|
45
|
-
|
|
46
|
-
codeFrame: codeframe,
|
|
54
|
+
codeFrames: [codeframe],
|
|
47
55
|
};
|
|
48
56
|
|
|
49
57
|
if (result.errorCount > 0) {
|
|
@@ -56,4 +64,4 @@ export default new Validator({
|
|
|
56
64
|
|
|
57
65
|
return validatorResult;
|
|
58
66
|
},
|
|
59
|
-
});
|
|
67
|
+
}): Validator);
|
package/.babelrc
DELETED