@servicetitan/eslint-plugin 30.3.1 → 31.0.0
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/dist/index.js +52 -27
- package/dist/index.js.map +1 -1
- package/dist/processors/stub.js +15 -5
- package/dist/processors/stub.js.map +1 -1
- package/dist/rules/__mocks__/fixture/file.js +2 -3
- package/dist/rules/__mocks__/fixture/file.js.map +1 -1
- package/dist/rules/__mocks__/fixture/react.js +2 -3
- package/dist/rules/__mocks__/fixture/react.js.map +1 -1
- package/dist/rules/__mocks__/fixture/tsconfig.json +6 -0
- package/dist/rules/decorators-declare.js +29 -18
- package/dist/rules/decorators-declare.js.map +1 -1
- package/dist/rules/mobx/no-abstract-decorators.js +30 -17
- package/dist/rules/mobx/no-abstract-decorators.js.map +1 -1
- package/dist/rules/mobx/use-makeObservable-with-decorators.js +35 -24
- package/dist/rules/mobx/use-makeObservable-with-decorators.js.map +1 -1
- package/dist/rules/no-async-in-foreach.js +43 -28
- package/dist/rules/no-async-in-foreach.js.map +1 -1
- package/dist/rules/react/destructure-default-import.js +21 -14
- package/dist/rules/react/destructure-default-import.js.map +1 -1
- package/dist/rules/react/no-qualified-type.js +20 -12
- package/dist/rules/react/no-qualified-type.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get // eslint-disable-next-line import/no-default-export
|
|
13
|
+
default () {
|
|
14
|
+
return _default;
|
|
15
|
+
},
|
|
16
|
+
get rules () {
|
|
17
|
+
return rules;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const _noasyncinforeach = require("./rules/no-async-in-foreach");
|
|
21
|
+
const _decoratorsdeclare = require("./rules/decorators-declare");
|
|
22
|
+
const _usemakeObservablewithdecorators = require("./rules/mobx/use-makeObservable-with-decorators");
|
|
23
|
+
const _noabstractdecorators = require("./rules/mobx/no-abstract-decorators");
|
|
24
|
+
const _destructuredefaultimport = require("./rules/react/destructure-default-import");
|
|
25
|
+
const _noqualifiedtype = require("./rules/react/no-qualified-type");
|
|
26
|
+
const rules = {
|
|
11
27
|
base: {
|
|
12
|
-
'no-async-in-foreach':
|
|
13
|
-
'use-declare-with-decorators':
|
|
28
|
+
'no-async-in-foreach': _noasyncinforeach.noAsyncInForEach,
|
|
29
|
+
'use-declare-with-decorators': _decoratorsdeclare.useDeclareWithDecorators
|
|
14
30
|
},
|
|
15
31
|
mobx: {
|
|
16
|
-
'use-makeObservable-with-decorators':
|
|
17
|
-
'no-abstract-decorators':
|
|
32
|
+
'use-makeObservable-with-decorators': _usemakeObservablewithdecorators.mobxUseMakeObservableWithDecorators,
|
|
33
|
+
'no-abstract-decorators': _noabstractdecorators.mobxNoAbstractDecorators
|
|
18
34
|
},
|
|
19
35
|
react: {
|
|
20
|
-
'destructure-default-import':
|
|
21
|
-
'no-qualified-type':
|
|
22
|
-
}
|
|
36
|
+
'destructure-default-import': _destructuredefaultimport.reactDestructureDefaultImport,
|
|
37
|
+
'no-qualified-type': _noqualifiedtype.reactNoQualifiedType
|
|
38
|
+
}
|
|
23
39
|
};
|
|
24
40
|
const plugin = {
|
|
25
41
|
configs: {
|
|
@@ -27,23 +43,32 @@ const plugin = {
|
|
|
27
43
|
{
|
|
28
44
|
name: '@servicetitan/eslint-plugin',
|
|
29
45
|
plugins: {
|
|
30
|
-
'@servicetitan': {
|
|
31
|
-
|
|
32
|
-
|
|
46
|
+
'@servicetitan': {
|
|
47
|
+
rules: rules.base
|
|
48
|
+
},
|
|
49
|
+
'@servicetitan/mobx': {
|
|
50
|
+
rules: rules.mobx
|
|
51
|
+
},
|
|
52
|
+
'@servicetitan/react': {
|
|
53
|
+
rules: rules.react
|
|
54
|
+
}
|
|
33
55
|
},
|
|
34
|
-
files: [
|
|
56
|
+
files: [
|
|
57
|
+
'**/*.ts',
|
|
58
|
+
'**/*.tsx'
|
|
59
|
+
],
|
|
35
60
|
rules: {
|
|
36
61
|
'@servicetitan/mobx/no-abstract-decorators': 'error',
|
|
37
62
|
'@servicetitan/mobx/use-makeObservable-with-decorators': 'error',
|
|
38
63
|
'@servicetitan/react/destructure-default-import': 'error',
|
|
39
64
|
'@servicetitan/react/no-qualified-type': 'error',
|
|
40
65
|
'@servicetitan/no-async-in-foreach': 'error',
|
|
41
|
-
'@servicetitan/use-declare-with-decorators': 'error'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
66
|
+
'@servicetitan/use-declare-with-decorators': 'error'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
46
71
|
};
|
|
47
|
-
|
|
48
|
-
|
|
72
|
+
const _default = plugin;
|
|
73
|
+
|
|
49
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport { Linter, Rule } from 'eslint';\n\nimport { noAsyncInForEach } from './rules/no-async-in-foreach';\nimport { useDeclareWithDecorators } from './rules/decorators-declare';\nimport { mobxUseMakeObservableWithDecorators } from './rules/mobx/use-makeObservable-with-decorators';\nimport { mobxNoAbstractDecorators } from './rules/mobx/no-abstract-decorators';\nimport { reactDestructureDefaultImport } from './rules/react/destructure-default-import';\nimport { reactNoQualifiedType } from './rules/react/no-qualified-type';\n\nexport const rules: Record<\n 'base' | 'mobx' | 'react',\n Record<string, Rule.RuleModule | AnyRuleModule>\n> = {\n base: {\n 'no-async-in-foreach': noAsyncInForEach,\n 'use-declare-with-decorators': useDeclareWithDecorators,\n },\n mobx: {\n 'use-makeObservable-with-decorators': mobxUseMakeObservableWithDecorators,\n 'no-abstract-decorators': mobxNoAbstractDecorators,\n },\n react: {\n 'destructure-default-import': reactDestructureDefaultImport,\n 'no-qualified-type': reactNoQualifiedType,\n },\n};\n\nconst plugin = {\n configs: {\n recommended: [\n {\n name: '@servicetitan/eslint-plugin',\n plugins: {\n '@servicetitan': { rules: rules.base },\n '@servicetitan/mobx': { rules: rules.mobx },\n '@servicetitan/react': { rules: rules.react },\n },\n files: ['**/*.ts', '**/*.tsx'],\n rules: {\n '@servicetitan/mobx/no-abstract-decorators': 'error',\n '@servicetitan/mobx/use-makeObservable-with-decorators': 'error',\n '@servicetitan/react/destructure-default-import': 'error',\n '@servicetitan/react/no-qualified-type': 'error',\n '@servicetitan/no-async-in-foreach': 'error',\n '@servicetitan/use-declare-with-decorators': 'error',\n },\n } as Linter.Config,\n ],\n },\n};\n\n// eslint-disable-next-line import/no-default-export\nexport default plugin;\n"],"names":["rules","base","noAsyncInForEach","useDeclareWithDecorators","mobx","mobxUseMakeObservableWithDecorators","mobxNoAbstractDecorators","react","reactDestructureDefaultImport","reactNoQualifiedType","plugin","configs","recommended","name","plugins","files"],"mappings":";;;;;;;;;;;QAoDA,oDAAoD;IACpD;eAAA;;QA3CaA;eAAAA;;;kCAPoB;mCACQ;iDACW;sCACX;0CACK;iCACT;AAE9B,MAAMA,QAGT;IACAC,MAAM;QACF,uBAAuBC,kCAAgB;QACvC,+BAA+BC,2CAAwB;IAC3D;IACAC,MAAM;QACF,sCAAsCC,oEAAmC;QACzE,0BAA0BC,8CAAwB;IACtD;IACAC,OAAO;QACH,8BAA8BC,uDAA6B;QAC3D,qBAAqBC,qCAAoB;IAC7C;AACJ;AAEA,MAAMC,SAAS;IACXC,SAAS;QACLC,aAAa;YACT;gBACIC,MAAM;gBACNC,SAAS;oBACL,iBAAiB;wBAAEd,OAAOA,MAAMC,IAAI;oBAAC;oBACrC,sBAAsB;wBAAED,OAAOA,MAAMI,IAAI;oBAAC;oBAC1C,uBAAuB;wBAAEJ,OAAOA,MAAMO,KAAK;oBAAC;gBAChD;gBACAQ,OAAO;oBAAC;oBAAW;iBAAW;gBAC9Bf,OAAO;oBACH,6CAA6C;oBAC7C,yDAAyD;oBACzD,kDAAkD;oBAClD,yCAAyC;oBACzC,qCAAqC;oBACrC,6CAA6C;gBACjD;YACJ;SACH;IACL;AACJ;MAGA,WAAeU"}
|
package/dist/processors/stub.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "stub", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return stub;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const stub = {
|
|
12
|
+
preprocess: ()=>[
|
|
13
|
+
''
|
|
14
|
+
],
|
|
15
|
+
postprocess: ([messages])=>messages
|
|
7
16
|
};
|
|
17
|
+
|
|
8
18
|
//# sourceMappingURL=stub.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/processors/stub.ts"],"sourcesContent":["import type { Linter } from 'eslint';\n\nexport const stub: Linter.LintOptions = {\n preprocess: () => [''],\n postprocess: ([messages]) => messages,\n};\n"],"names":["stub","preprocess","postprocess","messages"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,OAA2B;IACpCC,YAAY,IAAM;YAAC;SAAG;IACtBC,aAAa,CAAC,CAACC,SAAS,GAAKA;AACjC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/*
|
|
4
2
|
* This file is required to test type-aware rules.
|
|
5
3
|
* See https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
6
|
-
*/
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
|
|
7
6
|
//# sourceMappingURL=file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../src/rules/__mocks__/fixture/file.ts"],"sourcesContent":["/*\n * This file is required to test type-aware rules.\n * See https://typescript-eslint.io/packages/rule-tester/#type-aware-testing\n */\n"],"names":[],"mappings":"AAAA;;;CAGC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/*
|
|
4
2
|
* This file is required to test type-aware rules.
|
|
5
3
|
* See https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
6
|
-
*/
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
|
|
7
6
|
//# sourceMappingURL=react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../../src/rules/__mocks__/fixture/react.tsx"],"sourcesContent":["/*\n * This file is required to test type-aware rules.\n * See https://typescript-eslint.io/packages/rule-tester/#type-aware-testing\n */\n"],"names":[],"mappings":"AAAA;;;CAGC"}
|
|
@@ -1,44 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useDeclareWithDecorators", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useDeclareWithDecorators;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const customDecorators = [
|
|
12
|
+
'injectDependency',
|
|
13
|
+
'koObservableToMobx'
|
|
14
|
+
];
|
|
15
|
+
const useDeclareWithDecorators = {
|
|
6
16
|
meta: {
|
|
7
17
|
type: 'problem',
|
|
8
18
|
docs: {
|
|
9
19
|
description: 'Disallow custom @servicetitan class field decorators without declare',
|
|
10
20
|
category: 'Possible Errors',
|
|
11
21
|
recommended: false,
|
|
12
|
-
url: 'https://github.com/servicetitan/uikit.git'
|
|
22
|
+
url: 'https://github.com/servicetitan/uikit.git'
|
|
13
23
|
},
|
|
14
24
|
messages: {
|
|
15
|
-
decoratorsDeclare: "Use declare when decorating with '@{{name}}'"
|
|
16
|
-
}
|
|
25
|
+
decoratorsDeclare: "Use declare when decorating with '@{{name}}'"
|
|
26
|
+
}
|
|
17
27
|
},
|
|
18
|
-
create(context) {
|
|
28
|
+
create (context) {
|
|
19
29
|
return {
|
|
20
|
-
ClassProperty(node) {
|
|
21
|
-
var
|
|
30
|
+
ClassProperty (node) {
|
|
31
|
+
var _node_decorators;
|
|
22
32
|
if (node.declare) {
|
|
23
33
|
return; // field is already defined with declare
|
|
24
34
|
}
|
|
25
|
-
if (
|
|
26
|
-
node.decorators.forEach((decorator)
|
|
27
|
-
var
|
|
28
|
-
const name = (
|
|
35
|
+
if (node === null || node === void 0 ? void 0 : (_node_decorators = node.decorators) === null || _node_decorators === void 0 ? void 0 : _node_decorators.length) {
|
|
36
|
+
node.decorators.forEach((decorator)=>{
|
|
37
|
+
var _decorator_expression_callee, _decorator_expression;
|
|
38
|
+
const name = (_decorator_expression = decorator.expression) === null || _decorator_expression === void 0 ? void 0 : (_decorator_expression_callee = _decorator_expression.callee) === null || _decorator_expression_callee === void 0 ? void 0 : _decorator_expression_callee.name;
|
|
29
39
|
if (name && customDecorators.includes(name)) {
|
|
30
40
|
context.report({
|
|
31
41
|
node,
|
|
32
42
|
messageId: 'decoratorsDeclare',
|
|
33
43
|
data: {
|
|
34
|
-
name
|
|
35
|
-
}
|
|
44
|
+
name
|
|
45
|
+
}
|
|
36
46
|
});
|
|
37
47
|
}
|
|
38
48
|
});
|
|
39
49
|
}
|
|
40
|
-
}
|
|
50
|
+
}
|
|
41
51
|
};
|
|
42
|
-
}
|
|
52
|
+
}
|
|
43
53
|
};
|
|
54
|
+
|
|
44
55
|
//# sourceMappingURL=decorators-declare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/rules/decorators-declare.ts"],"sourcesContent":["import { Rule } from 'eslint';\n\nconst customDecorators = ['injectDependency', 'koObservableToMobx'];\n\nexport const useDeclareWithDecorators: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow custom @servicetitan class field decorators without declare',\n category: 'Possible Errors',\n recommended: false,\n url: 'https://github.com/servicetitan/uikit.git',\n },\n messages: {\n decoratorsDeclare: \"Use declare when decorating with '@{{name}}'\",\n },\n },\n create(context) {\n return {\n ClassProperty(node: any) {\n if (node.declare) {\n return; // field is already defined with declare\n }\n\n if (node?.decorators?.length) {\n node.decorators.forEach((decorator: any) => {\n const name = decorator.expression?.callee?.name;\n\n if (name && customDecorators.includes(name)) {\n context.report({\n node,\n messageId: 'decoratorsDeclare',\n data: {\n name,\n },\n });\n }\n });\n }\n },\n };\n },\n};\n"],"names":["useDeclareWithDecorators","customDecorators","meta","type","docs","description","category","recommended","url","messages","decoratorsDeclare","create","context","ClassProperty","node","declare","decorators","length","forEach","decorator","name","expression","callee","includes","report","messageId","data"],"mappings":";;;;+BAIaA;;;eAAAA;;;AAFb,MAAMC,mBAAmB;IAAC;IAAoB;CAAqB;AAE5D,MAAMD,2BAA4C;IACrDE,MAAM;QACFC,MAAM;QACNC,MAAM;YACFC,aAAa;YACbC,UAAU;YACVC,aAAa;YACbC,KAAK;QACT;QACAC,UAAU;YACNC,mBAAmB;QACvB;IACJ;IACAC,QAAOC,OAAO;QACV,OAAO;YACHC,eAAcC,IAAS;oBAKfA;gBAJJ,IAAIA,KAAKC,OAAO,EAAE;oBACd,QAAQ,wCAAwC;gBACpD;gBAEA,IAAID,iBAAAA,4BAAAA,mBAAAA,KAAME,UAAU,cAAhBF,uCAAAA,iBAAkBG,MAAM,EAAE;oBAC1BH,KAAKE,UAAU,CAACE,OAAO,CAAC,CAACC;4BACRA,8BAAAA;wBAAb,MAAMC,QAAOD,wBAAAA,UAAUE,UAAU,cAApBF,6CAAAA,+BAAAA,sBAAsBG,MAAM,cAA5BH,mDAAAA,6BAA8BC,IAAI;wBAE/C,IAAIA,QAAQnB,iBAAiBsB,QAAQ,CAACH,OAAO;4BACzCR,QAAQY,MAAM,CAAC;gCACXV;gCACAW,WAAW;gCACXC,MAAM;oCACFN;gCACJ;4BACJ;wBACJ;oBACJ;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "mobxNoAbstractDecorators", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return mobxNoAbstractDecorators;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const mobxDecorators = [
|
|
12
|
+
'observable',
|
|
13
|
+
'action',
|
|
14
|
+
'computed',
|
|
15
|
+
'override'
|
|
16
|
+
];
|
|
17
|
+
const mobxNoAbstractDecorators = {
|
|
6
18
|
meta: {
|
|
7
19
|
type: 'problem',
|
|
8
20
|
docs: {
|
|
9
21
|
description: 'Disallow MobX decorators on abstract class fields',
|
|
10
22
|
category: 'Possible Errors',
|
|
11
23
|
recommended: false,
|
|
12
|
-
url: 'https://github.com/servicetitan/uikit.git'
|
|
24
|
+
url: 'https://github.com/servicetitan/uikit.git'
|
|
13
25
|
},
|
|
14
26
|
messages: {
|
|
15
|
-
noAbstractMobxDecorators: "Don't decorate abstract class fields or methods with '@{{name}}'"
|
|
16
|
-
}
|
|
27
|
+
noAbstractMobxDecorators: "Don't decorate abstract class fields or methods with '@{{name}}'"
|
|
28
|
+
}
|
|
17
29
|
},
|
|
18
|
-
create(context) {
|
|
30
|
+
create (context) {
|
|
19
31
|
function checkFn(node) {
|
|
20
|
-
var
|
|
21
|
-
if (
|
|
22
|
-
node.decorators.forEach((decorator)
|
|
23
|
-
var
|
|
32
|
+
var _node_decorators;
|
|
33
|
+
if (node === null || node === void 0 ? void 0 : (_node_decorators = node.decorators) === null || _node_decorators === void 0 ? void 0 : _node_decorators.length) {
|
|
34
|
+
node.decorators.forEach((decorator)=>{
|
|
35
|
+
var _decorator_expression, _decorator_expression_object, _decorator_expression1;
|
|
24
36
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
25
|
-
const name = (
|
|
37
|
+
const name = (decorator === null || decorator === void 0 ? void 0 : (_decorator_expression = decorator.expression) === null || _decorator_expression === void 0 ? void 0 : _decorator_expression.name) || (decorator === null || decorator === void 0 ? void 0 : (_decorator_expression1 = decorator.expression) === null || _decorator_expression1 === void 0 ? void 0 : (_decorator_expression_object = _decorator_expression1.object) === null || _decorator_expression_object === void 0 ? void 0 : _decorator_expression_object.name);
|
|
26
38
|
if (name && mobxDecorators.includes(name)) {
|
|
27
39
|
context.report({
|
|
28
40
|
node,
|
|
29
41
|
messageId: 'noAbstractMobxDecorators',
|
|
30
42
|
data: {
|
|
31
|
-
name
|
|
32
|
-
}
|
|
43
|
+
name
|
|
44
|
+
}
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
47
|
});
|
|
@@ -37,8 +49,9 @@ exports.mobxNoAbstractDecorators = {
|
|
|
37
49
|
}
|
|
38
50
|
return {
|
|
39
51
|
TSAbstractClassProperty: checkFn,
|
|
40
|
-
TSAbstractMethodDefinition: checkFn
|
|
52
|
+
TSAbstractMethodDefinition: checkFn
|
|
41
53
|
};
|
|
42
|
-
}
|
|
54
|
+
}
|
|
43
55
|
};
|
|
56
|
+
|
|
44
57
|
//# sourceMappingURL=no-abstract-decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/rules/mobx/no-abstract-decorators.ts"],"sourcesContent":["import { Rule } from 'eslint';\n\nconst mobxDecorators = ['observable', 'action', 'computed', 'override'];\n\nexport const mobxNoAbstractDecorators: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow MobX decorators on abstract class fields',\n category: 'Possible Errors',\n recommended: false,\n url: 'https://github.com/servicetitan/uikit.git',\n },\n messages: {\n noAbstractMobxDecorators:\n \"Don't decorate abstract class fields or methods with '@{{name}}'\",\n },\n },\n create(context: any) {\n function checkFn(node: any) {\n if (node?.decorators?.length) {\n node.decorators.forEach((decorator: any) => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n const name = decorator?.expression?.name || decorator?.expression?.object?.name;\n\n if (name && mobxDecorators.includes(name)) {\n context.report({\n node,\n messageId: 'noAbstractMobxDecorators',\n data: {\n name,\n },\n });\n }\n });\n }\n }\n\n return {\n TSAbstractClassProperty: checkFn,\n TSAbstractMethodDefinition: checkFn,\n };\n },\n};\n"],"names":["mobxNoAbstractDecorators","mobxDecorators","meta","type","docs","description","category","recommended","url","messages","noAbstractMobxDecorators","create","context","checkFn","node","decorators","length","forEach","decorator","name","expression","object","includes","report","messageId","data","TSAbstractClassProperty","TSAbstractMethodDefinition"],"mappings":";;;;+BAIaA;;;eAAAA;;;AAFb,MAAMC,iBAAiB;IAAC;IAAc;IAAU;IAAY;CAAW;AAEhE,MAAMD,2BAA4C;IACrDE,MAAM;QACFC,MAAM;QACNC,MAAM;YACFC,aAAa;YACbC,UAAU;YACVC,aAAa;YACbC,KAAK;QACT;QACAC,UAAU;YACNC,0BACI;QACR;IACJ;IACAC,QAAOC,OAAY;QACf,SAASC,QAAQC,IAAS;gBAClBA;YAAJ,IAAIA,iBAAAA,4BAAAA,mBAAAA,KAAMC,UAAU,cAAhBD,uCAAAA,iBAAkBE,MAAM,EAAE;gBAC1BF,KAAKC,UAAU,CAACE,OAAO,CAAC,CAACC;wBAERA,uBAA+BA,8BAAAA;oBAD5C,wEAAwE;oBACxE,MAAMC,OAAOD,CAAAA,sBAAAA,iCAAAA,wBAAAA,UAAWE,UAAU,cAArBF,4CAAAA,sBAAuBC,IAAI,MAAID,sBAAAA,iCAAAA,yBAAAA,UAAWE,UAAU,cAArBF,8CAAAA,+BAAAA,uBAAuBG,MAAM,cAA7BH,mDAAAA,6BAA+BC,IAAI;oBAE/E,IAAIA,QAAQlB,eAAeqB,QAAQ,CAACH,OAAO;wBACvCP,QAAQW,MAAM,CAAC;4BACXT;4BACAU,WAAW;4BACXC,MAAM;gCACFN;4BACJ;wBACJ;oBACJ;gBACJ;YACJ;QACJ;QAEA,OAAO;YACHO,yBAAyBb;YACzBc,4BAA4Bd;QAChC;IACJ;AACJ"}
|
|
@@ -1,46 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "mobxUseMakeObservableWithDecorators", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return mobxUseMakeObservableWithDecorators;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
4
11
|
// NOTE: "action" also covers "action.bound"
|
|
5
|
-
const mobxDecorators = [
|
|
6
|
-
|
|
12
|
+
const mobxDecorators = [
|
|
13
|
+
'observable',
|
|
14
|
+
'action',
|
|
15
|
+
'computed',
|
|
16
|
+
'override'
|
|
17
|
+
];
|
|
18
|
+
const mobxUseMakeObservableWithDecorators = {
|
|
7
19
|
meta: {
|
|
8
20
|
type: 'problem',
|
|
9
21
|
docs: {
|
|
10
22
|
description: 'Testing makeObservable used with decorators',
|
|
11
23
|
category: 'Possible Errors',
|
|
12
24
|
recommended: false,
|
|
13
|
-
url: 'https://github.com/servicetitan/uikit.git'
|
|
25
|
+
url: 'https://github.com/servicetitan/uikit.git'
|
|
14
26
|
},
|
|
15
27
|
messages: {
|
|
16
28
|
makeObservable: 'Use makeObservable in the constructor with MobX decorators',
|
|
17
|
-
constructor: 'Add constructor with makeObservable when using MobX decorators'
|
|
18
|
-
}
|
|
29
|
+
constructor: 'Add constructor with makeObservable when using MobX decorators'
|
|
30
|
+
}
|
|
19
31
|
},
|
|
20
|
-
create(context) {
|
|
32
|
+
create (context) {
|
|
21
33
|
return {
|
|
22
|
-
ClassDeclaration(node) {
|
|
34
|
+
ClassDeclaration (node) {
|
|
23
35
|
let hasMobxDecorator = false;
|
|
24
36
|
let hasConstructor = false;
|
|
25
37
|
let hasMakeObservable = false;
|
|
26
|
-
node.body.body.forEach((methodOrProperty)
|
|
27
|
-
var _a, _b;
|
|
38
|
+
node.body.body.forEach((methodOrProperty)=>{
|
|
28
39
|
if (methodOrProperty.decorators) {
|
|
29
|
-
methodOrProperty.decorators.forEach((decorator)
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
((_a = decorator === null || decorator === void 0 ? void 0 : decorator.expression) === null || _a === void 0 ? void 0 : _a.name) ||
|
|
34
|
-
((_c = (_b = decorator === null || decorator === void 0 ? void 0 : decorator.expression) === null || _b === void 0 ? void 0 : _b.object) === null || _c === void 0 ? void 0 : _c.name))) {
|
|
40
|
+
methodOrProperty.decorators.forEach((decorator)=>{
|
|
41
|
+
var // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
42
|
+
_decorator_expression, _decorator_expression_object, _decorator_expression1;
|
|
43
|
+
if (mobxDecorators.includes((decorator === null || decorator === void 0 ? void 0 : (_decorator_expression = decorator.expression) === null || _decorator_expression === void 0 ? void 0 : _decorator_expression.name) || (decorator === null || decorator === void 0 ? void 0 : (_decorator_expression1 = decorator.expression) === null || _decorator_expression1 === void 0 ? void 0 : (_decorator_expression_object = _decorator_expression1.object) === null || _decorator_expression_object === void 0 ? void 0 : _decorator_expression_object.name))) {
|
|
35
44
|
hasMobxDecorator = true;
|
|
36
45
|
}
|
|
37
46
|
});
|
|
38
47
|
}
|
|
39
48
|
if (methodOrProperty.kind === 'constructor') {
|
|
49
|
+
var _methodOrProperty_value_body, _methodOrProperty_value;
|
|
40
50
|
hasConstructor = true;
|
|
41
|
-
(
|
|
42
|
-
var
|
|
43
|
-
if ((
|
|
51
|
+
(_methodOrProperty_value = methodOrProperty.value) === null || _methodOrProperty_value === void 0 ? void 0 : (_methodOrProperty_value_body = _methodOrProperty_value.body) === null || _methodOrProperty_value_body === void 0 ? void 0 : _methodOrProperty_value_body.body.forEach((statement)=>{
|
|
52
|
+
var _statement_expression_callee, _statement_expression;
|
|
53
|
+
if ((statement === null || statement === void 0 ? void 0 : (_statement_expression = statement.expression) === null || _statement_expression === void 0 ? void 0 : (_statement_expression_callee = _statement_expression.callee) === null || _statement_expression_callee === void 0 ? void 0 : _statement_expression_callee.name) === 'makeObservable') {
|
|
44
54
|
hasMakeObservable = true;
|
|
45
55
|
}
|
|
46
56
|
});
|
|
@@ -49,17 +59,18 @@ exports.mobxUseMakeObservableWithDecorators = {
|
|
|
49
59
|
if (hasMobxDecorator && !hasMakeObservable && hasConstructor) {
|
|
50
60
|
context.report({
|
|
51
61
|
node,
|
|
52
|
-
messageId: 'makeObservable'
|
|
62
|
+
messageId: 'makeObservable'
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
if (hasMobxDecorator && !hasMakeObservable && !hasConstructor) {
|
|
56
66
|
context.report({
|
|
57
67
|
node,
|
|
58
|
-
messageId: 'constructor'
|
|
68
|
+
messageId: 'constructor'
|
|
59
69
|
});
|
|
60
70
|
}
|
|
61
|
-
}
|
|
71
|
+
}
|
|
62
72
|
};
|
|
63
|
-
}
|
|
73
|
+
}
|
|
64
74
|
};
|
|
75
|
+
|
|
65
76
|
//# sourceMappingURL=use-makeObservable-with-decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/rules/mobx/use-makeObservable-with-decorators.ts"],"sourcesContent":["import { Rule } from 'eslint';\n\n// NOTE: \"action\" also covers \"action.bound\"\nconst mobxDecorators = ['observable', 'action', 'computed', 'override'];\n\nexport const mobxUseMakeObservableWithDecorators: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Testing makeObservable used with decorators',\n category: 'Possible Errors',\n recommended: false,\n url: 'https://github.com/servicetitan/uikit.git',\n },\n messages: {\n makeObservable: 'Use makeObservable in the constructor with MobX decorators',\n constructor: 'Add constructor with makeObservable when using MobX decorators',\n },\n },\n create(context) {\n return {\n ClassDeclaration(node) {\n let hasMobxDecorator = false;\n let hasConstructor = false;\n let hasMakeObservable = false;\n\n node.body.body.forEach((methodOrProperty: any) => {\n if (methodOrProperty.decorators) {\n methodOrProperty.decorators.forEach((decorator: any) => {\n if (\n mobxDecorators.includes(\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n decorator?.expression?.name ||\n decorator?.expression?.object?.name\n )\n ) {\n hasMobxDecorator = true;\n }\n });\n }\n\n if (methodOrProperty.kind === 'constructor') {\n hasConstructor = true;\n\n methodOrProperty.value?.body?.body.forEach((statement: any) => {\n if (statement?.expression?.callee?.name === 'makeObservable') {\n hasMakeObservable = true;\n }\n });\n }\n });\n\n if (hasMobxDecorator && !hasMakeObservable && hasConstructor) {\n context.report({\n node,\n messageId: 'makeObservable',\n });\n }\n\n if (hasMobxDecorator && !hasMakeObservable && !hasConstructor) {\n context.report({\n node,\n messageId: 'constructor',\n });\n }\n },\n };\n },\n};\n"],"names":["mobxUseMakeObservableWithDecorators","mobxDecorators","meta","type","docs","description","category","recommended","url","messages","makeObservable","constructor","create","context","ClassDeclaration","node","hasMobxDecorator","hasConstructor","hasMakeObservable","body","forEach","methodOrProperty","decorators","decorator","includes","expression","name","object","kind","value","statement","callee","report","messageId"],"mappings":";;;;+BAKaA;;;eAAAA;;;AAHb,4CAA4C;AAC5C,MAAMC,iBAAiB;IAAC;IAAc;IAAU;IAAY;CAAW;AAEhE,MAAMD,sCAAuD;IAChEE,MAAM;QACFC,MAAM;QACNC,MAAM;YACFC,aAAa;YACbC,UAAU;YACVC,aAAa;YACbC,KAAK;QACT;QACAC,UAAU;YACNC,gBAAgB;YAChBC,aAAa;QACjB;IACJ;IACAC,QAAOC,OAAO;QACV,OAAO;YACHC,kBAAiBC,IAAI;gBACjB,IAAIC,mBAAmB;gBACvB,IAAIC,iBAAiB;gBACrB,IAAIC,oBAAoB;gBAExBH,KAAKI,IAAI,CAACA,IAAI,CAACC,OAAO,CAAC,CAACC;oBACpB,IAAIA,iBAAiBC,UAAU,EAAE;wBAC7BD,iBAAiBC,UAAU,CAACF,OAAO,CAAC,CAACG;gCAGzB,wEAAwE;4BACxEA,uBACIA,8BAAAA;4BAJZ,IACItB,eAAeuB,QAAQ,CAEnBD,CAAAA,sBAAAA,iCAAAA,wBAAAA,UAAWE,UAAU,cAArBF,4CAAAA,sBAAuBG,IAAI,MACvBH,sBAAAA,iCAAAA,yBAAAA,UAAWE,UAAU,cAArBF,8CAAAA,+BAAAA,uBAAuBI,MAAM,cAA7BJ,mDAAAA,6BAA+BG,IAAI,IAE7C;gCACEV,mBAAmB;4BACvB;wBACJ;oBACJ;oBAEA,IAAIK,iBAAiBO,IAAI,KAAK,eAAe;4BAGzCP,8BAAAA;wBAFAJ,iBAAiB;yBAEjBI,0BAAAA,iBAAiBQ,KAAK,cAAtBR,+CAAAA,+BAAAA,wBAAwBF,IAAI,cAA5BE,mDAAAA,6BAA8BF,IAAI,CAACC,OAAO,CAAC,CAACU;gCACpCA,8BAAAA;4BAAJ,IAAIA,CAAAA,sBAAAA,iCAAAA,wBAAAA,UAAWL,UAAU,cAArBK,6CAAAA,+BAAAA,sBAAuBC,MAAM,cAA7BD,mDAAAA,6BAA+BJ,IAAI,MAAK,kBAAkB;gCAC1DR,oBAAoB;4BACxB;wBACJ;oBACJ;gBACJ;gBAEA,IAAIF,oBAAoB,CAACE,qBAAqBD,gBAAgB;oBAC1DJ,QAAQmB,MAAM,CAAC;wBACXjB;wBACAkB,WAAW;oBACf;gBACJ;gBAEA,IAAIjB,oBAAoB,CAACE,qBAAqB,CAACD,gBAAgB;oBAC3DJ,QAAQmB,MAAM,CAAC;wBACXjB;wBACAkB,WAAW;oBACf;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "noAsyncInForEach", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return noAsyncInForEach;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _utils = require("@typescript-eslint/utils");
|
|
12
|
+
const _typescript = /*#__PURE__*/ _interop_require_default(require("typescript"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
8
18
|
const { getParserServices } = require('@typescript-eslint/utils/eslint-utils');
|
|
9
19
|
const { containsAllTypesByName } = require('@typescript-eslint/type-utils');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
create(context) {
|
|
20
|
+
const createRule = _utils.ESLintUtils.RuleCreator((_name)=>'https://gist.github.com/joeytwiddle/37d2085425c049629b80956d3c618971');
|
|
21
|
+
const noAsyncInForEach = createRule({
|
|
22
|
+
create (context) {
|
|
14
23
|
const services = getParserServices(context);
|
|
15
24
|
const checker = services.program.getTypeChecker();
|
|
16
25
|
function checkForEachExpression(node) {
|
|
@@ -22,57 +31,63 @@ exports.noAsyncInForEach = createRule({
|
|
|
22
31
|
if (!isArrayLike(callee.object)) {
|
|
23
32
|
return;
|
|
24
33
|
}
|
|
25
|
-
context.report({
|
|
34
|
+
context.report({
|
|
35
|
+
messageId: 'noAsyncInForEach',
|
|
36
|
+
node
|
|
37
|
+
});
|
|
26
38
|
}
|
|
27
39
|
function getSymbolAtLocation(node) {
|
|
28
40
|
const symbol = services.getSymbolAtLocation(node);
|
|
29
|
-
if (symbol && symbol.flags &
|
|
41
|
+
if (symbol && symbol.flags & _typescript.default.SymbolFlags.Alias) {
|
|
30
42
|
return checker.getAliasedSymbol(symbol);
|
|
31
43
|
}
|
|
32
44
|
return symbol;
|
|
33
45
|
}
|
|
34
46
|
function isArrayLike(node) {
|
|
35
47
|
const nodeType = services.getTypeAtLocation(node);
|
|
36
|
-
const types = isUnionType(nodeType) ? nodeType.types : [
|
|
37
|
-
|
|
48
|
+
const types = isUnionType(nodeType) ? nodeType.types : [
|
|
49
|
+
nodeType
|
|
50
|
+
];
|
|
51
|
+
return types.some((type)=>checker.isArrayType(type) || checker.isTupleType(type));
|
|
38
52
|
}
|
|
39
53
|
function isAsync(node) {
|
|
40
|
-
return
|
|
41
|
-
hasAsyncModifier(getSymbolAtLocation(node)) ||
|
|
42
|
-
returnsPromise(node));
|
|
54
|
+
return node.type === _utils.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression && node.async || hasAsyncModifier(getSymbolAtLocation(node)) || returnsPromise(node);
|
|
43
55
|
}
|
|
44
56
|
function isUnionType(type) {
|
|
45
|
-
return (type.flags &
|
|
57
|
+
return (type.flags & _typescript.default.TypeFlags.Union) !== 0;
|
|
46
58
|
}
|
|
47
59
|
function hasAsyncModifier(symbol) {
|
|
48
|
-
var
|
|
49
|
-
return !!(
|
|
50
|
-
var
|
|
51
|
-
return (
|
|
60
|
+
var _symbol_declarations;
|
|
61
|
+
return !!(symbol === null || symbol === void 0 ? void 0 : (_symbol_declarations = symbol.declarations) === null || _symbol_declarations === void 0 ? void 0 : _symbol_declarations.find((declaration)=>{
|
|
62
|
+
var _declaration_modifiers;
|
|
63
|
+
return (_declaration_modifiers = declaration.modifiers) === null || _declaration_modifiers === void 0 ? void 0 : _declaration_modifiers.find((modifier)=>modifier.kind === _typescript.default.SyntaxKind.AsyncKeyword);
|
|
52
64
|
}));
|
|
53
65
|
}
|
|
54
66
|
function returnsPromise(node) {
|
|
55
67
|
const signatures = services.getTypeAtLocation(node).getCallSignatures();
|
|
56
68
|
if (signatures.length) {
|
|
57
69
|
const returnType = checker.getReturnTypeOfSignature(signatures[0]);
|
|
58
|
-
return containsAllTypesByName(returnType, true, new Set([
|
|
70
|
+
return containsAllTypesByName(returnType, true, new Set([
|
|
71
|
+
'Promise'
|
|
72
|
+
]));
|
|
59
73
|
}
|
|
60
74
|
}
|
|
61
75
|
return {
|
|
62
|
-
"CallExpression[arguments.length=1] > MemberExpression[property.name='forEach']": checkForEachExpression
|
|
76
|
+
"CallExpression[arguments.length=1] > MemberExpression[property.name='forEach']": checkForEachExpression
|
|
63
77
|
};
|
|
64
78
|
},
|
|
65
79
|
name: 'no-async-in-foreach',
|
|
66
80
|
meta: {
|
|
67
81
|
docs: {
|
|
68
|
-
description: 'Disallow passing asynchronous callback to Array.forEach'
|
|
82
|
+
description: 'Disallow passing asynchronous callback to Array.forEach'
|
|
69
83
|
},
|
|
70
84
|
messages: {
|
|
71
|
-
noAsyncInForEach: 'Async callback passed to Array.forEach'
|
|
85
|
+
noAsyncInForEach: 'Async callback passed to Array.forEach'
|
|
72
86
|
},
|
|
73
87
|
type: 'problem',
|
|
74
|
-
schema: []
|
|
88
|
+
schema: []
|
|
75
89
|
},
|
|
76
|
-
defaultOptions: []
|
|
90
|
+
defaultOptions: []
|
|
77
91
|
});
|
|
92
|
+
|
|
78
93
|
//# sourceMappingURL=no-async-in-foreach.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/rules/no-async-in-foreach.ts"],"sourcesContent":["import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';\nconst { getParserServices } = require('@typescript-eslint/utils/eslint-utils');\nconst { containsAllTypesByName } = require('@typescript-eslint/type-utils');\nimport ts, { ParameterDeclaration, TypeChecker } from 'typescript';\n\nconst createRule = ESLintUtils.RuleCreator(\n _name => 'https://gist.github.com/joeytwiddle/37d2085425c049629b80956d3c618971'\n);\n\nexport const noAsyncInForEach = createRule({\n create(context) {\n const services = getParserServices(context);\n const checker = services.program.getTypeChecker() as TypeChecker & {\n // Type declarations aren't in 4.x. See https://github.com/microsoft/TypeScript/pull/52467\n isArrayType: (type: ts.Type) => boolean;\n isTupleType: (type: ts.Type) => boolean;\n };\n\n function checkForEachExpression(node: TSESTree.MemberExpression) {\n const callExpression = node.parent as TSESTree.CallExpression;\n if (!isAsync(callExpression.arguments[0])) {\n return;\n }\n\n const callee = callExpression.callee as TSESTree.MemberExpression;\n if (!isArrayLike(callee.object)) {\n return;\n }\n\n context.report({ messageId: 'noAsyncInForEach', node });\n }\n\n function getSymbolAtLocation(node: TSESTree.Node) {\n const symbol = services.getSymbolAtLocation(node);\n if (symbol && symbol.flags & ts.SymbolFlags.Alias) {\n return checker.getAliasedSymbol(symbol);\n }\n return symbol;\n }\n\n function isArrayLike(node: TSESTree.Node) {\n const nodeType = services.getTypeAtLocation(node);\n const types = isUnionType(nodeType) ? nodeType.types : [nodeType];\n return types.some(type => checker.isArrayType(type) || checker.isTupleType(type));\n }\n\n function isAsync(node: TSESTree.Node) {\n return (\n (node.type === TSESTree.AST_NODE_TYPES.ArrowFunctionExpression && node.async) ||\n hasAsyncModifier(getSymbolAtLocation(node)) ||\n returnsPromise(node)\n );\n }\n\n function isUnionType(type: ts.Type): type is ts.UnionType {\n return (type.flags & ts.TypeFlags.Union) !== 0;\n }\n\n function hasAsyncModifier(symbol?: ts.Symbol) {\n return !!symbol?.declarations?.find((declaration: ParameterDeclaration) =>\n declaration.modifiers?.find(\n modifier => modifier.kind === ts.SyntaxKind.AsyncKeyword\n )\n );\n }\n\n function returnsPromise(node: TSESTree.Node) {\n const signatures = services.getTypeAtLocation(node).getCallSignatures();\n if (signatures.length) {\n const returnType = checker.getReturnTypeOfSignature(signatures[0]);\n return containsAllTypesByName(returnType, true, new Set(['Promise']));\n }\n }\n\n return {\n \"CallExpression[arguments.length=1] > MemberExpression[property.name='forEach']\":\n checkForEachExpression,\n };\n },\n name: 'no-async-in-foreach',\n meta: {\n docs: {\n description: 'Disallow passing asynchronous callback to Array.forEach',\n },\n messages: {\n noAsyncInForEach: 'Async callback passed to Array.forEach',\n },\n type: 'problem',\n schema: [],\n },\n defaultOptions: [],\n});\n"],"names":["noAsyncInForEach","getParserServices","require","containsAllTypesByName","createRule","ESLintUtils","RuleCreator","_name","create","context","services","checker","program","getTypeChecker","checkForEachExpression","node","callExpression","parent","isAsync","arguments","callee","isArrayLike","object","report","messageId","getSymbolAtLocation","symbol","flags","ts","SymbolFlags","Alias","getAliasedSymbol","nodeType","getTypeAtLocation","types","isUnionType","some","type","isArrayType","isTupleType","TSESTree","AST_NODE_TYPES","ArrowFunctionExpression","async","hasAsyncModifier","returnsPromise","TypeFlags","Union","declarations","find","declaration","modifiers","modifier","kind","SyntaxKind","AsyncKeyword","signatures","getCallSignatures","length","returnType","getReturnTypeOfSignature","Set","name","meta","docs","description","messages","schema","defaultOptions"],"mappings":";;;;+BASaA;;;eAAAA;;;uBATyB;mEAGgB;;;;;;AAFtD,MAAM,EAAEC,iBAAiB,EAAE,GAAGC,QAAQ;AACtC,MAAM,EAAEC,sBAAsB,EAAE,GAAGD,QAAQ;AAG3C,MAAME,aAAaC,kBAAW,CAACC,WAAW,CACtCC,CAAAA,QAAS;AAGN,MAAMP,mBAAmBI,WAAW;IACvCI,QAAOC,OAAO;QACV,MAAMC,WAAWT,kBAAkBQ;QACnC,MAAME,UAAUD,SAASE,OAAO,CAACC,cAAc;QAM/C,SAASC,uBAAuBC,IAA+B;YAC3D,MAAMC,iBAAiBD,KAAKE,MAAM;YAClC,IAAI,CAACC,QAAQF,eAAeG,SAAS,CAAC,EAAE,GAAG;gBACvC;YACJ;YAEA,MAAMC,SAASJ,eAAeI,MAAM;YACpC,IAAI,CAACC,YAAYD,OAAOE,MAAM,GAAG;gBAC7B;YACJ;YAEAb,QAAQc,MAAM,CAAC;gBAAEC,WAAW;gBAAoBT;YAAK;QACzD;QAEA,SAASU,oBAAoBV,IAAmB;YAC5C,MAAMW,SAAShB,SAASe,mBAAmB,CAACV;YAC5C,IAAIW,UAAUA,OAAOC,KAAK,GAAGC,mBAAE,CAACC,WAAW,CAACC,KAAK,EAAE;gBAC/C,OAAOnB,QAAQoB,gBAAgB,CAACL;YACpC;YACA,OAAOA;QACX;QAEA,SAASL,YAAYN,IAAmB;YACpC,MAAMiB,WAAWtB,SAASuB,iBAAiB,CAAClB;YAC5C,MAAMmB,QAAQC,YAAYH,YAAYA,SAASE,KAAK,GAAG;gBAACF;aAAS;YACjE,OAAOE,MAAME,IAAI,CAACC,CAAAA,OAAQ1B,QAAQ2B,WAAW,CAACD,SAAS1B,QAAQ4B,WAAW,CAACF;QAC/E;QAEA,SAASnB,QAAQH,IAAmB;YAChC,OACI,AAACA,KAAKsB,IAAI,KAAKG,eAAQ,CAACC,cAAc,CAACC,uBAAuB,IAAI3B,KAAK4B,KAAK,IAC5EC,iBAAiBnB,oBAAoBV,UACrC8B,eAAe9B;QAEvB;QAEA,SAASoB,YAAYE,IAAa;YAC9B,OAAO,AAACA,CAAAA,KAAKV,KAAK,GAAGC,mBAAE,CAACkB,SAAS,CAACC,KAAK,AAAD,MAAO;QACjD;QAEA,SAASH,iBAAiBlB,MAAkB;gBAC/BA;YAAT,OAAO,CAAC,EAACA,mBAAAA,8BAAAA,uBAAAA,OAAQsB,YAAY,cAApBtB,2CAAAA,qBAAsBuB,IAAI,CAAC,CAACC;oBACjCA;wBAAAA,yBAAAA,YAAYC,SAAS,cAArBD,6CAAAA,uBAAuBD,IAAI,CACvBG,CAAAA,WAAYA,SAASC,IAAI,KAAKzB,mBAAE,CAAC0B,UAAU,CAACC,YAAY;;QAGpE;QAEA,SAASV,eAAe9B,IAAmB;YACvC,MAAMyC,aAAa9C,SAASuB,iBAAiB,CAAClB,MAAM0C,iBAAiB;YACrE,IAAID,WAAWE,MAAM,EAAE;gBACnB,MAAMC,aAAahD,QAAQiD,wBAAwB,CAACJ,UAAU,CAAC,EAAE;gBACjE,OAAOrD,uBAAuBwD,YAAY,MAAM,IAAIE,IAAI;oBAAC;iBAAU;YACvE;QACJ;QAEA,OAAO;YACH,kFACI/C;QACR;IACJ;IACAgD,MAAM;IACNC,MAAM;QACFC,MAAM;YACFC,aAAa;QACjB;QACAC,UAAU;YACNlE,kBAAkB;QACtB;QACAqC,MAAM;QACN8B,QAAQ,EAAE;IACd;IACAC,gBAAgB,EAAE;AACtB"}
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "reactDestructureDefaultImport", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return reactDestructureDefaultImport;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const reactDestructureDefaultImport = {
|
|
5
12
|
meta: {
|
|
6
13
|
type: 'suggestion',
|
|
7
14
|
docs: {
|
|
8
15
|
description: "Disallow importing React's default export",
|
|
9
16
|
category: 'Best Practices',
|
|
10
17
|
recommended: false,
|
|
11
|
-
url: 'https://github.com/servicetitan/uikit.git'
|
|
18
|
+
url: 'https://github.com/servicetitan/uikit.git'
|
|
12
19
|
},
|
|
13
20
|
messages: {
|
|
14
|
-
importDefault: 'Avoid importing React default export'
|
|
15
|
-
}
|
|
21
|
+
importDefault: 'Avoid importing React default export'
|
|
22
|
+
}
|
|
16
23
|
},
|
|
17
|
-
create(context) {
|
|
24
|
+
create (context) {
|
|
18
25
|
return {
|
|
19
|
-
ImportDeclaration(node) {
|
|
26
|
+
ImportDeclaration (node) {
|
|
20
27
|
if (node.source.value !== 'react') {
|
|
21
28
|
return;
|
|
22
29
|
}
|
|
23
|
-
node.specifiers.forEach(specifier
|
|
24
|
-
if (specifier.type === 'ImportDefaultSpecifier' ||
|
|
25
|
-
specifier.type === 'ImportNamespaceSpecifier') {
|
|
30
|
+
node.specifiers.forEach((specifier)=>{
|
|
31
|
+
if (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {
|
|
26
32
|
context.report({
|
|
27
33
|
node,
|
|
28
|
-
messageId: 'importDefault'
|
|
34
|
+
messageId: 'importDefault'
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
37
|
});
|
|
32
|
-
}
|
|
38
|
+
}
|
|
33
39
|
};
|
|
34
|
-
}
|
|
40
|
+
}
|
|
35
41
|
};
|
|
42
|
+
|
|
36
43
|
//# sourceMappingURL=destructure-default-import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/rules/react/destructure-default-import.ts"],"sourcesContent":["import { Rule } from 'eslint';\n\nexport const reactDestructureDefaultImport: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: \"Disallow importing React's default export\",\n category: 'Best Practices',\n recommended: false,\n url: 'https://github.com/servicetitan/uikit.git',\n },\n messages: {\n importDefault: 'Avoid importing React default export',\n },\n },\n create(context) {\n return {\n ImportDeclaration(node) {\n if (node.source.value !== 'react') {\n return;\n }\n\n node.specifiers.forEach(specifier => {\n if (\n specifier.type === 'ImportDefaultSpecifier' ||\n specifier.type === 'ImportNamespaceSpecifier'\n ) {\n context.report({\n node,\n messageId: 'importDefault',\n });\n }\n });\n },\n };\n },\n};\n"],"names":["reactDestructureDefaultImport","meta","type","docs","description","category","recommended","url","messages","importDefault","create","context","ImportDeclaration","node","source","value","specifiers","forEach","specifier","report","messageId"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,gCAAiD;IAC1DC,MAAM;QACFC,MAAM;QACNC,MAAM;YACFC,aAAa;YACbC,UAAU;YACVC,aAAa;YACbC,KAAK;QACT;QACAC,UAAU;YACNC,eAAe;QACnB;IACJ;IACAC,QAAOC,OAAO;QACV,OAAO;YACHC,mBAAkBC,IAAI;gBAClB,IAAIA,KAAKC,MAAM,CAACC,KAAK,KAAK,SAAS;oBAC/B;gBACJ;gBAEAF,KAAKG,UAAU,CAACC,OAAO,CAACC,CAAAA;oBACpB,IACIA,UAAUhB,IAAI,KAAK,4BACnBgB,UAAUhB,IAAI,KAAK,4BACrB;wBACES,QAAQQ,MAAM,CAAC;4BACXN;4BACAO,WAAW;wBACf;oBACJ;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "reactNoQualifiedType", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return reactNoQualifiedType;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const reactNoQualifiedType = {
|
|
5
12
|
meta: {
|
|
6
13
|
type: 'suggestion',
|
|
7
14
|
docs: {
|
|
8
15
|
description: 'Disallow using React types from default export',
|
|
9
16
|
category: 'Best Practices',
|
|
10
17
|
recommended: false,
|
|
11
|
-
url: 'https://github.com/servicetitan/uikit.git'
|
|
18
|
+
url: 'https://github.com/servicetitan/uikit.git'
|
|
12
19
|
},
|
|
13
20
|
messages: {
|
|
14
|
-
importDefault: "Import {{right}} from 'react' instead of using React.{{right}}"
|
|
15
|
-
}
|
|
21
|
+
importDefault: "Import {{right}} from 'react' instead of using React.{{right}}"
|
|
22
|
+
}
|
|
16
23
|
},
|
|
17
|
-
create(context) {
|
|
24
|
+
create (context) {
|
|
18
25
|
return {
|
|
19
|
-
TSQualifiedName(node) {
|
|
26
|
+
TSQualifiedName (node) {
|
|
20
27
|
if (node.left && node.left.name === 'React') {
|
|
21
28
|
context.report({
|
|
22
29
|
node,
|
|
23
30
|
messageId: 'importDefault',
|
|
24
31
|
data: {
|
|
25
|
-
right: node.right.name
|
|
26
|
-
}
|
|
32
|
+
right: node.right.name
|
|
33
|
+
}
|
|
27
34
|
});
|
|
28
35
|
}
|
|
29
|
-
}
|
|
36
|
+
}
|
|
30
37
|
};
|
|
31
|
-
}
|
|
38
|
+
}
|
|
32
39
|
};
|
|
40
|
+
|
|
33
41
|
//# sourceMappingURL=no-qualified-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../src/rules/react/no-qualified-type.ts"],"sourcesContent":["import { Rule } from 'eslint';\n\nexport const reactNoQualifiedType: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Disallow using React types from default export',\n category: 'Best Practices',\n recommended: false,\n url: 'https://github.com/servicetitan/uikit.git',\n },\n messages: {\n importDefault: \"Import {{right}} from 'react' instead of using React.{{right}}\",\n },\n },\n create(context) {\n return {\n TSQualifiedName(node: any) {\n if (node.left && node.left.name === 'React') {\n context.report({\n node,\n messageId: 'importDefault',\n data: {\n right: node.right.name,\n },\n });\n }\n },\n };\n },\n};\n"],"names":["reactNoQualifiedType","meta","type","docs","description","category","recommended","url","messages","importDefault","create","context","TSQualifiedName","node","left","name","report","messageId","data","right"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA,uBAAwC;IACjDC,MAAM;QACFC,MAAM;QACNC,MAAM;YACFC,aAAa;YACbC,UAAU;YACVC,aAAa;YACbC,KAAK;QACT;QACAC,UAAU;YACNC,eAAe;QACnB;IACJ;IACAC,QAAOC,OAAO;QACV,OAAO;YACHC,iBAAgBC,IAAS;gBACrB,IAAIA,KAAKC,IAAI,IAAID,KAAKC,IAAI,CAACC,IAAI,KAAK,SAAS;oBACzCJ,QAAQK,MAAM,CAAC;wBACXH;wBACAI,WAAW;wBACXC,MAAM;4BACFC,OAAON,KAAKM,KAAK,CAACJ,IAAI;wBAC1B;oBACJ;gBACJ;YACJ;QACJ;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/eslint": "~9.6.1",
|
|
21
21
|
"@typescript-eslint/rule-tester": "~8.32.1",
|
|
22
|
-
"eslint": "~9.
|
|
22
|
+
"eslint": "~9.30.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"eslint": "~9.
|
|
25
|
+
"eslint": "~9.30.1",
|
|
26
26
|
"typescript": ">=5.8.3"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"cli": {
|
|
32
32
|
"webpack": false
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c52e188a1217df74052774a2eea6a5126089e3d5"
|
|
35
35
|
}
|