Best JavaScript code snippet using storybook-root
tsShim.js
Source:tsShim.js
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3var ts = require("typescript");4var typescript_1 = require("typescript");5exports.getMeaningFromLocation = ts.getMeaningFromLocation6 || function (node) {7 if (node.parent.kind === typescript_1.SyntaxKind.ExportAssignment) {8 return 1 | 2 | 4;9 }10 else if (isInRightSideOfImport(node)) {11 return getMeaningFromRightHandSideOfImportEquals(node);12 }13 else if (ts.isDeclarationName(node)) {14 return exports.getMeaningFromDeclaration(node.parent);15 }16 else if (isTypeReference(node)) {17 return 2;18 }19 else if (isNamespaceReference(node)) {20 return 4;21 }22 else {23 return 1;24 }25 };26exports.getMeaningFromDeclaration = ts.getMeaningFromDeclaration27 || function (node) {28 switch (node.kind) {29 case typescript_1.SyntaxKind.Parameter:30 case typescript_1.SyntaxKind.VariableDeclaration:31 case typescript_1.SyntaxKind.BindingElement:32 case typescript_1.SyntaxKind.PropertyDeclaration:33 case typescript_1.SyntaxKind.PropertySignature:34 case typescript_1.SyntaxKind.PropertyAssignment:35 case typescript_1.SyntaxKind.ShorthandPropertyAssignment:36 case typescript_1.SyntaxKind.EnumMember:37 case typescript_1.SyntaxKind.MethodDeclaration:38 case typescript_1.SyntaxKind.MethodSignature:39 case typescript_1.SyntaxKind.Constructor:40 case typescript_1.SyntaxKind.GetAccessor:41 case typescript_1.SyntaxKind.SetAccessor:42 case typescript_1.SyntaxKind.FunctionDeclaration:43 case typescript_1.SyntaxKind.FunctionExpression:44 case typescript_1.SyntaxKind.ArrowFunction:45 case typescript_1.SyntaxKind.CatchClause:46 return 1;47 case typescript_1.SyntaxKind.TypeParameter:48 case typescript_1.SyntaxKind.InterfaceDeclaration:49 case typescript_1.SyntaxKind.TypeAliasDeclaration:50 case typescript_1.SyntaxKind.TypeLiteral:51 return 2;52 case typescript_1.SyntaxKind.ClassDeclaration:53 case typescript_1.SyntaxKind.EnumDeclaration:54 return 1 | 2;55 case typescript_1.SyntaxKind.ModuleDeclaration:56 if (ts.isAmbientModule(node)) {57 return 4 | 1;58 }59 else if (ts.getModuleInstanceState(node) === 1) {60 return 4 | 1;61 }62 else {63 return 4;64 }65 case typescript_1.SyntaxKind.NamedImports:66 case typescript_1.SyntaxKind.ImportSpecifier:67 case typescript_1.SyntaxKind.ImportEqualsDeclaration:68 case typescript_1.SyntaxKind.ImportDeclaration:69 case typescript_1.SyntaxKind.ExportAssignment:70 case typescript_1.SyntaxKind.ExportDeclaration:71 return 1 | 2 | 4;72 case typescript_1.SyntaxKind.SourceFile:73 return 4 | 1;74 }75 return 1 | 2 | 4;76 };77function isInRightSideOfImport(node) {78 while (node.parent.kind === typescript_1.SyntaxKind.QualifiedName) {79 node = node.parent;80 }81 return isInternalModuleImportEqualsDeclaration(node.parent) && (node.parent).moduleReference === node;82}83function isInternalModuleImportEqualsDeclaration(node) {84 return node.kind === typescript_1.SyntaxKind.ImportEqualsDeclaration && node.moduleReference.kind !== typescript_1.SyntaxKind.ExternalModuleReference;85}86function getMeaningFromRightHandSideOfImportEquals(node) {87 if (node.parent.kind === typescript_1.SyntaxKind.QualifiedName &&88 (node.parent).right === node &&89 node.parent.parent.kind === typescript_1.SyntaxKind.ImportEqualsDeclaration) {90 return 1 | 2 | 4;91 }92 return 4;93}94function isTypeReference(node) {95 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) {96 node = node.parent;97 }98 return node.parent.kind === typescript_1.SyntaxKind.TypeReference ||99 (node.parent.kind === typescript_1.SyntaxKind.ExpressionWithTypeArguments && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) ||100 (node.kind === typescript_1.SyntaxKind.ThisKeyword && !isPartOfExpression(node)) ||101 node.kind === typescript_1.SyntaxKind.ThisType;102}103function isNamespaceReference(node) {104 return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node);105}106function isQualifiedNameNamespaceReference(node) {107 var root = node;108 var isLastClause = true;109 if (root.parent.kind === typescript_1.SyntaxKind.QualifiedName) {110 while (root.parent && root.parent.kind === typescript_1.SyntaxKind.QualifiedName) {111 root = root.parent;112 }113 isLastClause = (root).right === node;114 }115 return root.parent.kind === typescript_1.SyntaxKind.TypeReference && !isLastClause;116}117function isPropertyAccessNamespaceReference(node) {118 var root = node;119 var isLastClause = true;120 if (root.parent.kind === typescript_1.SyntaxKind.PropertyAccessExpression) {121 while (root.parent && root.parent.kind === typescript_1.SyntaxKind.PropertyAccessExpression) {122 root = root.parent;123 }124 isLastClause = (root).name === node;125 }126 if (!isLastClause && root.parent.kind === typescript_1.SyntaxKind.ExpressionWithTypeArguments && root.parent.parent.kind === typescript_1.SyntaxKind.HeritageClause) {127 var decl = root.parent.parent.parent;128 return (decl.kind === typescript_1.SyntaxKind.ClassDeclaration && (root.parent.parent).token === typescript_1.SyntaxKind.ImplementsKeyword) ||129 (decl.kind === typescript_1.SyntaxKind.InterfaceDeclaration && (root.parent.parent).token === typescript_1.SyntaxKind.ExtendsKeyword);130 }131 return false;132}133function isPartOfExpression(node) {134 switch (node.kind) {135 case typescript_1.SyntaxKind.ThisKeyword:136 case typescript_1.SyntaxKind.SuperKeyword:137 case typescript_1.SyntaxKind.NullKeyword:138 case typescript_1.SyntaxKind.TrueKeyword:139 case typescript_1.SyntaxKind.FalseKeyword:140 case typescript_1.SyntaxKind.RegularExpressionLiteral:141 case typescript_1.SyntaxKind.ArrayLiteralExpression:142 case typescript_1.SyntaxKind.ObjectLiteralExpression:143 case typescript_1.SyntaxKind.PropertyAccessExpression:144 case typescript_1.SyntaxKind.ElementAccessExpression:145 case typescript_1.SyntaxKind.CallExpression:146 case typescript_1.SyntaxKind.NewExpression:147 case typescript_1.SyntaxKind.TaggedTemplateExpression:148 case typescript_1.SyntaxKind.AsExpression:149 case typescript_1.SyntaxKind.TypeAssertionExpression:150 case typescript_1.SyntaxKind.NonNullExpression:151 case typescript_1.SyntaxKind.ParenthesizedExpression:152 case typescript_1.SyntaxKind.FunctionExpression:153 case typescript_1.SyntaxKind.ClassExpression:154 case typescript_1.SyntaxKind.ArrowFunction:155 case typescript_1.SyntaxKind.VoidExpression:156 case typescript_1.SyntaxKind.DeleteExpression:157 case typescript_1.SyntaxKind.TypeOfExpression:158 case typescript_1.SyntaxKind.PrefixUnaryExpression:159 case typescript_1.SyntaxKind.PostfixUnaryExpression:160 case typescript_1.SyntaxKind.BinaryExpression:161 case typescript_1.SyntaxKind.ConditionalExpression:162 case typescript_1.SyntaxKind.TemplateExpression:163 case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:164 case typescript_1.SyntaxKind.OmittedExpression:165 case typescript_1.SyntaxKind.JsxElement:166 case typescript_1.SyntaxKind.JsxSelfClosingElement:167 case typescript_1.SyntaxKind.YieldExpression:168 case typescript_1.SyntaxKind.AwaitExpression:169 return true;170 case typescript_1.SyntaxKind.QualifiedName:171 while (node.parent.kind === typescript_1.SyntaxKind.QualifiedName) {172 node = node.parent;173 }174 return node.parent.kind === typescript_1.SyntaxKind.TypeQuery || ts.isJSXTagName(node);175 case typescript_1.SyntaxKind.Identifier:176 if (node.parent.kind === typescript_1.SyntaxKind.TypeQuery || ts.isJSXTagName(node)) {177 return true;178 }179 case typescript_1.SyntaxKind.NumericLiteral:180 case typescript_1.SyntaxKind.StringLiteral:181 case typescript_1.SyntaxKind.ThisKeyword:182 var parent_1 = node.parent;183 switch (parent_1.kind) {184 case typescript_1.SyntaxKind.VariableDeclaration:185 case typescript_1.SyntaxKind.Parameter:186 case typescript_1.SyntaxKind.PropertyDeclaration:187 case typescript_1.SyntaxKind.PropertySignature:188 case typescript_1.SyntaxKind.EnumMember:189 case typescript_1.SyntaxKind.PropertyAssignment:190 case typescript_1.SyntaxKind.BindingElement:191 return (parent_1).initializer === node;192 case typescript_1.SyntaxKind.ExpressionStatement:193 case typescript_1.SyntaxKind.IfStatement:194 case typescript_1.SyntaxKind.DoStatement:195 case typescript_1.SyntaxKind.WhileStatement:196 case typescript_1.SyntaxKind.ReturnStatement:197 case typescript_1.SyntaxKind.WithStatement:198 case typescript_1.SyntaxKind.SwitchStatement:199 case typescript_1.SyntaxKind.CaseClause:200 case typescript_1.SyntaxKind.ThrowStatement:201 case typescript_1.SyntaxKind.SwitchStatement:202 return (parent_1).expression === node;203 case typescript_1.SyntaxKind.ForStatement:204 var forStatement = parent_1;205 return (forStatement.initializer === node && forStatement.initializer.kind !== typescript_1.SyntaxKind.VariableDeclarationList) ||206 forStatement.condition === node ||207 forStatement.incrementor === node;208 case typescript_1.SyntaxKind.ForInStatement:209 case typescript_1.SyntaxKind.ForOfStatement:210 var forInStatement = parent_1;211 return (forInStatement.initializer === node && forInStatement.initializer.kind !== typescript_1.SyntaxKind.VariableDeclarationList) ||212 forInStatement.expression === node;213 case typescript_1.SyntaxKind.TypeAssertionExpression:214 case typescript_1.SyntaxKind.AsExpression:215 return node === (parent_1).expression;216 case typescript_1.SyntaxKind.TemplateSpan:217 return node === (parent_1).expression;218 case typescript_1.SyntaxKind.ComputedPropertyName:219 return node === (parent_1).expression;220 case typescript_1.SyntaxKind.Decorator:221 case typescript_1.SyntaxKind.JsxExpression:222 case typescript_1.SyntaxKind.JsxSpreadAttribute:223 return true;224 case typescript_1.SyntaxKind.ExpressionWithTypeArguments:225 return (parent_1).expression === node && ts.isExpressionWithTypeArgumentsInClassExtendsClause(parent_1);226 default:227 if (isPartOfExpression(parent_1)) {228 return true;229 }230 }231 }232 return false;233}234function getThisMemberSymbolKind(typeChecker, symbol, location) {235 if (ts.SymbolDisplay && ts.SymbolDisplay.getSymbolKind) {236 return ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);237 }238 var flags = symbol.getFlags();239 if (flags & typescript_1.SymbolFlags.Class)240 return ts.getDeclarationOfKind(symbol, typescript_1.SyntaxKind.ClassExpression) ?241 typescript_1.ScriptElementKind.localClassElement : typescript_1.ScriptElementKind.classElement;242 if (flags & typescript_1.SymbolFlags.Enum)243 return typescript_1.ScriptElementKind.enumElement;244 if (flags & typescript_1.SymbolFlags.TypeAlias)245 return typescript_1.ScriptElementKind.typeElement;246 if (flags & typescript_1.SymbolFlags.Interface)247 return typescript_1.ScriptElementKind.interfaceElement;248 if (flags & typescript_1.SymbolFlags.TypeParameter)249 return typescript_1.ScriptElementKind.typeParameterElement;250 var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags);251 if (result === typescript_1.ScriptElementKind.unknown) {252 if (flags & typescript_1.SymbolFlags.TypeParameter)253 return typescript_1.ScriptElementKind.typeParameterElement;254 if (flags & typescript_1.SymbolFlags.EnumMember)255 return typescript_1.ScriptElementKind.variableElement;256 if (flags & typescript_1.SymbolFlags.Alias)257 return typescript_1.ScriptElementKind.alias;258 if (flags & typescript_1.SymbolFlags.Module)259 return typescript_1.ScriptElementKind.moduleElement;260 }261 return result;262}263exports.getThisMemberSymbolKind = getThisMemberSymbolKind;264function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags) {265 if (typeChecker.isUndefinedSymbol(symbol)) {266 return typescript_1.ScriptElementKind.variableElement;267 }268 if (typeChecker.isArgumentsSymbol(symbol)) {269 return typescript_1.ScriptElementKind.localVariableElement;270 }271 if (flags & typescript_1.SymbolFlags.GetAccessor)272 return typescript_1.ScriptElementKind.memberGetAccessorElement;273 if (flags & typescript_1.SymbolFlags.SetAccessor)274 return typescript_1.ScriptElementKind.memberSetAccessorElement;275 if (flags & typescript_1.SymbolFlags.Method)276 return typescript_1.ScriptElementKind.memberFunctionElement;277 if (flags & typescript_1.SymbolFlags.Constructor)278 return typescript_1.ScriptElementKind.constructorImplementationElement;279 if (flags & typescript_1.SymbolFlags.Property) {280 if (flags & typescript_1.SymbolFlags["SyntheticProperty"]) {281 var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) {282 var rootSymbolFlags = rootSymbol.getFlags();283 if (rootSymbolFlags & (typescript_1.SymbolFlags.PropertyOrAccessor | typescript_1.SymbolFlags.Variable)) {284 return typescript_1.ScriptElementKind.memberVariableElement;285 }286 });287 if (!unionPropertyKind) {288 return typescript_1.ScriptElementKind.memberVariableElement;289 }290 return unionPropertyKind;291 }292 return typescript_1.ScriptElementKind.memberVariableElement;293 }294 return typescript_1.ScriptElementKind.unknown;...
.eslintrc.js
Source:.eslintrc.js
1module.exports = {2 "env": {3 "browser": true,4 "es6": true,5 "node": true6 },7 "parser": "@typescript-eslint/βparser",8 "parserOptions": {9 "project": "src/βtsconfig.node.json",10 "sourceType": "module"11 },12 "plugins": [13 "@typescript-eslint",14 "import",15 "jsdoc",16 "prefer-arrow",17 "unicorn"18 ],19 "rules": {20 "@typescript-eslint/βadjacent-overload-signatures": "error",21 "@typescript-eslint/βarray-type": [22 "error",23 {24 "default": "array"25 }26 ],27 "@typescript-eslint/βawait-thenable": "error",28 "@typescript-eslint/βban-ts-comment": "error",29 "@typescript-eslint/βban-types": "off",30 "@typescript-eslint/βbrace-style": [31 "error",32 "1tbs",33 {34 "allowSingleLine": true35 }36 ],37 "@typescript-eslint/βcamelcase": "off",38 "@typescript-eslint/βcomma-spacing": "error",39 "@typescript-eslint/βconsistent-type-assertions": [40 "error",41 {42 "assertionStyle": "angle-bracket"43 }44 ],45 "@typescript-eslint/βconsistent-type-definitions": "error",46 "@typescript-eslint/βdefault-param-last": "error",47 "@typescript-eslint/βexplicit-function-return-type": "error",48 "@typescript-eslint/βexplicit-member-accessibility": [49 "error",50 {51 "accessibility": "explicit"52 }53 ],54 "@typescript-eslint/βexplicit-module-boundary-types": "error",55 "@typescript-eslint/βfunc-call-spacing": "error",56 "@typescript-eslint/βindent": [57 "off",58 459 ],60 "@typescript-eslint/βmember-delimiter-style": [61 "error",62 {63 "multiline": {64 "delimiter": "semi",65 "requireLast": true66 },67 "singleline": {68 "delimiter": "semi",69 "requireLast": false70 }71 }72 ],73 "@typescript-eslint/βmember-ordering": "error",74 "@typescript-eslint/βnaming-convention": [75 "error",76 {77 "selector": "default",78 "format": ["camelCase", "PascalCase"]79 },80 {81 "selector": "variable",82 "format": ["camelCase", "PascalCase", "UPPER_CASE"]83 },84 {85 "selector": "function",86 "format": ["camelCase", "PascalCase"]87 },88 {89 "selector": "class",90 "format": ["PascalCase"]91 },92 {93 "selector": "interface",94 "format": ["PascalCase"],95 "prefix": ["I"]96 },97 {98 "selector": "typeAlias",99 "format": ["PascalCase"],100 "prefix": ["T"]101 },102 {103 "selector": "typeParameter",104 "format": ["PascalCase"]105 },106 {107 "selector": "enum",108 "format": ["PascalCase"]109 },110 {111 "selector": "enumMember",112 "format": null113 },114 {115 "selector": "property",116 "format": ["camelCase", "PascalCase", "snake_case"]117 }118 ],119 "@typescript-eslint/βno-empty-function": "off",120 "@typescript-eslint/βno-empty-interface": "error",121 "@typescript-eslint/βno-explicit-any": "off",122 "@typescript-eslint/βno-extra-parens": "off",123 "@typescript-eslint/βno-floating-promises": "error",124 "@typescript-eslint/βno-for-in-array": "error",125 "@typescript-eslint/βno-inferrable-types": "off",126 "@typescript-eslint/βno-magic-numbers": "off",127 "@typescript-eslint/βno-misused-new": "error",128 "@typescript-eslint/βno-namespace": "error",129 "@typescript-eslint/βno-non-null-asserted-optional-chain": "error",130 "@typescript-eslint/βno-non-null-assertion": "error",131 "@typescript-eslint/βno-param-reassign": "off",132 "@typescript-eslint/βno-parameter-properties": "error",133 "@typescript-eslint/βno-require-imports": "off",134 "@typescript-eslint/βno-shadow": "error",135 "@typescript-eslint/βno-this-alias": "error",136 "@typescript-eslint/βno-unnecessary-qualifier": "error",137 "@typescript-eslint/βno-unnecessary-type-arguments": "error",138 "@typescript-eslint/βno-unnecessary-type-assertion": "error",139 "@typescript-eslint/βno-unused-expressions": "error",140 "@typescript-eslint/βno-use-before-define": "off",141 "@typescript-eslint/βno-var-requires": "error",142 "@typescript-eslint/βprefer-for-of": "error",143 "@typescript-eslint/βprefer-function-type": "error",144 "@typescript-eslint/βprefer-namespace-keyword": "error",145 "@typescript-eslint/βprefer-nullish-coalescing": "error",146 "@typescript-eslint/βprefer-optional-chain": "error",147 "@typescript-eslint/βprefer-readonly": "error",148 "@typescript-eslint/βpromise-function-async": "error",149 "@typescript-eslint/βquotes": [150 "error",151 "single"152 ],153 "@typescript-eslint/βrequire-array-sort-compare": "error",154 "@typescript-eslint/βrestrict-plus-operands": "error",155 "@typescript-eslint/βsemi": [156 "error",157 "always"158 ],159 "@typescript-eslint/βspace-before-function-paren": "error",160 "@typescript-eslint/βstrict-boolean-expressions": "off",161 "@typescript-eslint/βtriple-slash-reference": "error",162 "@typescript-eslint/βtype-annotation-spacing": "error",163 "@typescript-eslint/βtypedef": "error",164 "@typescript-eslint/βunified-signatures": "error",165 "arrow-body-style": "off",166 "arrow-parens": [167 "off",168 "as-needed"169 ],170 "brace-style": "off",171 "capitalized-comments": "off",172 "comma-dangle": "off",173 "comma-spacing": "off",174 "complexity": [175 "error",176 {177 "max": 10178 }179 ],180 "constructor-super": "error",181 "curly": "error",182 "default-case": "off",183 "dot-notation": "error",184 "eol-last": "error",185 "eqeqeq": [186 "error",187 "smart"188 ],189 "func-call-spacing": "off",190 "guard-for-in": "error",191 "id-blacklist": "off",192 "id-match": "off",193 "import/βexport": "error",194 "import/βfirst": "error",195 "import/βnewline-after-import": "error",196 "import/βno-absolute-path": "error",197 "import/βno-cycle": "error",198 "import/βno-default-export": "error",199 "import/βno-deprecated": "error",200 "import/βno-extraneous-dependencies": "error",201 "import/βno-internal-modules": "error",202 "import/βno-mutable-exports": "error",203 "import/βno-unassigned-import": "off",204 "import/βno-useless-path-segments": "error",205 "import/βorder": "off",206 "indent": "off",207 "jsdoc/βno-types": "off",208 "linebreak-style": "off",209 "max-classes-per-file": [210 "error",211 1212 ],213 "max-len": "off",214 "max-lines": [215 "error",216 500217 ],218 "new-parens": "error",219 "newline-per-chained-call": "off",220 "no-bitwise": "off",221 "no-caller": "error",222 "no-cond-assign": "error",223 "no-console": [224 "error",225 {226 "allow": [227 "log",228 "warn",229 "dir",230 "timeLog",231 "assert",232 "clear",233 "count",234 "countReset",235 "group",236 "groupEnd",237 "table",238 "dirxml",239 "error",240 "groupCollapsed",241 "Console",242 "profile",243 "profileEnd",244 "timeStamp",245 "context"246 ]247 }248 ],249 "no-constant-condition": "error",250 "no-control-regex": "off",251 "no-debugger": "error",252 "no-duplicate-case": "error",253 "no-duplicate-imports": "error",254 "no-empty": "off",255 "no-eval": "off",256 "no-extra-bind": "error",257 "no-extra-parens": "off",258 "no-extra-semi": "error",259 "no-fallthrough": "error",260 "no-invalid-regexp": "error",261 "no-invalid-this": "off",262 "no-irregular-whitespace": "error",263 "no-magic-numbers": "off",264 "no-multi-str": "error",265 "no-multiple-empty-lines": "error",266 "no-new-wrappers": "error",267 "no-null/βno-null": "off",268 "no-octal": "error",269 "no-octal-escape": "error",270 "no-redeclare": "error",271 "no-regex-spaces": "error",272 "no-restricted-syntax": [273 "error",274 "ForInStatement"275 ],276 "no-return-await": "error",277 "no-sequences": "error",278 "no-shadow": "off",279 "no-sparse-arrays": "error",280 "no-template-curly-in-string": "error",281 "no-throw-literal": "error",282 "no-trailing-spaces": [283 "error",284 {285 "skipBlankLines": true286 }287 ],288 "no-undef-init": "error",289 "no-underscore-dangle": "off",290 "no-unsafe-finally": "error",291 "no-unused-expressions": "off",292 "no-unused-labels": "error",293 "no-var": "error",294 "no-void": "error",295 "object-shorthand": "off",296 "one-var": [297 "error",298 "never"299 ],300 "padding-line-between-statements": [301 "error",302 {303 "blankLine": "always",304 "prev": "*",305 "next": "return"306 }307 ],308 "prefer-arrow/βprefer-arrow-functions": "off",309 "prefer-const": "error",310 "prefer-object-spread": "error",311 "prefer-template": "error",312 "quote-props": [313 "error",314 "as-needed"315 ],316 "quotes": "off",317 "radix": "error",318 "space-before-function-paren": "off",319 "spaced-comment": "error",320 "space-in-parens": [321 "error",322 "never"323 ],324 "unicorn/βcatch-error-name": [325 "error",326 {327 "name": "error"328 }329 ],330 "unicorn/βno-nested-ternary": "error",331 "unicorn/βno-unreadable-array-destructuring": "error",332 "unicorn/βnumeric-separators-style": [333 "error",334 {335 number: {336 minimumDigits: 7,337 groupLength: 3338 }339 }340 ],341 "unicorn/βprefer-array-find": "error",342 "unicorn/βprefer-includes": "error",343 "unicorn/βprefer-optional-catch-binding": "error",344 "unicorn/βprefer-starts-ends-with": "error",345 "unicorn/βprefer-set-has": "error",346 "unicorn/βprefer-string-slice": "error",347 "unicorn/βprefer-string-trim-start-end": "error",348 "use-isnan": "error",349 "valid-typeof": "error",350 "yoda": "error"351 }...
base.ts
Source:base.ts
1import type { Linter } from 'eslint'2import { SharedEditorConfig } from '@fellwork/βeslint-shared'3export const typescriptBase: Linter.BaseConfig = {4 rules: {5 '@typescript-eslint/βawait-thenable': 'off',6 '@typescript-eslint/βconsistent-type-exports': 'off',7 '@typescript-eslint/βnaming-convention': 'off',8 '@typescript-eslint/βno-base-to-string': 'off',9 '@typescript-eslint/βno-confusing-void-expression': 'off',10 '@typescript-eslint/βno-floating-promises': 'off',11 '@typescript-eslint/βno-meaningless-void-operator': 'off',12 '@typescript-eslint/βno-misused-promises': 'off',13 '@typescript-eslint/βprefer-regexp-exec': 'off',14 '@typescript-eslint/βno-unnecessary-boolean-literal-compare': 'off',15 '@typescript-eslint/βno-unnecessary-condition': 'off',16 '@typescript-eslint/βno-unnecessary-qualifier': 'off',17 '@typescript-eslint/βno-unnecessary-type-arguments': 'off',18 '@typescript-eslint/βno-unnecessary-type-assertion': 'off',19 '@typescript-eslint/βno-unsafe-argument': 'off',20 '@typescript-eslint/βno-unsafe-assignment': 'off',21 '@typescript-eslint/βno-unsafe-call': 'off',22 '@typescript-eslint/βno-unsafe-member-access': 'off',23 '@typescript-eslint/βno-unsafe-return': 'off',24 '@typescript-eslint/βnon-nullable-type-assertion-style': 'off',25 '@typescript-eslint/βprefer-includes': 'off',26 '@typescript-eslint/βprefer-reduce-type-parameter': 'off',27 '@typescript-eslint/βprefer-string-starts-ends-with': 'off',28 '@typescript-eslint/βprefer-return-this-type': 'off',29 '@typescript-eslint/βpromise-function-async': 'off',30 '@typescript-eslint/βrequire-array-sort-compare': 'off',31 '@typescript-eslint/βrestrict-plus-operands': 'off',32 '@typescript-eslint/βswitch-exhaustiveness-check': 'off',33 '@typescript-eslint/βunbound-method': 'off',34 '@typescript-eslint/βdot-notation': 'off',35 '@typescript-eslint/βrequire-await': 'off',36 '@typescript-eslint/βreturn-await': 'off',37 '@typescript-eslint/βno-for-in-array': 'off',38 '@typescript-eslint/βprefer-nullish-coalescing': 'off',39 '@typescript-eslint/βprefer-readonly': 'off',40 '@typescript-eslint/βprefer-readonly-parameter-types': 'off',41 '@typescript-eslint/βno-implied-eval': 'off',42 '@typescript-eslint/βno-require-imports': 'off',43 '@typescript-eslint/βrestrict-template-expressions': 'off',44 '@typescript-eslint/βstrict-boolean-expressions': 'off',45 '@typescript-eslint/βno-throw-literal': 'off',46 /β/β Off47 'no-undef': 'off',48 '@typescript-eslint/βban-tslint-comment': 'off',49 '@typescript-eslint/βno-extraneous-class': 'off',50 '@typescript-eslint/βno-parameter-properties': 'off',51 '@typescript-eslint/βtypedef': 'off',52 '@typescript-eslint/βno-type-alias': 'off',53 '@typescript-eslint/βadjacent-overload-signatures': 'warn',54 /β/β Warn or error55 'indent': 'off',56 '@typescript-eslint/βindent': ['warn', SharedEditorConfig.indent_size, {57 SwitchCase: 1,58 VariableDeclarator: 1,59 outerIIFEBody: 1,60 MemberExpression: 1,61 FunctionDeclaration: { parameters: 1, body: 1 },62 FunctionExpression: { parameters: 1, body: 1 },63 CallExpression: { arguments: 1 },64 ArrayExpression: 1,65 ObjectExpression: 1,66 ImportDeclaration: 1,67 flatTernaryExpressions: false,68 ignoreComments: false,69 ignoredNodes: [70 'TemplateLiteral *',71 'JSXElement',72 'JSXElement > *',73 'JSXAttribute',74 'JSXIdentifier',75 'JSXNamespacedName',76 'JSXMemberExpression',77 'JSXSpreadAttribute',78 'JSXExpressionContainer',79 'JSXOpeningElement',80 'JSXClosingElement',81 'JSXFragment',82 'JSXOpeningFragment',83 'JSXClosingFragment',84 'JSXText',85 'JSXEmptyExpression',86 'JSXSpreadChild',87 'TSTypeParameterInstantiation',88 ],89 offsetTernaryExpressions: true,90 }],91 '@typescript-eslint/βarray-type': [92 'warn',93 {94 default: 'array-simple',95 },96 ],97 '@typescript-eslint/βban-ts-comment': [98 'warn',99 {100 'ts-expect-error': 'allow-with-description',101 'ts-ignore': 'allow-with-description',102 'ts-nocheck': 'allow-with-description',103 'ts-check': 'allow-with-description',104 'minimumDescriptionLength': 5,105 },106 ],107 '@typescript-eslint/βconsistent-type-assertions': [108 'warn',109 {110 assertionStyle: 'as',111 objectLiteralTypeAssertions: 'allow-as-parameter',112 },113 ],114 '@typescript-eslint/βexplicit-function-return-type': [115 'warn',116 {117 allowExpressions: true,118 },119 ],120 '@typescript-eslint/βexplicit-module-boundary-types': 'warn',121 '@typescript-eslint/βmember-delimiter-style': ['warn', { multiline: { delimiter: 'none' } }],122 '@typescript-eslint/βmember-ordering': 'warn',123 '@typescript-eslint/βno-confusing-non-null-assertion': 'warn',124 '@typescript-eslint/βno-empty-interface': [125 'warn',126 {127 allowSingleExtends: true,128 },129 ],130 '@typescript-eslint/βno-explicit-any': 'error',131 '@typescript-eslint/βno-extra-non-null-assertion': 'warn',132 '@typescript-eslint/βno-implicit-any-catch': 'warn',133 '@typescript-eslint/βno-inferrable-types': 'warn',134 '@typescript-eslint/βno-invalid-void-type': 'warn',135 '@typescript-eslint/βno-non-null-assertion': 'warn',136 '@typescript-eslint/βno-unnecessary-type-constraint': 'warn',137 '@typescript-eslint/βprefer-as-const': 'warn',138 '@typescript-eslint/βprefer-enum-initializers': 'warn',139 '@typescript-eslint/βprefer-literal-enum-member': 'warn',140 '@typescript-eslint/βprefer-ts-expect-error': 'warn',141 '@typescript-eslint/βsort-type-union-intersection-members': 'warn',142 '@typescript-eslint/βtype-annotation-spacing': ['warn', {}],143 '@typescript-eslint/βunified-signatures': 'warn',144 /β/β Style145 'brace-style': 'off',146 '@typescript-eslint/βbrace-style': ['warn', 'stroustrup', { allowSingleLine: true }],147 'comma-dangle': 'off',148 '@typescript-eslint/βcomma-dangle': ['warn', 'always-multiline'],149 'comma-spacing': 'off',150 '@typescript-eslint/βcomma-spacing': ['warn', { before: false, after: true }],151 'default-param-last': 'off',152 '@typescript-eslint/βdefault-param-last': 'warn',153 'func-call-spacing': 'off',154 '@typescript-eslint/βfunc-call-spacing': 'warn',155 'keyword-spacing': 'off',156 '@typescript-eslint/βkeyword-spacing': ['warn', { before: true, after: true }],157 'lines-between-class-members': 'off',158 '@typescript-eslint/βlines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],159 'no-array-constructor': 'off',160 '@typescript-eslint/βno-array-constructor': 'warn',161 'no-empty-function': 'off',162 '@typescript-eslint/βno-empty-function': 'warn',163 'no-extra-parens': 'off',164 '@typescript-eslint/βno-extra-parens': ['warn', 'functions'],165 'no-extra-semi': 'off',166 '@typescript-eslint/βsemi': ['warn', 'never'],167 'no-loss-of-precision': 'off',168 '@typescript-eslint/βno-loss-of-precision': 'warn',169 'no-magic-numbers': 'off',170 '@typescript-eslint/βno-magic-numbers': [171 'warn',172 {173 ignoreEnums: true,174 ignore: [0, 1],175 },176 ],177 'no-shadow': 'off',178 '@typescript-eslint/βno-shadow': 'warn',179 'no-unused-expressions': 'off',180 '@typescript-eslint/βno-unused-expressions': 'warn',181 'no-unused-vars': 'off',182 '@typescript-eslint/βno-unused-vars': [183 'warn',184 {185 argsIgnorePattern: '^_',186 },187 ],188 'no-useless-constructor': 'off',189 '@typescript-eslint/βno-useless-constructor': 'warn',190 'object-curly-spacing': 'off',191 '@typescript-eslint/βobject-curly-spacing': ['warn', 'always'],192 'quotes': 'off',193 '@typescript-eslint/βquotes': ['warn', 'single'],194 'semi': 'off',195 'space-before-blocks': 'off',196 '@typescript-eslint/βspace-before-blocks': ['error', 'always'],197 'space-before-function-paren': 'off',198 '@typescript-eslint/βspace-before-function-paren': [199 'warn',200 {201 named: 'never',202 anonymous: 'always',203 asyncArrow: 'always',204 },205 ],206 'space-infix-ops': 'off',207 '@typescript-eslint/βspace-infix-ops': 'warn',208 '@typescript-eslint/βprefer-function-type': 'error',209 '@typescript-eslint/βban-types': [210 'error',211 {212 extendDefaults: true,213 },214 ],215 '@typescript-eslint/βclass-literal-property-style': 'error',216 '@typescript-eslint/βconsistent-indexed-object-style': ['error', 'record'],217 '@typescript-eslint/βconsistent-type-definitions': ['error', 'interface'],218 '@typescript-eslint/βconsistent-type-imports': [219 'error',220 {221 prefer: 'type-imports',222 disallowTypeAnnotations: false,223 },224 ],225 '@typescript-eslint/βexplicit-member-accessibility': [226 'error',227 {228 accessibility: 'explicit',229 },230 ],231 '@typescript-eslint/βmethod-signature-style': 'error',232 '@typescript-eslint/βno-dynamic-delete': 'error',233 '@typescript-eslint/βno-misused-new': 'error',234 '@typescript-eslint/βno-namespace': 'error',235 '@typescript-eslint/βno-non-null-asserted-optional-chain': 'error',236 '@typescript-eslint/βno-this-alias': 'error',237 '@typescript-eslint/βno-var-requires': 'error',238 '@typescript-eslint/βprefer-for-of': 'error',239 '@typescript-eslint/βprefer-namespace-keyword': 'error',240 '@typescript-eslint/βtriple-slash-reference': [241 'error',242 {243 path: 'never',244 types: 'never',245 lib: 'never',246 },247 ],248 'init-declarations': 'off',249 '@typescript-eslint/βinit-declarations': 'error',250 'no-dupe-class-members': 'off',251 '@typescript-eslint/βno-dupe-class-members': 'error',252 'no-duplicate-imports': 'off',253 '@typescript-eslint/βno-duplicate-imports': 'error',254 'no-invalid-this': 'off',255 '@typescript-eslint/βno-invalid-this': 'error',256 'no-loop-func': 'off',257 '@typescript-eslint/βno-loop-func': 'error',258 'no-redeclare': 'off',259 '@typescript-eslint/βno-redeclare': 'error',260 'no-use-before-define': 'off',261 '@typescript-eslint/βno-use-before-define': ['error', { functions: false, classes: false, variables: true }],262 },...
Using AI Code Generation
1import { configure } from '@storybook/βreact';2import { setOptions } from '@storybook/βaddon-options';3import { setAddon } from '@storybook/βreact';4import infoAddon, { setDefaults } from '@storybook/βaddon-info';5setAddon(infoAddon);6setDefaults({7 styles: stylesheet => {8 stylesheet.infoBody = {9 };10 stylesheet.infoStory = {11 };12 return stylesheet;13 },14});15setOptions({
Using AI Code Generation
1import { configure } from '@storybook/βreact';2configure(require.context('../βsrc', true, /β\.stories\.js$/β), module);3import { configure } from '@storybook/βreact';4configure(require.context('../βsrc', true, /β\.stories\.tsx$/β), module);5import { configure } from '@storybook/βreact';6configure(require.context('../βsrc', true, /β\.stories\.jsx$/β), module);7import { configure } from '@storybook/βreact';8configure(require.context('../βsrc', true, /β\.stories\.mdx$/β), module);9import { configure } from '@storybook/βreact';10configure(require.context('../βsrc', true, /β\.stories\.ts$/β), module);11import { configure } from '@storybook/βreact';12configure(require.context('../βsrc', true, /β\.stories\.tsx$/β), module);13import { configure } from '@storybook/βreact';14configure(require.context('../βsrc', true, /β\.stories\.jsx$/β), module);15import { configure } from '@storybook/βreact';16configure(require.context('../βsrc', true, /β\.stories\.mdx$/β), module);17import { configure } from '@storybook/βreact';18configure(require.context('../βsrc', true, /β\.stories\.ts$/β), module);19import { configure } from '@storybook/βreact';20configure(require.context('../βsrc', true, /β\.stories\.tsx$/β), module);21import { configure } from '@storybook/βreact';
Using AI Code Generation
1import { configure } from '@storybook/βreact';2function loadStories() {3 require('../βsrc/βstories');4}5configure(loadStories, module);6{7 "compilerOptions": {8 "paths": {9 },10 },11}12const path = require('path');13module.exports = (baseConfig, env, defaultConfig) => {14 defaultConfig.module.rules.push({15 test: /β\.(ts|tsx)$/β,16 loader: require.resolve('awesome-typescript-loader'),17 });18 defaultConfig.resolve.extensions.push('.ts', '.tsx');19 return defaultConfig;20};21{22 "scripts": {23 },24 "dependencies": {
Using AI Code Generation
1import { storiesOf } from '@storybook/βreact';2import { action } from '@storybook/βaddon-actions';3import { linkTo } from '@storybook/βaddon-links';4import { Button, Welcome } from 'components';5storiesOf('Welcome', module).add('to Storybook', () => (6 <Welcome showApp={linkTo('Button')} /β>7));8storiesOf('Button', module)9 .add('with text', () => (10 <Button onClick={action('clicked')}>Hello Button</βButton>11 .add('with some emoji', () => (12 <Button onClick={action('clicked')}>π π π π―</βButton>13 ));14{15 "compilerOptions": {16 "paths": {17 }18 },19}20import { configure } from '@storybook/βreact';21configure(require.context('../βstories', true, /β\.stories\.js$/β), module);22const path = require('path');23module.exports = (baseConfig, env, config) => {24 config.module.rules.push({25 test: /β\.(ts|tsx)$/β,26 loader: require.resolve('awesome-typescript-loader')27 });28 config.resolve.extensions.push('.ts', '.tsx');29 config.resolve.alias = {30 components: path.resolve(__dirname, '../βsrc/βcomponents')31 };32 return config;33};34import '@storybook/βaddon-actions/βregister';
Using AI Code Generation
1import { withA11y } from '@storybook/βaddon-a11y';2import { withKnobs } from '@storybook/βaddon-knobs';3import { withInfo } from '@storybook/βaddon-info';4addDecorator(withA11y);5addDecorator(withKnobs);6addDecorator(withInfo
Using AI Code Generation
1import { configure } from '@storybook/βreact';2function loadStories() {3 require('../βstories/βindex.js');4}5configure(loadStories, module);6import { storiesOf } from '@storybook/βreact';7import { withInfo } from '@storybook/βaddon-info';8import { withKnobs, text } from '@storybook/βaddon-knobs';9import { action } from '@storybook/βaddon-actions';10import { linkTo } from '@storybook/βaddon-links';11import React from 'react';12import { Button } from '@storybook/βreact/βdemo';13import { Welcome } from '@storybook/βreact/βdemo';14storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} /β>);15storiesOf('Button', module)16 .addDecorator(withKnobs)17 .addDecorator(withInfo)18 .add('with text', () => <Button onClick={action('clicked')}>{text('Label', 'Hello Button')}</βButton>)19 .add('with some emoji', () => <Button onClick={action('clicked')}>{text('Label', 'π π π π―')}</βButton>);
Using AI Code Generation
1import { configure } from 'storybook-root';2configure(require.context('../βsrc', true, /β\.stories\.js$/β), module);3import { configure } from 'storybook-root';4configure(require.context('../βsrc', true, /β\.stories\.js$/β), module);5import React from 'react';6import { action } from '@storybook/βaddon-actions';7import { Button } from '@storybook/βreact/βdemo';8import { withKnobs, text, boolean, number } from "@storybook/βaddon-knobs";9export default {10};11export const Text = () => <Button onClick={action('clicked')}>{text('Label', 'Hello Button')}</βButton>;12export const Emoji = () => (13 <Button onClick={action('clicked')} disabled={boolean('Disabled', false)}>14);15export const WithSomeEmojiAndAction = () => (16 <Button onClick={action('This was clicked')}>17);18export const WithSomeEmojiAndAction = () => (19 <Button onClick={action('This was clicked')}>20);21export const WithSomeEmojiAndAction = () => (22 <Button onClick={action('This was clicked')}>23);24export const WithSomeEmojiAndAction = () => (25 <Button onClick={action('This was clicked')}>
Using AI Code Generation
1const path = require('path');2const root = path.resolve(__dirname, '..', '..');3const storybookRoot = path.resolve(root, 'node_modules/β@storybook/βreact');4const storybook = require(storybookRoot);5const storybook = require('@storybook/βreact');6const storybook = require('@storybook/βreact/βdist/βserver/βindex.js');7const storybook = require('@storybook/βreact/βdist/βserver/βindex.js');8const config = require('../β../β.storybook/βconfig.js');9const stories = require('../β../β.storybook/βstories.js');10storybook({
Using AI Code Generation
1const path = require('path');2const { root } = require('@storybook/βreact/βdist/βserver/βconfig/βdefaults/βwebpack.config.js');3const { getReactScriptsPath } = require('@storybook/βreact/βdist/βserver/βcra-config');4module.exports = (baseConfig, env, defaultConfig) => {5 const reactScriptsPath = getReactScriptsPath();6 const reactScriptsTsConfigPath = path.join(reactScriptsPath, 'tsconfig.json');7 const storybookTsConfigPath = path.join(root, 'tsconfig.json');8 config.module.rules.push({9 test: /β\.(ts|tsx)$/β,10 loader: require.resolve('ts-loader'),11 options: {12 compilerOptions: {13 paths: {14 },15 },16 },17 });18 config.resolve.extensions.push('.ts', '.tsx');19 return config;20};
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!