@servicetitan/eslint-plugin 33.1.0 → 34.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.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/rules/no-async-in-foreach.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -3
- package/src/rules/__tests__/no-async-in-foreach.test.ts +1 -2
- package/src/rules/no-async-in-foreach.ts +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQtC,eAAO,MAAM,KAAK,EAAE,MAAM,CACtB,MAAM,GAAG,MAAM,GAAG,OAAO,EACzB,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,CAclD,CAAC;AAEF,QAAA,MAAM,MAAM;;;;CAsBX,CAAC;AAGF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@ _export(exports, {
|
|
|
17
17
|
return rules;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const _noasyncinforeach = require("./rules/no-async-in-foreach");
|
|
21
20
|
const _decoratorsdeclare = require("./rules/decorators-declare");
|
|
22
|
-
const _usemakeObservablewithdecorators = require("./rules/mobx/use-makeObservable-with-decorators");
|
|
23
21
|
const _noabstractdecorators = require("./rules/mobx/no-abstract-decorators");
|
|
22
|
+
const _usemakeObservablewithdecorators = require("./rules/mobx/use-makeObservable-with-decorators");
|
|
23
|
+
const _noasyncinforeach = require("./rules/no-async-in-foreach");
|
|
24
24
|
const _destructuredefaultimport = require("./rules/react/destructure-default-import");
|
|
25
25
|
const _noqualifiedtype = require("./rules/react/no-qualified-type");
|
|
26
26
|
const rules = {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport { Linter, Rule } from 'eslint';\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport { Linter, Rule } from 'eslint';\nimport { useDeclareWithDecorators } from './rules/decorators-declare';\nimport { mobxNoAbstractDecorators } from './rules/mobx/no-abstract-decorators';\nimport { mobxUseMakeObservableWithDecorators } from './rules/mobx/use-makeObservable-with-decorators';\nimport { noAsyncInForEach } from './rules/no-async-in-foreach';\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":";;;;;;;;;;;QAmDA,oDAAoD;IACpD;eAAA;;QA3CaA;eAAAA;;;mCAP4B;sCACA;iDACW;kCACnB;0CACa;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"}
|
|
@@ -1 +1 @@
|
|
|
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');\
|
|
1
|
+
{"version":3,"sources":["../../src/rules/no-async-in-foreach.ts"],"sourcesContent":["import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';\nimport ts, { ParameterDeclaration, TypeChecker } from 'typescript';\nconst { getParserServices } = require('@typescript-eslint/utils/eslint-utils');\nconst { containsAllTypesByName } = require('@typescript-eslint/type-utils');\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;mEACgB;;;;;;AACtD,MAAM,EAAEC,iBAAiB,EAAE,GAAGC,QAAQ;AACtC,MAAM,EAAEC,sBAAsB,EAAE,GAAGD,QAAQ;AAE3C,MAAME,aAAaC,kBAAW,CAACC,WAAW,CACtCC,CAAAA,QAAS;AAGN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A,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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/eslint-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "34.0.0",
|
|
4
|
+
"description": "Custom ESLint rules for React, MobX, and TypeScript best practices",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/servicetitan/uikit.git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/eslint": "~9.6.1",
|
|
22
22
|
"@typescript-eslint/rule-tester": "~8.46.2",
|
|
23
|
-
"eslint": "~9.39.
|
|
23
|
+
"eslint": "~9.39.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"eslint": ">=9",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"cli": {
|
|
33
33
|
"webpack": false
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "e193dc22703963f67099874a24de535d0696b6e2"
|
|
36
36
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
import { Linter, Rule } from 'eslint';
|
|
3
|
-
|
|
4
|
-
import { noAsyncInForEach } from './rules/no-async-in-foreach';
|
|
5
3
|
import { useDeclareWithDecorators } from './rules/decorators-declare';
|
|
6
|
-
import { mobxUseMakeObservableWithDecorators } from './rules/mobx/use-makeObservable-with-decorators';
|
|
7
4
|
import { mobxNoAbstractDecorators } from './rules/mobx/no-abstract-decorators';
|
|
5
|
+
import { mobxUseMakeObservableWithDecorators } from './rules/mobx/use-makeObservable-with-decorators';
|
|
6
|
+
import { noAsyncInForEach } from './rules/no-async-in-foreach';
|
|
8
7
|
import { reactDestructureDefaultImport } from './rules/react/destructure-default-import';
|
|
9
8
|
import { reactNoQualifiedType } from './rules/react/no-qualified-type';
|
|
10
9
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
2
1
|
import typescriptEslintParser from '@typescript-eslint/parser';
|
|
2
|
+
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
|
|
5
4
|
import { noAsyncInForEach } from '../no-async-in-foreach';
|
|
6
5
|
|
|
7
6
|
if (!globalThis.structuredClone) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import ts, { ParameterDeclaration, TypeChecker } from 'typescript';
|
|
2
3
|
const { getParserServices } = require('@typescript-eslint/utils/eslint-utils');
|
|
3
4
|
const { containsAllTypesByName } = require('@typescript-eslint/type-utils');
|
|
4
|
-
import ts, { ParameterDeclaration, TypeChecker } from 'typescript';
|
|
5
5
|
|
|
6
6
|
const createRule = ESLintUtils.RuleCreator(
|
|
7
7
|
_name => 'https://gist.github.com/joeytwiddle/37d2085425c049629b80956d3c618971'
|