@microsoft/sp-tslint-rules 1.21.0-beta.0 → 1.21.0-beta.2

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.
Files changed (34) hide show
  1. package/lib-commonjs/importRequiresChunkNameRule.js +130 -0
  2. package/lib-commonjs/index.js +9 -0
  3. package/lib-commonjs/noAsyncAwaitRule.js +102 -0
  4. package/lib-commonjs/noRequireEnsureRule.js +95 -0
  5. package/lib-commonjs/pairReactDomRenderUnmountRule.js +136 -0
  6. package/lib-commonjs/scripts/runTslintTests.js +69 -0
  7. package/lib-commonjs/validKillSwitchGuidRule.js +100 -0
  8. package/lib-dts/scripts/runTslintTests.d.ts +3 -0
  9. package/{lib → lib-esm}/importRequiresChunkNameRule.js +30 -48
  10. package/lib-esm/index.js +6 -0
  11. package/lib-esm/noAsyncAwaitRule.js +55 -0
  12. package/lib-esm/noRequireEnsureRule.js +44 -0
  13. package/lib-esm/pairReactDomRenderUnmountRule.js +85 -0
  14. package/lib-esm/scripts/runTslintTests.js +18 -0
  15. package/lib-esm/validKillSwitchGuidRule.js +53 -0
  16. package/package.json +27 -5
  17. package/base-tslint.json +0 -5
  18. package/lib/importRequiresChunkNameRule.d.ts.map +0 -1
  19. package/lib/index.d.ts.map +0 -1
  20. package/lib/index.js +0 -7
  21. package/lib/noAsyncAwaitRule.d.ts.map +0 -1
  22. package/lib/noAsyncAwaitRule.js +0 -73
  23. package/lib/noRequireEnsureRule.d.ts.map +0 -1
  24. package/lib/noRequireEnsureRule.js +0 -60
  25. package/lib/pairReactDomRenderUnmountRule.d.ts.map +0 -1
  26. package/lib/pairReactDomRenderUnmountRule.js +0 -108
  27. package/lib/validKillSwitchGuidRule.d.ts.map +0 -1
  28. package/lib/validKillSwitchGuidRule.js +0 -72
  29. /package/{lib → lib-dts}/importRequiresChunkNameRule.d.ts +0 -0
  30. /package/{lib → lib-dts}/index.d.ts +0 -0
  31. /package/{lib → lib-dts}/noAsyncAwaitRule.d.ts +0 -0
  32. /package/{lib → lib-dts}/noRequireEnsureRule.d.ts +0 -0
  33. /package/{lib → lib-dts}/pairReactDomRenderUnmountRule.d.ts +0 -0
  34. /package/{lib → lib-dts}/validKillSwitchGuidRule.d.ts +0 -0
@@ -1,32 +1,19 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
7
11
  }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Rule = void 0;
