@microsoft/sp-tslint-rules 1.14.0 → 1.15.0-beta.1
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.
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Rule = void 0;
|
|
3
23
|
const tsutils_1 = require("tsutils");
|
|
4
|
-
const ts = require("typescript");
|
|
5
|
-
const Lint = require("tslint");
|
|
24
|
+
const ts = __importStar(require("typescript"));
|
|
25
|
+
const Lint = __importStar(require("tslint"));
|
|
6
26
|
/**
|
|
7
27
|
* Matches parts of the webpack import(...) meta-comment that look like these examples:
|
|
8
28
|
* - propertyName:'value'
|
|
@@ -25,13 +45,13 @@ class Rule extends Lint.Rules.AbstractRule {
|
|
|
25
45
|
apply(sourceFile) {
|
|
26
46
|
return this.applyWithFunction(sourceFile, (ctx) => {
|
|
27
47
|
const childCallback = (node) => {
|
|
28
|
-
if (tsutils_1.isCallExpression(node) &&
|
|
48
|
+
if ((0, tsutils_1.isCallExpression)(node) &&
|
|
29
49
|
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
|
30
50
|
node.getChildCount() >= 4 // 4+ children: keyword, openParen, args..., closeParen
|
|
31
51
|
) {
|
|
32
52
|
// In an import(...) expression
|
|
33
53
|
const comments = [];
|
|
34
|
-
tsutils_1.forEachComment(node, (text, comment) => {
|
|
54
|
+
(0, tsutils_1.forEachComment)(node, (text, comment) => {
|
|
35
55
|
comments.push(text.substring(comment.pos, comment.end));
|
|
36
56
|
});
|
|
37
57
|
let webpackChunkNameTokensFound = 0;
|
package/lib/index.js
CHANGED
package/lib/noAsyncAwaitRule.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Rule = void 0;
|
|
3
23
|
const tsutils_1 = require("tsutils");
|
|
4
|
-
const ts = require("typescript");
|
|
5
|
-
const Lint = require("tslint");
|
|
24
|
+
const ts = __importStar(require("typescript"));
|
|
25
|
+
const Lint = __importStar(require("tslint"));
|
|
6
26
|
/**
|
|
7
27
|
* Check for any functions with the `async` modifier. If a function does not have the `async`
|
|
8
28
|
* modifier then we defer to TSC to fail on `await` keywords since `await` has to be used
|
|
@@ -29,10 +49,10 @@ function noAsyncAwait(context, node) {
|
|
|
29
49
|
ts.forEachChild(context.sourceFile, (n) => noAsyncAwait(context, n));
|
|
30
50
|
}
|
|
31
51
|
else {
|
|
32
|
-
if (tsutils_1.isArrowFunction(node) ||
|
|
33
|
-
tsutils_1.isFunctionDeclaration(node) ||
|
|
34
|
-
tsutils_1.isFunctionExpression(node) ||
|
|
35
|
-
tsutils_1.isMethodDeclaration(node)) {
|
|
52
|
+
if ((0, tsutils_1.isArrowFunction)(node) ||
|
|
53
|
+
(0, tsutils_1.isFunctionDeclaration)(node) ||
|
|
54
|
+
(0, tsutils_1.isFunctionExpression)(node) ||
|
|
55
|
+
(0, tsutils_1.isMethodDeclaration)(node)) {
|
|
36
56
|
checkAndReportIfAsync(context, node);
|
|
37
57
|
}
|
|
38
58
|
ts.forEachChild(node, (n) => noAsyncAwait(context, n));
|
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.Rule = void 0;
|
|
3
23
|
const tsutils_1 = require("tsutils");
|
|
4
|
-
const ts = require("typescript");
|
|
5
|
-
const Lint = require("tslint");
|
|
24
|
+
const ts = __importStar(require("typescript"));
|
|
25
|
+
const Lint = __importStar(require("tslint"));
|
|
6
26
|
// tslint:disable:export-name
|
|
7
27
|
class Rule extends Lint.Rules.AbstractRule {
|
|
8
28
|
apply(sourceFile) {
|
|
9
29
|
return this.applyWithFunction(sourceFile, (ctx) => {
|
|
10
30
|
const childCallback = (node) => {
|
|
11
|
-
if (tsutils_1.isCallExpression(node) &&
|
|
12
|
-
tsutils_1.isPropertyAccessExpression(node.expression) &&
|
|
13
|
-
tsutils_1.isIdentifier(node.expression.expression) &&
|
|
31
|
+
if ((0, tsutils_1.isCallExpression)(node) &&
|
|
32
|
+
(0, tsutils_1.isPropertyAccessExpression)(node.expression) &&
|
|
33
|
+
(0, tsutils_1.isIdentifier)(node.expression.expression) &&
|
|
14
34
|
node.expression.expression.text === 'require' &&
|
|
15
35
|
node.expression.getChildCount() === 3) {
|
|
16
36
|
const lastChild = node.expression.getChildAt(2);
|
|
17
|
-
if (tsutils_1.isIdentifier(lastChild) && lastChild.text === 'ensure') {
|
|
37
|
+
if ((0, tsutils_1.isIdentifier)(lastChild) && lastChild.text === 'ensure') {
|
|
18
38
|
ctx.addFailureAtNode(node.expression, "Calls to 'require.ensure' are not allowed. Use 'import' instead.");
|
|
19
39
|
}
|
|
20
40
|
}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
22
|
+
exports.Rule = void 0;
|
|
23
|
+
const tsUtils = __importStar(require("tsutils"));
|
|
24
|
+
const ts = __importStar(require("typescript"));
|
|
25
|
+
const Lint = __importStar(require("tslint"));
|
|
6
26
|
// tslint:disable:export-name
|
|
7
27
|
class Rule extends Lint.Rules.AbstractRule {
|
|
8
28
|
apply(sourceFile) {
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
22
|
+
exports.Rule = void 0;
|
|
23
|
+
const Lint = __importStar(require("tslint"));
|
|
4
24
|
const tsutils_1 = require("tsutils");
|
|
5
|
-
const ts = require("typescript");
|
|
25
|
+
const ts = __importStar(require("typescript"));
|
|
6
26
|
/**
|
|
7
27
|
* Validate valid GUID strings are being passed as an argument to SPKillSwitch.isActivated calls.
|
|
8
28
|
* JavaScript does not have a native GUID type. We removed expensive runtime parsing during production
|
|
@@ -29,16 +49,16 @@ function validKillSwitchGuid(context, node) {
|
|
|
29
49
|
ts.forEachChild(context.sourceFile, (n) => validKillSwitchGuid(context, n));
|
|
30
50
|
}
|
|
31
51
|
else {
|
|
32
|
-
if (tsutils_1.isCallExpression(node) && isSPKillSwitch(node) && !isValidGuid(node.arguments[0].getText())) {
|
|
52
|
+
if ((0, tsutils_1.isCallExpression)(node) && isSPKillSwitch(node) && !isValidGuid(node.arguments[0].getText())) {
|
|
33
53
|
context.addFailureAtNode(node, '_SPKillSwitch.isActivated argument must be a valid, lower-case GUID');
|
|
34
54
|
}
|
|
35
55
|
ts.forEachChild(node, (n) => validKillSwitchGuid(context, n));
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
58
|
function isSPKillSwitch(node) {
|
|
39
|
-
return (tsutils_1.isPropertyAccessExpression(node.expression) &&
|
|
59
|
+
return ((0, tsutils_1.isPropertyAccessExpression)(node.expression) &&
|
|
40
60
|
node.expression.name.getText() === 'isActivated' &&
|
|
41
|
-
tsutils_1.isIdentifier(node.expression.expression) &&
|
|
61
|
+
(0, tsutils_1.isIdentifier)(node.expression.expression) &&
|
|
42
62
|
(node.expression.expression.getText() === '_SPKillSwitch' ||
|
|
43
63
|
node.expression.expression.getText() === 'SPKillSwitch') &&
|
|
44
64
|
node.arguments.length === 1);
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/sp-tslint-rules",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0-beta.1",
|
|
4
4
|
"description": "SharePoint Framework tslint rules",
|
|
5
5
|
"license": "SEE LICENSE IN \"EULA\" FOLDER",
|
|
6
6
|
"homepage": "http://aka.ms/spfx",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"scripts": {},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=12.13.0 <13.0.0 || >=14.15.0 <15.0.0"
|
|
10
|
+
"node": ">=12.13.0 <13.0.0 || >=14.15.0 <15.0.0 || >=16.13.0 <17.0.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"tslint": "~6.1.3",
|
|
14
|
-
"tsutils": "~2.11.2"
|
|
14
|
+
"tsutils": "~2.11.2",
|
|
15
|
+
"typescript": "3.7.5"
|
|
15
16
|
}
|
|
16
17
|
}
|