27
- const tsutils_1 = require("tsutils");
28
- const ts = __importStar(require("typescript"));
29
- const Lint = __importStar(require("tslint"));
12
+ return obj;
13
+ }
14
+ import { isCallExpression, forEachComment } from 'tsutils';
15
+ import * as ts from 'typescript';
16
+ import * as Lint from 'tslint';
30
17
  /**
31
18
  * Matches parts of the webpack import(...) meta-comment that look like these examples:
32
19
  * - propertyName:'value'
@@ -37,37 +24,33 @@ const Lint = __importStar(require("tslint"));
37
24
  * - propertyName : 'value'
38
25
  * - propertyName :"value"
39
26
  * - propertyName : "value"
40
- */
41
- const COMMENT_PART_REGEX = /^([A-Za-z]+)\s*:\s*('[^']+'|"[^"]+")$/;
27
+ */ const COMMENT_PART_REGEX = /^([A-Za-z]+)\s*:\s*('[^']+'|"[^"]+")$/;
28
+ var _Lint_Rules_AbstractRule;
42
29
  /**
43
30
  * This rule requires that import(...) statements include a /* webpackChunkName: '...' *\/ comment.
44
31
  *
45
32
  * See documentation here: https://webpack.js.org/api/module-methods/#import-
46
- */
47
- class Rule extends Lint.Rules.AbstractRule {
33
+ */ export class Rule extends (_Lint_Rules_AbstractRule = Lint.Rules.AbstractRule) {
48
34
  apply(sourceFile) {
49
- return this.applyWithFunction(sourceFile, (ctx) => {
50
- const childCallback = (node) => {
51
- if ((0, tsutils_1.isCallExpression)(node) &&
52
- node.expression.kind === ts.SyntaxKind.ImportKeyword &&
53
- node.getChildCount() >= 4 // 4+ children: keyword, openParen, args..., closeParen
35
+ return this.applyWithFunction(sourceFile, (ctx)=>{
36
+ const childCallback = (node)=>{
37
+ if (isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword && node.getChildCount() >= 4 // 4+ children: keyword, openParen, args..., closeParen
54
38
  ) {
55
39
  // In an import(...) expression
56
40
  const comments = [];
57
- (0, tsutils_1.forEachComment)(node, (text, comment) => {
41
+ forEachComment(node, (text, comment)=>{
58
42
  comments.push(text.substring(comment.pos, comment.end));
59
43
  });
60
44
  let webpackChunkNameTokensFound = 0;
61
- for (const rawComment of comments) {
45
+ for (const rawComment of comments){
62
46
  let comment = rawComment.trim();
63
47
  if (comment.indexOf('//') === 0) {
64
48
  comment = comment.substr(2);
65
- }
66
- else if (comment.indexOf('/*') === 0 && comment.indexOf('*/') === comment.length - 2) {
49
+ } else if (comment.indexOf('/*') === 0 && comment.indexOf('*/') === comment.length - 2) {
67
50
  comment = comment.substring(2, comment.length - 2);
68
51
  }
69
52
  const commentParts = comment.split(',');
70
- for (let commentPart of commentParts) {
53
+ for (let commentPart of commentParts){
71
54
  commentPart = commentPart.trim();
72
55
  const commentRegexResult = commentPart.match(COMMENT_PART_REGEX);
73
56
  if (commentRegexResult && commentRegexResult[1] === 'webpackChunkName') {
@@ -77,8 +60,7 @@ class Rule extends Lint.Rules.AbstractRule {
77
60
  }
78
61
  if (webpackChunkNameTokensFound === 0) {
79
62
  ctx.addFailureAtNode(node.expression, 'Calls to "import" must include a /* webpackChunkName: \'name\' */ comment');
80
- }
81
- else if (webpackChunkNameTokensFound !== 1) {
63
+ } else if (webpackChunkNameTokensFound !== 1) {
82
64
  ctx.addFailureAtNode(node.expression, 'Calls to "import" must include only one /* webpackChunkName: \'name\' */ comment');
83
65
  }
84
66
  }
@@ -88,8 +70,7 @@ class Rule extends Lint.Rules.AbstractRule {
88
70
  });
89
71
  }
90
72
  }
91
- exports.Rule = Rule;
92
- Rule.metadata = {
73
+ _define_property(Rule, "metadata", {
93
74
  ruleName: 'import-requires-chunk-name',
94
75
  description: 'Requires that calls to import(...) for code splitting include a webpack chunk name',
95
76
  rationale: 'Unnamed chunks are difficult to manage.',
@@ -97,5 +78,6 @@ Rule.metadata = {
97
78
  options: {},
98
79
  type: 'functionality',
99
80
  typescriptOnly: false
100
- };
101
- //# sourceMappingURL=importRequiresChunkNameRule.js.map
81
+ });
82
+
83
+ //#sourceMappingUrl=./importRequiresChunkNameRule.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SharePoint Framework tslint rules.
3
+ * @remarks
4
+ */ export { };
5
+
6
+ //#sourceMappingUrl=./index.js.map
@@ -0,0 +1,55 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { isArrowFunction, isFunctionDeclaration, isFunctionExpression, isMethodDeclaration } from 'tsutils';
15
+ import * as ts from 'typescript';
16
+ import * as Lint from 'tslint';
17
+ var _Lint_Rules_AbstractRule;
18
+ /**
19
+ * Check for any functions with the `async` modifier. If a function does not have the `async`
20
+ * modifier then we defer to TSC to fail on `await` keywords since `await` has to be used
21
+ * within an `async` context.
22
+ */ export class Rule extends (_Lint_Rules_AbstractRule = Lint.Rules.AbstractRule) {
23
+ apply(source) {
24
+ return this.applyWithFunction(source, noAsyncAwait);
25
+ }
26
+ }
27
+ _define_property(Rule, "metadata", {
28
+ ruleName: 'no-async-await',
29
+ description: 'Warn when using async/await functions.',
30
+ rationale: 'async/await has overhead when emitting ES5 JavaScript',
31
+ optionsDescription: 'No options available.',
32
+ options: undefined,
33
+ type: 'functionality',
34
+ typescriptOnly: false
35
+ });
36
+ function noAsyncAwait(context, node) {
37
+ if (!node) {
38
+ ts.forEachChild(context.sourceFile, (n)=>noAsyncAwait(context, n));
39
+ } else {
40
+ if (isArrowFunction(node) || isFunctionDeclaration(node) || isFunctionExpression(node) || isMethodDeclaration(node)) {
41
+ checkAndReportIfAsync(context, node);
42
+ }
43
+ ts.forEachChild(node, (n)=>noAsyncAwait(context, n));
44
+ }
45
+ }
46
+ function checkAndReportIfAsync(context, node) {
47
+ if (node.body === undefined && node.type !== undefined) {
48
+ return;
49
+ }
50
+ if (node.modifiers !== undefined && node.modifiers.find((modifier)=>modifier.kind === ts.SyntaxKind.AsyncKeyword)) {
51
+ context.addFailureAtNode(node, 'async/await usage is not allowed');
52
+ }
53
+ }
54
+
55
+ //#sourceMappingUrl=./noAsyncAwaitRule.js.map
@@ -0,0 +1,44 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { isCallExpression, isIdentifier, isPropertyAccessExpression } from 'tsutils';
15
+ import * as ts from 'typescript';
16
+ import * as Lint from 'tslint';
17
+ var _Lint_Rules_AbstractRule;
18
+ export class Rule extends (_Lint_Rules_AbstractRule = Lint.Rules.AbstractRule) {
19
+ apply(sourceFile) {
20
+ return this.applyWithFunction(sourceFile, (ctx)=>{
21
+ const childCallback = (node)=>{
22
+ if (isCallExpression(node) && isPropertyAccessExpression(node.expression) && isIdentifier(node.expression.expression) && node.expression.expression.text === 'require' && node.expression.getChildCount() === 3) {
23
+ const lastChild = node.expression.getChildAt(2);
24
+ if (isIdentifier(lastChild) && lastChild.text === 'ensure') {
25
+ ctx.addFailureAtNode(node.expression, "Calls to 'require.ensure' are not allowed. Use 'import' instead.");
26
+ }
27
+ }
28
+ return ts.forEachChild(node, childCallback);
29
+ };
30
+ return ts.forEachChild(ctx.sourceFile, childCallback);
31
+ });
32
+ }
33
+ }
34
+ _define_property(Rule, "metadata", {
35
+ ruleName: 'no-require-ensure',
36
+ description: 'Warns about the use of the require.ensure function.',
37
+ rationale: '`require.ensure` is outdated. Use `import(...)` instead.',
38
+ optionsDescription: 'No options available.',
39
+ options: {},
40
+ type: 'functionality',
41
+ typescriptOnly: false
42
+ });
43
+
44
+ //#sourceMappingUrl=./noRequireEnsureRule.js.map
@@ -0,0 +1,85 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import * as tsUtils from 'tsutils';
15
+ import * as ts from 'typescript';
16
+ import * as Lint from 'tslint';
17
+ var _Lint_Rules_AbstractRule;
18
+ export class Rule extends (_Lint_Rules_AbstractRule = Lint.Rules.AbstractRule) {
19
+ apply(sourceFile) {
20
+ return this.applyWithFunction(sourceFile, this._walk.bind(this));
21
+ }
22
+ _walk(ctx) {
23
+ const renderCalls = [];
24
+ const unmountCalls = [];
25
+ // Do not convert `callback` to a function. It references `this` keyword inside it.
26
+ const callback = (node)=>{
27
+ const reactDOMImportNamespaceName = this._getReactDOMImportNamespaceName(node);
28
+ if (reactDOMImportNamespaceName) {
29
+ this._reactDOMImportNamespaceName = reactDOMImportNamespaceName;
30
+ return;
31
+ }
32
+ const isRenderCallExpression = this._isReactDOMCallExpression(node, 'render');
33
+ if (isRenderCallExpression) {
34
+ renderCalls.push(node);
35
+ return;
36
+ }
37
+ const isUnmountCallExpression = this._isReactDOMCallExpression(node, 'unmountComponentAtNode');
38
+ if (isUnmountCallExpression) {
39
+ unmountCalls.push(node);
40
+ return;
41
+ }
42
+ ts.forEachChild(node, callback);
43
+ };
44
+ ts.forEachChild(ctx.sourceFile, callback);
45
+ // Verify the count of render calls and unmount calls are the same in the file.
46
+ if (renderCalls.length !== unmountCalls.length) {
47
+ renderCalls.concat(unmountCalls).forEach((renderCallExpression)=>{
48
+ ctx.addFailureAtNode(renderCallExpression, 'Unmatched calls between `ReactDOM.render` and `ReactDOM.unmountComponentAtNode`.');
49
+ });
50
+ }
51
+ }
52
+ _getReactDOMImportNamespaceName(node) {
53
+ if (// import * as ReactDOM from 'react-dom'
54
+ tsUtils.isImportDeclaration(node) && // * as ReactDOM
55
+ node.importClause && tsUtils.isImportClause(node.importClause) && // ReactDOM
56
+ node.importClause.namedBindings && tsUtils.isNamespaceImport(node.importClause.namedBindings) && // 'react-dom'
57
+ tsUtils.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === 'react-dom') {
58
+ return node.importClause.namedBindings.name.text;
59
+ } else {
60
+ return undefined;
61
+ }
62
+ }
63
+ _isReactDOMCallExpression(node, methodName) {
64
+ return(// ReactDOM.method(param1, param2)
65
+ tsUtils.isCallExpression(node) && // ReactDOM.method
66
+ tsUtils.isPropertyAccessExpression(node.expression) && // ReactDOM
67
+ tsUtils.isIdentifier(node.expression.expression) && node.expression.expression.text === this._reactDOMImportNamespaceName && // method
68
+ tsUtils.isIdentifier(node.expression.name) && node.expression.name.text === methodName);
69
+ }
70
+ constructor(...args){
71
+ super(...args);
72
+ _define_property(this, "_reactDOMImportNamespaceName", void 0);
73
+ }
74
+ }
75
+ _define_property(Rule, "metadata", {
76
+ ruleName: 'pair-react-dom-render-unmount',
77
+ description: 'Pair ReactDOM render and unmount calls in one file.' + ' If a ReactDOM render tree is not unmounted when disposed, it will cause a memory leak.',
78
+ rationale: 'Pair the render and unmount calls to avoid memory leak.',
79
+ optionsDescription: 'No options available.',
80
+ options: {},
81
+ type: 'maintainability',
82
+ typescriptOnly: false
83
+ });
84
+
85
+ //#sourceMappingUrl=./pairReactDomRenderUnmountRule.js.map
@@ -0,0 +1,18 @@
1
+ import * as tslint from 'tslint';
2
+ export async function runAsync(options) {
3
+ const { heftTaskSession: { logger } } = options;
4
+ const testResults = tslint.Test.runTests([
5
+ 'test/**/tslint.json'
6
+ ], 'lib-commonjs');
7
+ const isSuccess = tslint.Test.consoleTestResultsHandler(testResults, {
8
+ log: logger.terminal.writeLine.bind(logger.terminal),
9
+ error: logger.terminal.writeErrorLine.bind(logger.terminal)
10
+ });
11
+ if (!isSuccess) {
12
+ const e = new Error('TSLint tests failed.');
13
+ logger.emitError(e);
14
+ throw e;
15
+ }
16
+ }
17
+
18
+ //#sourceMappingUrl=./runTslintTests.js.map
@@ -0,0 +1,53 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import * as Lint from 'tslint';
15
+ import { isCallExpression, isIdentifier, isPropertyAccessExpression } from 'tsutils';
16
+ import * as ts from 'typescript';
17
+ var _Lint_Rules_AbstractRule;
18
+ /**
19
+ * Validate valid GUID strings are being passed as an argument to SPKillSwitch.isActivated calls.
20
+ * JavaScript does not have a native GUID type. We removed expensive runtime parsing during production
21
+ * builds when checking kill switches. In order to ensure type safety, we are validating at build time with tslint.
22
+ */ export class Rule extends (_Lint_Rules_AbstractRule = Lint.Rules.AbstractRule) {
23
+ apply(source) {
24
+ return this.applyWithFunction(source, validKillSwitchGuid);
25
+ }
26
+ }
27
+ _define_property(Rule, "metadata", {
28
+ ruleName: 'valid-kill-switch-guid',
29
+ description: 'Warn if _SPKillSwitch.isActivated is being called with an incorrect argument',
30
+ rationale: 'Compile time type safety',
31
+ optionsDescription: 'No options available.',
32
+ options: undefined,
33
+ type: 'functionality',
34
+ typescriptOnly: false
35
+ });
36
+ function validKillSwitchGuid(context, node) {
37
+ if (!node) {
38
+ ts.forEachChild(context.sourceFile, (n)=>validKillSwitchGuid(context, n));
39
+ } else {
40
+ if (isCallExpression(node) && isSPKillSwitch(node) && !isValidGuid(node.arguments[0].getText())) {
41
+ context.addFailureAtNode(node, '_SPKillSwitch.isActivated argument must be a valid, lower-case GUID');
42
+ }
43
+ ts.forEachChild(node, (n)=>validKillSwitchGuid(context, n));
44
+ }
45
+ }
46
+ function isSPKillSwitch(node) {
47
+ return isPropertyAccessExpression(node.expression) && node.expression.name.getText() === 'isActivated' && isIdentifier(node.expression.expression) && (node.expression.expression.getText() === '_SPKillSwitch' || node.expression.expression.getText() === 'SPKillSwitch') && node.arguments.length === 1;
48
+ }
49
+ function isValidGuid(guidString) {
50
+ return /^'[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}'$/.test(guidString);
51
+ }
52
+
53
+ //#sourceMappingUrl=./validKillSwitchGuidRule.js.map
package/package.json CHANGED
@@ -1,12 +1,34 @@
1
1
  {
2
2
  "name": "@microsoft/sp-tslint-rules",
3
- "version": "1.21.0-beta.0",
3
+ "version": "1.21.0-beta.2",
4
4
  "description": "SharePoint Framework tslint rules",
5
5
  "license": "https://aka.ms/spfx/license",
6
6
  "homepage": "http://aka.ms/spfx",
7
- "main": "lib/index.js",
7
+ "main": "lib-commonjs/index.js",
8
+ "module": "lib-esm/index.js",
9
+ "typings": "lib-dts/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./lib-esm/index.js",
13
+ "require": "./lib-commonjs/index.js",
14
+ "types": "./lib-dts/index.d.ts"
15
+ },
16
+ "./lib/*": {
17
+ "import": "./lib-esm/*.js",
18
+ "require": "./lib-commonjs/*.js",
19
+ "types": "./lib-dts/*.d.ts"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ "lib/*": [
26
+ "lib-dts/*"
27
+ ]
28
+ }
29
+ },
8
30
  "engines": {
9
- "node": ">=18.17.1 <19.0.0"
31
+ "node": ">=18.17.1 <19.0.0 || >=22.14.0 < 23.0.0"
10
32
  },
11
33
  "dependencies": {
12
34
  "tslint": "~6.1.3",
@@ -14,9 +36,9 @@
14
36
  "typescript": "5.3.3"
15
37
  },
16
38
  "devDependencies": {
17
- "@rushstack/heft": "0.68.13",
39
+ "@rushstack/heft": "0.71.0",
18
40
  "eslint": "8.57.1",
19
- "@odsp-web-tools/internal-node-rig": "0.1.0"
41
+ "@msinternal/internal-node-rig": "0.1.0"
20
42
  },
21
43
  "scripts": {
22
44
  "build": "heft test --clean",
package/base-tslint.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "http://json.schemastore.org/tslint",
3
-
4
- "rulesDirectory": ["tslint-microsoft-contrib", "./lib"]
5
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"importRequiresChunkNameRule.d.ts","sourceRoot":"","sources":["../src/importRequiresChunkNameRule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAe/B;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,IAAI,CAAC,KAAK,CAAC,YAAY;IAC/C,OAAc,QAAQ,EAAE,IAAI,CAAC,aAAa,CAQxC;IAEK,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;CAqD5D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC"}
package/lib/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * SharePoint Framework tslint rules.
4
- * @remarks
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noAsyncAwaitRule.d.ts","sourceRoot":"","sources":["../src/noAsyncAwaitRule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAI/B;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,IAAI,CAAC,KAAK,CAAC,YAAY;IAC/C,OAAc,QAAQ,EAAE,IAAI,CAAC,aAAa,CAQxC;IAEK,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;CAGxD"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Rule = void 0;
27
- const tsutils_1 = require("tsutils");
28
- const ts = __importStar(require("typescript"));
29
- const Lint = __importStar(require("tslint"));
30
- /**
31
- * Check for any functions with the `async` modifier. If a function does not have the `async`
32
- * modifier then we defer to TSC to fail on `await` keywords since `await` has to be used
33
- * within an `async` context.
34
- */
35
- class Rule extends Lint.Rules.AbstractRule {
36
- apply(source) {
37
- return this.applyWithFunction(source, noAsyncAwait);
38
- }
39
- }
40
- exports.Rule = Rule;
41
- Rule.metadata = {
42
- ruleName: 'no-async-await',
43
- description: 'Warn when using async/await functions.',
44
- rationale: 'async/await has overhead when emitting ES5 JavaScript',
45
- optionsDescription: 'No options available.',
46
- options: undefined,
47
- type: 'functionality',
48
- typescriptOnly: false
49
- };
50
- function noAsyncAwait(context, node) {
51
- if (!node) {
52
- ts.forEachChild(context.sourceFile, (n) => noAsyncAwait(context, n));
53
- }
54
- else {
55
- if ((0, tsutils_1.isArrowFunction)(node) ||
56
- (0, tsutils_1.isFunctionDeclaration)(node) ||
57
- (0, tsutils_1.isFunctionExpression)(node) ||
58
- (0, tsutils_1.isMethodDeclaration)(node)) {
59
- checkAndReportIfAsync(context, node);
60
- }
61
- ts.forEachChild(node, (n) => noAsyncAwait(context, n));
62
- }
63
- }
64
- function checkAndReportIfAsync(context, node) {
65
- if (node.body === undefined && node.type !== undefined) {
66
- return;
67
- }
68
- if (node.modifiers !== undefined &&
69
- node.modifiers.find((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword)) {
70
- context.addFailureAtNode(node, 'async/await usage is not allowed');
71
- }
72
- }
73
- //# sourceMappingURL=noAsyncAwaitRule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noRequireEnsureRule.d.ts","sourceRoot":"","sources":["../src/noRequireEnsureRule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,qBAAa,IAAK,SAAQ,IAAI,CAAC,KAAK,CAAC,YAAY;IAC/C,OAAc,QAAQ,EAAE,IAAI,CAAC,aAAa,CAQxC;IAEK,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;CAyB5D"}
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Rule = void 0;
27
- const tsutils_1 = require("tsutils");
28
- const ts = __importStar(require("typescript"));
29
- const Lint = __importStar(require("tslint"));
30
- class Rule extends Lint.Rules.AbstractRule {
31
- apply(sourceFile) {
32
- return this.applyWithFunction(sourceFile, (ctx) => {
33
- const childCallback = (node) => {
34
- if ((0, tsutils_1.isCallExpression)(node) &&
35
- (0, tsutils_1.isPropertyAccessExpression)(node.expression) &&
36
- (0, tsutils_1.isIdentifier)(node.expression.expression) &&
37
- node.expression.expression.text === 'require' &&
38
- node.expression.getChildCount() === 3) {
39
- const lastChild = node.expression.getChildAt(2);
40
- if ((0, tsutils_1.isIdentifier)(lastChild) && lastChild.text === 'ensure') {
41
- ctx.addFailureAtNode(node.expression, "Calls to 'require.ensure' are not allowed. Use 'import' instead.");
42
- }
43
- }
44
- return ts.forEachChild(node, childCallback);
45
- };
46
- return ts.forEachChild(ctx.sourceFile, childCallback);
47
- });
48
- }
49
- }
50
- exports.Rule = Rule;
51
- Rule.metadata = {
52
- ruleName: 'no-require-ensure',
53
- description: 'Warns about the use of the require.ensure function.',
54
- rationale: '`require.ensure` is outdated. Use `import(...)` instead.',
55
- optionsDescription: 'No options available.',
56
- options: {},
57
- type: 'functionality',
58
- typescriptOnly: false
59
- };
60
- //# sourceMappingURL=noRequireEnsureRule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pairReactDomRenderUnmountRule.d.ts","sourceRoot":"","sources":["../src/pairReactDomRenderUnmountRule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,qBAAa,IAAK,SAAQ,IAAI,CAAC,KAAK,CAAC,YAAY;IAC/C,OAAc,QAAQ,EAAE,IAAI,CAAC,aAAa,CAUxC;IAEF,OAAO,CAAC,4BAA4B,CAAqB;IAElD,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;IAI3D,OAAO,CAAC,KAAK;IAwCb,OAAO,CAAC,+BAA+B;IAoBvC,OAAO,CAAC,yBAAyB;CAclC"}