Mohsen Azimi mohsen1 @airbnb San Francisco, CA https://azimi.me ♥ Open Source 👨🏽‍💻Airbnb https://twitter.com/mohsen____

startedNockiro/slack-black-theme

started time in 6 days

issue commenttypescript-eslint/typescript-eslint

Access original TypeScript node for using in typechecker

you can get the original node like this:

https://github.com/typescript-eslint/typescript-eslint/blob/063518380215fc0b2df777080d247fe222cf258d/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts#L83

goodmind

comment created time in 15 days

issue commentmohsen1/multi-file-swagger-example

Not working if folders are not in root

I'm happy to merge a PR to fix this

NassiHarel

comment created time in 15 days

issue commentadlawson/nodejs-langs

Missing many languages

Here is a complete list of language https://iso639-3.sil.org/code_tables/639/data

garyking

comment created time in 16 days

startedMicrosoft/pyright

started time in a month

startedbramstein/typeset

started time in a month

startedOptimalBits/bull

started time in a month

issue openedtypescript-eslint/typescript-eslint

Rule proposal: No unnecessary check for falsy values

Code like this is probably result of wrong type annotation:

function foo(bar: string[]) {
 if (bar) {
   return bar.join(' -- ')
  }

  return '';
}

in my case type annotation was wrong and bar had to be of type string[] | null.

We should detect those checks that are always truthy according to types and warn against them.

created time in a month

issue openedstorybooks/storybook

Resizing window vertically can put addons panel under preview panel and get stuck thee

if resize window vertically to small enough hight, it's possible to put the header of addons panel under preview header and make it impossible to grab the splitter handler to make addons panel smaller:

Screen Shot 2019-03-15 at 1 14 26 PM

Resizing the window back will not make the addons panel smaller: Screen Shot 2019-03-15 at 1 15 55 PM

System:

  • OS: MacOS Mojave
  • Device: Macbook Pro
  • Browser: Chrome 73
  • Framework: React
  • Addons: knob, actions and link
  • Version: 5.0.1

Additional context Sometimes the panel header is completely hidden. This is why I filed https://github.com/storybooks/storybook/issues/6087 assuming enabling addons will make preview disappear

created time in a month

issue commentMicrosoft/TypeScript

Replace any by unknown in definition files

For now you can override the types yourself and enjoy more strict type checks:

declare global {
  interface JSON {
    parse(text: string, reviver?: (key: any, value: any) => any): unknown;
  }

  interface ArrayConstructor {
    isArray(a: unknown): a is unknown[];
  }

  interface Body {
    json(): Promise<unknown>;
  }
}
ThomasdenH

comment created time in a month

issue closedstorybooks/storybook

Enabling addons will put `height: 12px` on div wrapper around PreviewConnected and make preview invisible

After upgrading to v5 we're seeing this issue where if addons are enabled the preview is not showing up. After digging into the elements in the devtools I noticed the div that wraps PreviewConnected has following inline style:

style="height: 12px; left: 0px; top: 0px; width: 1460px;"

Screenshots Kapture 2019-03-14 at 10 09 07

Code snippets .storybook/addons.js

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-knobs/register';
// .storybook/config.js
import { configure } from '@storybook/react';
import registerTheme from '../src/utils/registerTheme';

registerTheme();

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.tsx$/);
function loadStories() {
  req.keys().forEach((filename) => req(filename));
}

configure(loadStories, module);
// .storybook/webpack.config.js
module.exports = ({ config }) => {
  config.module.rules.push({
    test: /\.tsx?$/,
    loader: 'babel-loader',
    exclude: /node_modules/,
  });

  config.resolve.extensions.push('.ts', '.tsx');

  return config;
};

package.json

 "@storybook/addon-actions": "^5.0.1",
    "@storybook/addon-info": "^5.0.1",
    "@storybook/addon-knobs": "^5.0.1",
    "@storybook/addon-links": "^5.0.1",
    "@storybook/addons": "^5.0.1",
    "@storybook/react": "^5.0.1",
    "@types/chrome": "0.0.77",
 "@types/storybook__addon-actions": "^3.4.2",
    "@types/storybook__addon-knobs": "^4.0.3",
    "@types/storybook__addon-links": "^3.3.4",
    "@types/storybook__react": "^4.0.1",

System:

  • OS: MacOS
  • Device: Mac
  • Browser: Chrome
  • Framework: React
  • Addons: see snippt
  • Version: see package.json

Additional context Add any other context about the problem here.

closed time in a month

mohsen1

issue commentstorybooks/storybook

Enabling addons will put `height: 12px` on div wrapper around PreviewConnected and make preview invisible

This is not happening in an Incognito window so I am assuming it's some Chrome extension messing with the layout.

mohsen1

comment created time in a month

issue openedstorybooks/storybook

Change theme to dark if user has dark mode enabled using prefers-color-scheme media query

Chrome and Safari will soon support the prefers-color-scheme media query. Let's respect that since Storybook has a dark theme already

Are you able to assist bring the feature to reality? yes

created time in a month

issue openedstorybooks/storybook

Enabling addons will put `height: 12px` on div wrapper around PreviewConnected and make preview invisible

After upgrading to v5 we're seeing this issue where if addons are enabled the preview is not showing up. After digging into the elements in the devtools I noticed the div that wraps PreviewConnected has following inline style:

style="height: 12px; left: 0px; top: 0px; width: 1460px;"

Screenshots Kapture 2019-03-14 at 10 09 07

Code snippets .storybook/addons.js

import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-knobs/register';
// .storybook/config.js
import { configure } from '@storybook/react';
import registerTheme from '../src/utils/registerTheme';

registerTheme();

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /.stories.tsx$/);
function loadStories() {
  req.keys().forEach((filename) => req(filename));
}

configure(loadStories, module);
// .storybook/webpack.config.js
module.exports = ({ config }) => {
  config.module.rules.push({
    test: /\.tsx?$/,
    loader: 'babel-loader',
    exclude: /node_modules/,
  });

  config.resolve.extensions.push('.ts', '.tsx');

  return config;
};

package.json

 "@storybook/addon-actions": "^5.0.1",
    "@storybook/addon-info": "^5.0.1",
    "@storybook/addon-knobs": "^5.0.1",
    "@storybook/addon-links": "^5.0.1",
    "@storybook/addons": "^5.0.1",
    "@storybook/react": "^5.0.1",
    "@types/chrome": "0.0.77",
 "@types/storybook__addon-actions": "^3.4.2",
    "@types/storybook__addon-knobs": "^4.0.3",
    "@types/storybook__addon-links": "^3.3.4",
    "@types/storybook__react": "^4.0.1",

System:

  • OS: MacOS
  • Device: Mac
  • Browser: Chrome
  • Framework: React
  • Addons: see snippt
  • Version: see package.json

Additional context Add any other context about the problem here.

created time in a month

pull request commentfacebookincubator/idx

Fix types: support enums, make DeepRequiredObject limited to object

There is no need for for bigint anymore. Issue was resolved by forcing DeepRequiredObject to only work on object and passthrough the primitives.

I think we can release this as a patch version.

Thanks for looking into this!

mohsen1

comment created time in a month

pull request commentfacebookincubator/idx

Fix several recent types bugs

This seems like redundant work. You can always suggest fixes in PR comments.

malash

comment created time in a month

issue openedfacebookincubator/idx

CI is not running test for PRs

Let's make CI run tests for PRs too

created time in a month

pull request commentfacebookincubator/idx

Remove bigint conditional type from UnboxDeepRequired

This is unnecessary with recent changes in #80

mohsen1

comment created time in a month

PR closed facebookincubator/idx

Remove bigint conditional type from UnboxDeepRequired CLA Signed

Fixes #77

+5 -7

1 comment

1 changed file

mohsen1

pr closed time in a month

push eventmohsen1/idx

Mohsen Azimi

commit sha a76f4317b184fd96329d0e374909a8c9098cd66a

Remove primitive checks

view details

push time in a month

pull request commentfacebookincubator/idx

Fix several recent types bugs

I'm trying to end the mess stage

Really?!!

malash

comment created time in a month

issue openedsindresorhus/type-fest

Similar project

FYI https://github.com/piotrwitek/utility-types is very similar to this project.

created time in a month

issue commenttypescript-eslint/typescript-eslint

ESLint can't detect error from typescript

It's by design I believe. ESLint is not in business of type checking your code. You should rely on TypeScript for checking for type errors.

zarkin404

comment created time in a month

issue commenttypescript-eslint/typescript-eslint

Expose Typescript -> ESTree AST conversion logic

related to #330

deifactor

comment created time in a month

startedWICG/import-maps

started time in a month

issue commentmohsen1/json-formatter-js

How to use as a standalone script?

this requires users to use Webpack or similar tools. You can probably make it emit UMD too

https://github.com/mohsen1/json-formatter-js/blob/1f561d2efee44238ace56c1ba6db2d2cb915311b/webpack.config.js#L16

bendavis78

comment created time in a month

pull request commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "no-enum-literals" rule

I'm still working on this. Functions and methods with overloading and all that is complicated. I also like the name opaque-enum

mohsen1

comment created time in a month

starteddonnemartin/system-design-primer

started time in a month

startedRyanCavanaugh/learn-a

started time in a month

Pull request review commenteslint/eslint

Chore: improve crash reporting (fixes #11304)

 module.exports = class Linter {                 options.filename             );         } catch (err) {+            err.message += `\nOccurred while linting ${options.filename}`;             debug("An error occurred while traversing");             debug("Filename:", options.filename);+            if (err.currentNode) {+                const { line } = err.currentNode.loc.start;

Can we get column information here too?

alexzherdev

comment created time in a month

created tagmohsen1/yawn-yaml

tagv1.4.0

YAML parser that preserves comments and styling

created time in a month

push eventmohsen1/yawn-yaml

Mohsen Azimi

commit sha 6328a40964ff9f8b5cfa718d84a62f6d53b42870

1.4.0

view details

push time in a month

push eventmohsen1/yawn-yaml

Mohsen Azimi

commit sha 69870710b8d770c0822d5f6d80808466d7f40241

Move to yarn

view details

Mohsen Azimi

commit sha fe6b7b2b5c494734d63faa61ffe4ca89cbd13056

new build

view details

push time in a month

push eventmohsen1/multi-file-swagger-example

Mohsen Azimi

commit sha c0829fec043527f3c765e57cb7d74db34c52db9b

Move to Yarn

view details

push time in a month

issue closedmohsen1/multi-file-swagger-example

Definitions 'ref' is injected, not referenced

In your example, foo.yaml contains a reference to the user definition:

ref: '#/definitions/User'

but this gets resolved to the actual object definition

<pre> swagger: '2.0' /bar: get: responses: '200': description: OK schema: <b> type: object properties: name: type: string</b> definitions: User: type: object properties: name: type: string </pre>

instead of just including the ref as I would expect (is my expectation erroneous?)

<pre> swagger: '2.0' /bar: get: responses: '200': description: OK schema: <b>$ref: '#/definitions/User'</b> definitions: User: type: object properties: name: type: string </pre>

closed time in a month

NadavK

push eventmohsen1/yawn-yaml

Russell Osborne

commit sha 939c5a175e62b9bc5abc5fae89efed4ca8019fe8

contains has been replaced with includes in lodash ^4

view details

Russell Osborne

commit sha 09da113789825f6b65b4611a253d0ea3e2449872

Add dist build

view details

Russell Osborne

commit sha 3b5be27702bd19c31db4862837357d5da477de3d

Bumping lodash to 4.0

view details

Russell Osborne

commit sha c2d514b547a4402b77066c91e496a4948736c034

Upgrade dependencies using npm 5.4

view details

Russell Osborne

commit sha f9219425be2573687e3cf1a932dd379e466b9ed3

Merge remote-tracking branch 'upstream/master'

view details

Russell Osborne

commit sha 4a69da22945d2e1330de7ed1486feb71d4ad1239

Upgrades lodash again

view details

Mohsen Azimi

commit sha e7d3142b6ed9cf02f1f905ae194421a6b1dc9c56

Merge pull request #7 from rposborne/master Support for lodash 4

view details

push time in a month

PR merged mohsen1/yawn-yaml

Support for lodash 4

contains has been replaced with includes in lodash ^4

+5082 -7

8 comments

5 changed files

rposborne

pr closed time in a month

push eventmohsen1/multi-file-swagger-example

Claudio

commit sha 3a3268780a9a9dc566449ce8c4e4c9cf8f7d9aa8

Updating dependencies which allows for nested reference resolution and adding regression test

view details

Claudio

commit sha 80f3d99e3edec44e9b6bf0c6aad6da7c40105286

Adding back commander dependency in case its used

view details

Mohsen Azimi

commit sha f36bafc60219adae05174a7b43adcae4fb1ccb8d

Merge pull request #21 from ClaudioConsolmagno/dependency-updates-and-regression-tests Updating dependencies which allows for nested reference resolution

view details

push time in a month

PR merged mohsen1/multi-file-swagger-example

Updating dependencies which allows for nested reference resolution

Updating to latest versions:

"commander": "^2.19.0",
"js-yaml": "^3.12.2",
"json-refs": "^3.0.12"

Updates allow nested references to be resolved which was added on json-refs@3.0.2 as per this https://github.com/whitlockjc/json-refs/issues/27

Have also added a lightweight regression test that can be used to show the changes: paths/index.yaml references paths/nested.yaml. Running npm test against previous dependencies would result in a broken /nested schema as such (SameFileReference definition doesn't appear anywhere):

  /nested:
    get:
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/nested/SameFileReference'

With this update, /nested schema is inlined:

  /nested:
    get:
      responses:
        '200':
          description: OK
          schema:
            type: object
            properties:
              name:
                type: string
+413 -5

0 comment

8 changed files

ClaudioConsolmagno

pr closed time in a month

create barnchmohsen1/typescript-eslint

branch : mohsen1--add-lib-to-tsconfig

created branch time in a month

Pull request review commenttypescript-eslint/typescript-eslint

fix(eslint-plugin): support BigInt in restrict-plus-operands rule

 var foo = pair + pair;         },       ],     },+    {+      code: `var foo = 1n; foo + 1`,

This is already an error throw by TypeScript. Why you need a lint rule for it?

https://www.typescriptlang.org/play/index.html#src=var%20foo%20%3D%201n%3B%20foo%20%2B%201

webschik

comment created time in a month

issue openedtypescript-eslint/typescript-eslint

Why I'm getting suggestions based on dom.d.ts lib in VSCode?

I confirmed that none of the configurations include "lib: ["dom"] but still I'm getting autocomplete results for window and such:

Screen Shot 2019-03-09 at 11 17 27 AM

For completeness here is TSServer logs:

<details>

[Info  - 11:15:03 AM] Using tsserver from: /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib
[Info  - 11:15:03 AM] TSServer log file: /Users/mohsen_nabiloo-azimi/Library/Application Support/Code/logs/20190302T212625/exthost26/vscode.typescript-language-features/tsserver-log-Nmu0P2/tsserver.log
[Info  - 11:15:03 AM] Forking TSServer
[Info  - 11:15:03 AM] Started TSServer
[Trace  - 11:15:03 AM] Sending request: configure (0). Response expected: no. Current queue length: 0
Arguments: {
    "hostInfo": "vscode",
    "preferences": {
        "providePrefixAndSuffixTextForRename": true,
        "allowRenameOfImportPath": true
    }
}
[Trace  - 11:15:03 AM] Sending request: compilerOptionsForInferredProjects (1). Response expected: no. Current queue length: 0
Arguments: {
    "options": {
        "module": "commonjs",
        "target": "es2016",
        "jsx": "preserve",
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true
    }
}
[Trace  - 11:15:03 AM] Sending request: open (2). Response expected: no. Current queue length: 0
Arguments: {
    "file": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts",
    "fileContent": "import ts from 'typescript';\nimport * as util from '../util';\nimport { TSESTree } from '@typescript-eslint/typescript-estree';\n\nexport default util.createRule({\n  name: 'no-enum-literal-comparison',\n  meta: {\n    type: 'suggestion',\n    docs: {\n      description: 'Disallows usage of literals instead of enums',\n      category: 'Best Practices',\n      recommended: 'error',\n    },\n    messages: {\n      noLiterals: 'Do not use literal values instead of enums',\n    },\n    schema: [],\n  },\n  defaultOptions: [],\n  create(context) {\n    const parserServices = util.getParserServices(context);\n    const checker = parserServices.program.getTypeChecker();\n\n    /**\n     * is node an identifier with type of an enum\n     * @param node identifier node\n     */\n    function isNodeEnumIdentifier(node: TSESTree.Node): boolean {\n      const originalNode = parserServices.esTreeNodeToTSNodeMap.get<\n        ts.Identifier\n      >(node);\n      const type = checker.getTypeAtLocation(originalNode);\n\n      if (!type.symbol) {\n        return false;\n      }\n\n      const { name } = type.symbol;\n\n      return !['Number', 'String'].includes(name);\n    }\n\n    function isNumberOrStringLiteral(\n      node: TSESTree.Node,\n    ): node is TSESTree.Literal {\n      return (\n        node.type === 'Literal' &&\n        ['number', 'string'].includes(typeof node.value)\n      );\n    }\n\n    return {\n      AssignmentExpression(node) {\n        if (\n          isNodeEnumIdentifier(node.left) &&\n          isNumberOrStringLiteral(node.right)\n        ) {\n          context.report({\n            node: node.right,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      BinaryExpression(node) {\n        if (\n          isNodeEnumIdentifier(node.left) &&\n          isNumberOrStringLiteral(node.right)\n        ) {\n          context.report({\n            node: node.right,\n            messageId: 'noLiterals',\n          });\n        }\n\n        if (\n          isNumberOrStringLiteral(node.left) &&\n          isNodeEnumIdentifier(node.right)\n        ) {\n          context.report({\n            node: node.left,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      VariableDeclarator(node) {\n        if (\n          isNodeEnumIdentifier(node.id) &&\n          node.init &&\n          isNumberOrStringLiteral(node.init)\n        ) {\n          context.report({\n            node: node.init,\n            messageId: 'noLiterals',\n          });\n        }\n      },\n      CallExpression(node) {\n        const originalNode = parserServices.esTreeNodeToTSNodeMap.get<\n          ts.CallExpression\n        >(node);\n        const callExpressionType = checker.getTypeAtLocation(originalNode);\n\n        if (node.arguments) {\n          for (const argument of node.arguments) {\n            const argumentType = checker.getTypeAtLocation(originalNode);\n          }\n        }\n      },\n    };\n  },\n});\n",
    "scriptKindName": "TS",
    "projectRootPath": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint"
}
[Trace  - 11:15:03 AM] Sending request: configurePlugin (3). Response expected: no. Current queue length: 0
Arguments: {
    "pluginName": "typescript-tslint-plugin",
    "configuration": {}
}
[Trace  - 11:15:03 AM] Sending request: geterr (4). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts"
    ]
}
[Trace  - 11:15:06 AM] Event received: projectLoadingStart (0).
Data: {
    "projectName": "/Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/tsconfig.json",
    "reason": "Creating possible configured project for /Users/mohsen_nabiloo-azimi/Code/typescript-eslint/packages/eslint-plugin/src/rules/no-enum-literal-comparison.ts to open"
}
[Trace  - 11:15:06 AM] Event received: projectLoadingFinish (0).

</details>

created time in 2 months

PR closed typescript-eslint/typescript-eslint

Emit declarations for eslint-plugin

The createRule helper is extremely useful for writing rules in TypeScript. I would like to use that for my own ESLint rules. Exporting the types will help a lot.

+0 -3

3 comments

1 changed file

mohsen1

pr closed time in 2 months

pull request commenttypescript-eslint/typescript-eslint

Emit declarations for eslint-plugin

Closing until we decide how we want to approach this issue: #330

mohsen1

comment created time in 2 months

issue commenttypescript-eslint/typescript-eslint

Massive performance penalty when `shouldProvideParserServices` is true

For users that use the CLI, there's nothing at all we can do about the cost - once the lint finishes, node exits, and with it the cache is gone. This means you have to pay it once per cli run.

I think TypeScript 3.4 .tsbuildinfo might be helpful here. It's something that TypeScript ESLint should assure it not left unused.

dsgkirkby

comment created time in 2 months

startedcodercom/code-server

started time in 2 months

push eventmohsen1/typescript-project-references-src-test-folders

Mohsen Azimi

commit sha e2a35bc68218a3e2851f125cf62b44b4e03636ab

init

view details

push time in 2 months

create barnchmohsen1/typescript-project-references-src-test-folders

branch : master

created branch time in 2 months

created repositorymohsen1/typescript-project-references-src-test-folders

Demo app showing how to use TypeSCript project references with two independent src and test folders

created time in 2 months

pull request commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "no-enum-literals" rule

oh wow! how did I miss that? I'll work on it. Meanwhile, let's finalize the naming.

mohsen1

comment created time in 2 months

pull request commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "no-enum-literals" rule

It also prevents you from using literals instead enum params

mohsen1

comment created time in 2 months

push eventmohsen1/typescript-eslint

Cameron Crothers

commit sha 097262f6f800c387724143808e17608c0cced743

fix(eslint-plugin): [interface-name-prefix] correct error message in always mode (#333) interface-name-prefix currenlty provides 'Interface name must not be prefixed with "I".' but when in always mode it should give an error message that matches the intent, added 'Interface name must be prefixed with "I".' for when "always" is enabled

view details

Mohsen Azimi

commit sha 6ad002efa657e864057252dfe8404265f48df565

Merge branch 'master' of git://github.com/typescript-eslint/typescript-eslint into mohsen1--no-enum-literals

view details

Mohsen Azimi

commit sha df08d28c35319183ac4894b1d9558fae73d9751c

fix(eslint-plugin): fix tests and remove unused schema Make test code multiline Remove unused schema and defaultOption

view details

push time in 2 months

Pull request review commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "no-enum-literals" rule

+import rule from '../../src/rules/no-enum-literals';+import { RuleTester } from '../RuleTester';++const ruleTester = new RuleTester({+  parser: '@typescript-eslint/parser',+  parserOptions: {+    project: './tsconfig.json',+  },+});++ruleTester.run('no-enum-literals', rule, {+  valid: [+    '0 === 0',

I was guarding against false negatives. Added comment

mohsen1

comment created time in 2 months

push eventmohsen1/typescript-eslint

薛定谔的猫

commit sha 00eae48cd64028238720e239f9ee04807c4311c4

docs(eslint-plugin): fix no-useless-constructor examples (#329) it should be the plugin rule name, than eslint core rule name.

view details

Cameron Crothers

commit sha 097262f6f800c387724143808e17608c0cced743

fix(eslint-plugin): [interface-name-prefix] correct error message in always mode (#333) interface-name-prefix currenlty provides 'Interface name must not be prefixed with "I".' but when in always mode it should give an error message that matches the intent, added 'Interface name must be prefixed with "I".' for when "always" is enabled

view details

Mohsen Azimi

commit sha dc63ba09ae9ddbcf1ca1865809930a71dad0bab7

Merge branch 'master' of git://github.com/typescript-eslint/typescript-eslint into mohsen1--enum-style

view details

Mohsen Azimi

commit sha 3715b5f03a24137799ee49e9d817f542fe2b23ed

fix(eslint-plugin) fix coverage

view details

push time in 2 months

issue openedMicrosoft/vscode

Search: when ignoring casing, search for kabob and snake case too

With this feature, snake_case and kabab-case will also be included in search results. For instance when I search for clientId I want to get results for

  • clientid
  • client_id
  • client-id
  • CLIENT_ID

created time in 2 months

pull request commentfacebookincubator/idx

Fix types: support enums, make DeepRequiredObject limited to object

The tests are running in strict mode:https://github.com/facebookincubator/idx/blob/361d07e4979cf7b2b53ad79481411dc1b11dc96a/packages/idx/package.json#L17

mohsen1

comment created time in 2 months

issue commenttypescript-eslint/typescript-eslint

Rule proposal: Exhaust enum in switch-statement

@bradzacher cases can have similar types but different values


let a = {}
let b = {}

function foo(arg: {}) {
    switch (arg) {
        case a: return 'A'
        case b: return 'B'
        default:
            console.log(arg)
    }
}

console.log(foo(a))
console.log(foo(b))
sindresorhus

comment created time in 2 months

issue commentmohsen1/multi-file-swagger-example

I want to break each PATH OPERATION into its own file

Have you thought about having two index entry points for public and private? It might be a bit more verbose that will work for sure:

#private index.yml
paths:
  /foo:
    $ref: ./foo/get.yaml
    $ref: ./foo/post.yaml
  /bar:
   # ...
#public index.yml
paths:
  /foo:
    $ref: ./foo/get.yaml
  /bar:
   # ...
ericweidl

comment created time in 2 months

startedfacebookincubator/fbt

started time in 2 months

PR opened facebookincubator/idx

Fix types: support enums, make DeepRequiredObject limited to object

Fixes #78

  • Make DeepRequiredObject strictly limited to object types so it doesn't unwrap primitive types
  • Update UnboxDeepRequired to check for objects and arrays before checking for primitives
  • Move TypeScript dependency down to idx package
+32 -21

0 comment

4 changed files

pr created time in 2 months

push eventmohsen1/idx

Mohsen Azimi

commit sha ed36841df677710975c9210129d5bb04e72fef32

Move TypeScript dependency down to idx package

view details

push time in 2 months

create barnchmohsen1/idx

branch : mohsen1--fix-enums

created branch time in 2 months

create barnchmohsen1/idx

branch : mohsen--remove-bigint

created branch time in 2 months

startedpikapkg/web

started time in 2 months

push eventmohsen1/typescript-eslint

薛定谔的猫

commit sha 00eae48cd64028238720e239f9ee04807c4311c4

docs(eslint-plugin): fix no-useless-constructor examples (#329) it should be the plugin rule name, than eslint core rule name.

view details

Mohsen Azimi

commit sha 004720bb68e302ab0b6952cfc4b228013a87c6bb

Merge branch 'master' into mohsen1--no-enum-literals

view details

push time in 2 months

pull request commenttypescript-eslint/typescript-eslint

Emit declarations for eslint-plugin

It's being exported by the module

https://github.com/typescript-eslint/typescript-eslint/blob/00eae48cd64028238720e239f9ee04807c4311c4/packages/eslint-plugin/typings/ts-eslint.d.ts#L687

I was getting the same error when I copy-pasted this code into my own repo. I didn't fully resolve that issue. Not sure what's going on...

mohsen1

comment created time in 2 months

issue openedtypescript-eslint/typescript-eslint

Publish the 'ts-eslint' types to npm

the ts-eslint module is pretty useful for writing typed ESLint rules. Can we publish that under @typescript-eslint/types?

created time in 2 months

push eventmohsen1/typescript-eslint

Mohsen Azimi

commit sha 98e416d48f3543bfcf8037a873c142d6d0fcffa9

Update tsconfig.build.json

view details

push time in 2 months

PR opened typescript-eslint/typescript-eslint

Emit declarations for eslint-plugin

The createRule helper is extremely useful for writing rules in TypeScript. I would like to use that for my own ESLint rules. Exporting the types will help a lot.

+2 -2

0 comment

1 changed file

pr created time in 2 months

push eventmohsen1/typescript-eslint

Mohsen Azimi

commit sha ab49a73d84208fbf04efeeaacce65f9efcb0cdf8

Emit declarations for eslint-plugin The `createRule` helper is extremely useful for writing rules in TypeScript. I would like to use that for my own ESLint rules. Exporting the types will help a lot!

view details

push time in 2 months

starteddreamingechoes/awesome-mental-health

started time in 2 months

startedbloomberg/pasta-sourcemaps

started time in 2 months

issue closedairbnb/react-with-styles

Provide a `useStyles` method for using with React Hooks API

I imagine the API should not be too different from the HOC. The README example would look like this:

import React from "react";
import { css, useStyles } from "./useStyles";

function MyComponent() {
  const styles = useStyles(({ color }) => ({
    firstLink: {
      color: color.primary
    },

    secondLink: {
      color: color.secondary
    }
  }));

  return (
    <div>
      <a href="/somewhere" {...css(styles.firstLink)}>
        A link to somewhere
      </a>{" "}
      and{" "}
      <a href="/somewhere-else" {...css(styles.secondLink)}>
        a link to somewhere else
      </a>
    </div>
  );
}

export default MyComponent;

closed time in 2 months

mohsen1

issue commentairbnb/react-with-styles

Provide a `useStyles` method for using with React Hooks API

Closing based on feedback. Styles are not a stateful part of the component so it doesn't make sense to use Hooks API for them.

mohsen1

comment created time in 2 months

issue openedairbnb/react-with-styles

Provide a `useStyles` method for using with React Hooks API

I imagine the API should not be too different from the HOC. The README example would look like this:

import React from "react";
import { css, useStyles } from "./useStyles";

function MyComponent() {
  const styles = useStyles(({ color }) => ({
    firstLink: {
      color: color.primary
    },

    secondLink: {
      color: color.secondary
    }
  }));

  return (
    <div>
      <a href="/somewhere" {...css(styles.firstLink)}>
        A link to somewhere
      </a>{" "}
      and{" "}
      <a href="/somewhere-else" {...css(styles.secondLink)}>
        a link to somewhere else
      </a>
    </div>
  );
}

export default MyComponent;

created time in 2 months

issue commentfacebookincubator/idx

`UnboxDeepRequired doesn't support enum type.

I wonder if it's possible to narrow to your enum type before string without having access to that MyEnum type.

Don't forget that idx is a generic and you can always provide the type argument directly instead of relying on type inference.

I'll look into this later this week.

malash

comment created time in 2 months

push eventmohsen1/typescript-eslint

James Henry

commit sha eaaa471beb96caf57a9f3c69d436bf2046ad413a

fix: trigger new release

view details

James Henry

commit sha 2f4276fcb55b6a8ad6019c941648f44a434c9afa

chore: publish v1.4.2

view details

Mohsen Azimi

commit sha 3cabb56aec226f00af2e312135f6acc439503180

feat(eslint-plugin): add "no-enum-literals" rule

view details

push time in 2 months

issue commenttypescript-eslint/typescript-eslint

Rule proposal: Disallow implicit casts from/to `any`

The TypeScript team decided this is not useful as a strict flag. But I support this as an ESLint rule

emlai

comment created time in 2 months

issue openedbabel/website

[REPL] Query string does not include plugins

I have this URL:

https://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=JYWwDg9gTgLgBMAJgDzgMyhEcDkTk4BQhApgHYCu2AsgJ4Cil2A3oXLgIY5wC8nOAGja4ARtz44xQgL6EYtMCTh0AKgqV9W7clQBcyhkwDchaSfaEANiXhwQ-1et5wtcHfYOMqAOg6nCAMYQZADO8CQOhlRwAD5wlJaWsXAUZIgkaMBkJIjO-AAUIAJwAPq8AHyl3u4AlOZwgcEhENbelhAA5vnMbnDSNUA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=true&timeTravel=true&sourceType=module&lineWrap=false&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.3.3

With two plugins:

  • typescript
  • idx

None of the plugins are loaded when I paste the URL in a new window.

Result of copy(JSON.stringify(Array.from(new URLSearchParams(window.location.hash.substr(1)).entries()), null, 2)):

[
  [
    "babili",
    "false"
  ],
  [
    "browsers",
    ""
  ],
  [
    "build",
    ""
  ],
  [
    "builtIns",
    "false"
  ],
  [
    "spec",
    "false"
  ],
  [
    "loose",
    "false"
  ],
  [
    "code_lz",
    "JYWwDg9gTgLgBMAJgDzgMyhEcDkTk4BQhApgHYCu2AsgJ4Cil2A3oXLgIY5wC8nOAGja4ARtz44xQgL6EYtMCTh0AKgqV9W7clQBcyhkwDchaSfaEANiXhwQ-1et5wtcHfYOMqAOg6nCAMYQZADO8CQOhlRwAD5wlJaWsXAUZIgkaMBkJIjO-AAUIAJwAPq8AHyl3u4AlOZwgcEhENbelhAA5vnMbnDSNUA"
  ],
  [
    "debug",
    "false"
  ],
  [
    "forceAllTransforms",
    "false"
  ],
  [
    "shippedProposals",
    "false"
  ],
  [
    "circleciRepo",
    ""
  ],
  [
    "evaluate",
    "false"
  ],
  [
    "fileSize",
    "true"
  ],
  [
    "timeTravel",
    "true"
  ],
  [
    "sourceType",
    "module"
  ],
  [
    "lineWrap",
    "false"
  ],
  [
    "presets",
    "es2015,react,stage-2"
  ],
  [
    "prettier",
    "false"
  ],
  [
    "targets",
    ""
  ],
  [
    "version",
    "7.3.3"
  ]
]

created time in 2 months

push eventmohsen1/typescript-eslint

Mohsen Azimi

commit sha 564d4799c8e7138f31c1c026552e5bea9752e9ee

feat(eslint-plugin): add "no-enum-literals" rule

view details

push time in 2 months

push eventmohsen1/typescript-eslint

James Henry

commit sha eaaa471beb96caf57a9f3c69d436bf2046ad413a

fix: trigger new release

view details

James Henry

commit sha 2f4276fcb55b6a8ad6019c941648f44a434c9afa

chore: publish v1.4.2

view details

Mohsen Azimi

commit sha c386cdb612b59ba5a0a80a3f11aa38f3fc030676

Merge branch 'master' into mohsen1--enum-style

view details

push time in 2 months

Pull request review commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add strict-comparisons rule

+import { TSESTree } from '@typescript-eslint/typescript-estree';+import { isUnionType, isTypeFlagSet } from 'tsutils';+import ts from 'typescript';++import * as util from '../util';++interface Config {+  allowObjectEqualComparison: boolean;+  allowStringOrderComparison: boolean;+}++type Options = [Config];++type MessageIds = 'nonComparableTypes' | 'invalidTypeForOperator';++export default util.createRule<Options, MessageIds>({+  name: 'strict-comparisons',+  meta: {+    type: 'problem',+    docs: {+      category: 'Best Practices',+      description: 'Only allow comparisons between primitive types.',+      tslintRuleName: 'object-comparison',+      recommended: 'error',+    },+    messages: {+      nonComparableTypes:+        "cannot compare type '{{ typesLeft }}' to type '{{ typesRight }}'",+      invalidTypeForOperator:+        "cannot use '{{ comparator }}' comparator for type '{{ type }}'",+    },+    schema: [+      {+        type: 'object',+        properties: {+          allowObjectEqualComparison: {+            type: 'boolean',+          },+          allowStringOrderComparison: {+            type: 'boolean',+          },+        },+        additionalProperties: false,+      },+    ],+  },+  defaultOptions: [+    {+      allowObjectEqualComparison: false,+      allowStringOrderComparison: false,+    },+  ],+  create(+    context,+    [{ allowObjectEqualComparison, allowStringOrderComparison }],+  ) {+    const service = util.getParserServices(context);++    const typeChecker = service.program.getTypeChecker();++    const enum TypeKind {+      Any = 0,+      Number = 1,+      Enum = 2,+      String = 3,+      Boolean = 4,+      NullOrUndefined = 5,+      Object = 6,+    }++    const typeNames = {+      [TypeKind.Any]: 'any',+      [TypeKind.Number]: 'number',+      [TypeKind.Enum]: 'enum',+      [TypeKind.String]: 'string',+      [TypeKind.Boolean]: 'boolean',+      [TypeKind.NullOrUndefined]: 'null | undefined',+      [TypeKind.Object]: 'object',+    };++    /**+     * Get TypeKinds of a typescript type+     * @param type+     */+    function getKinds(type: ts.Type): TypeKind[] {+      return isUnionType(type)+        ? Array.from(new Set(type.types.map(getKind)))+        : [getKind(type)];+    }++    /**+     * Get TypeKind of a typescript type+     * @param type+     */++    function getKind(type: ts.Type): TypeKind {+      // tslint:disable:no-bitwise+      return is(ts.TypeFlags.String | ts.TypeFlags.StringLiteral)+        ? TypeKind.String+        : is(ts.TypeFlags.Number | ts.TypeFlags.NumberLiteral)+        ? TypeKind.Number+        : is(ts.TypeFlags.BooleanLike)+        ? TypeKind.Boolean+        : is(ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)+        ? TypeKind.NullOrUndefined+        : is(ts.TypeFlags.Any)+        ? TypeKind.Any+        : TypeKind.Object;+      // tslint:enable:no-bitwise++      function is(flags: ts.TypeFlags) {+        return isTypeFlagSet(type, flags);+      }+    }++    /**+     * Check if a specific TypeKind is present in an array+     * @param typesLeft array of TypeKinds+     * @param typesRight TypeKind to check+     */+    function getStrictestComparableType(+      typesLeft: TypeKind[],+      typesRight: TypeKind[],+    ): TypeKind | undefined {+      const overlappingTypes = typesLeft.filter(+        type => typesRight.indexOf(type) >= 0,+      );++      if (overlappingTypes.length > 0) {+        return getStrictestKind(overlappingTypes);+      } else {+        // In case one of the types is "any", get the strictest type of the other array+        if (arrayContainsKind(typesLeft, TypeKind.Any)) {+          return getStrictestKind(typesRight);+        }+        if (arrayContainsKind(typesRight, TypeKind.Any)) {+          return getStrictestKind(typesLeft);+        }++        // In case one array contains NullOrUndefined and the other an Object, return Object+        if (+          (arrayContainsKind(typesLeft, TypeKind.NullOrUndefined) &&+            arrayContainsKind(typesRight, TypeKind.Object)) ||+          (arrayContainsKind(typesRight, TypeKind.NullOrUndefined) &&+            arrayContainsKind(typesLeft, TypeKind.Object))+        ) {+          return TypeKind.Object;+        }+        return undefined;+      }+    }++    /**+     * Check if a specific TypeKind is present in an array+     * @param types array of TypeKinds+     * @param typeToCheck TypeKind to check+     */+    function arrayContainsKind(+      types: TypeKind[],+      typeToCheck: TypeKind,+    ): boolean {+      return types.some(type => type === typeToCheck);+    }++    /**+     * Return the strictest kind of an array+     * @param types array of TypeKinds+     */+    function getStrictestKind(types: TypeKind[]): TypeKind {+      // tslint:disable-next-line:no-unsafe-any+      return Math.max.apply(Math, types);+    }++    /**+     * Check if the operator is a comparison operator+     * @param operator the operator to check+     */+    function isComparisonOperator(operator: string): boolean {+      if (isEqualityOperator(operator)) {+        return true;+      }+      switch (operator) {+        case '<':+        case '>':+        case '<=':+        case '>=':+          return true;+        default:+          return false;+      }+    }++    /**+     * Check if the operator is an equality operator+     * @param operator the operator to check+     */+    function isEqualityOperator(operator: string): boolean {+      switch (operator) {+        case '==':+        case '!=':+        case '===':+        case '!==':+          return true;+        default:+          return false;+      }+    }++    /**+     * Helper function to get base type of node+     * @param node the node to be evaluated.+     */+    function getNodeType(node: TSESTree.Node): ts.Type {+      const tsNode = service.esTreeNodeToTSNodeMap.get(node);+      return typeChecker.getTypeAtLocation(tsNode);+    }++    return {+      BinaryExpression(node: TSESTree.BinaryExpression) {

I added those types myself and in my other PR I noticed that I was missing BinaryExpression

https://github.com/typescript-eslint/typescript-eslint/pull/315/files#diff-d69227db78f612ab8986f26cca8df9f4R410

AndreasGassmann

comment created time in 2 months

pull request commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "enum-const-style" rule

I don't see the failure report in codecov. Can you point me to what's actually not passing?

mohsen1

comment created time in 2 months

create barnchmohsen1/typescript-eslint

branch : mohsen1--no-enum-literals

created branch time in 2 months

push eventmohsen1/typescript-eslint

Armano

commit sha b29cad91cdb3ee3f091af60a96d0c03ac84f1033

test(plugin-tslint): add missing test cases for plugin-tslint (#303)

view details

Johannes Ewald

commit sha 4526f27737ca4982351e2f495c1bd60cb6f1f86e

fix(eslint-plugin): out-of-bounds access in member-ordering rule (#304)

view details

Brad Zacher

commit sha 063518380215fc0b2df777080d247fe222cf258d

docs(*): switch from author file comments to all-contributors (#228)

view details

Denys Kniazevych

commit sha 9a883635a4b0cbf759d1ae791398933d6fb0d614

fix(eslint-plugin): support BigInt in restrict-plus-operands rule (#309) (#310)

view details

James Henry

commit sha d362c4a2051ff4128388fc515ba2f07f0ca1a3aa

chore: publish v1.4.1

view details

Mohsen Azimi

commit sha 4b1292a159cacde11e88aa6a949de30dd7e3cdcc

Add enum-const-style rule

view details

push time in 2 months

push eventmohsen1/typescript-eslint

Brad Zacher

commit sha 25dd589260fc74c7278b272cc27246235e4425bb

Update packages/eslint-plugin/docs/rules/enum-const-style.md Co-Authored-By: mohsen1 <me@azimi.me>

view details

push time in 2 months

Pull request review commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add strict-comparisons rule

+import { TSESTree } from '@typescript-eslint/typescript-estree';+import { isUnionType, isTypeFlagSet } from 'tsutils';+import ts from 'typescript';++import * as util from '../util';++interface Config {+  allowObjectEqualComparison: boolean;+  allowStringOrderComparison: boolean;+}++type Options = [Config];++type MessageIds = 'nonComparableTypes' | 'invalidTypeForOperator';++export default util.createRule<Options, MessageIds>({+  name: 'strict-comparisons',+  meta: {+    type: 'problem',+    docs: {+      category: 'Best Practices',+      description: 'Only allow comparisons between primitive types.',+      tslintRuleName: 'object-comparison',+      recommended: 'error',+    },+    messages: {+      nonComparableTypes:+        "cannot compare type '{{ typesLeft }}' to type '{{ typesRight }}'",+      invalidTypeForOperator:+        "cannot use '{{ comparator }}' comparator for type '{{ type }}'",+    },+    schema: [+      {+        type: 'object',+        properties: {+          allowObjectEqualComparison: {+            type: 'boolean',+          },+          allowStringOrderComparison: {+            type: 'boolean',+          },+        },+        additionalProperties: false,+      },+    ],+  },+  defaultOptions: [+    {+      allowObjectEqualComparison: false,+      allowStringOrderComparison: false,+    },+  ],+  create(+    context,+    [{ allowObjectEqualComparison, allowStringOrderComparison }],+  ) {+    const service = util.getParserServices(context);++    const typeChecker = service.program.getTypeChecker();++    const enum TypeKind {+      Any = 0,+      Number = 1,+      Enum = 2,+      String = 3,+      Boolean = 4,+      NullOrUndefined = 5,+      Object = 6,+    }++    const typeNames = {+      [TypeKind.Any]: 'any',+      [TypeKind.Number]: 'number',+      [TypeKind.Enum]: 'enum',+      [TypeKind.String]: 'string',+      [TypeKind.Boolean]: 'boolean',+      [TypeKind.NullOrUndefined]: 'null | undefined',+      [TypeKind.Object]: 'object',+    };++    /**+     * Get TypeKinds of a typescript type+     * @param type+     */+    function getKinds(type: ts.Type): TypeKind[] {+      return isUnionType(type)+        ? Array.from(new Set(type.types.map(getKind)))+        : [getKind(type)];+    }++    /**+     * Get TypeKind of a typescript type+     * @param type+     */++    function getKind(type: ts.Type): TypeKind {+      // tslint:disable:no-bitwise+      return is(ts.TypeFlags.String | ts.TypeFlags.StringLiteral)+        ? TypeKind.String+        : is(ts.TypeFlags.Number | ts.TypeFlags.NumberLiteral)+        ? TypeKind.Number+        : is(ts.TypeFlags.BooleanLike)+        ? TypeKind.Boolean+        : is(ts.TypeFlags.Null | ts.TypeFlags.Undefined | ts.TypeFlags.Void)+        ? TypeKind.NullOrUndefined+        : is(ts.TypeFlags.Any)+        ? TypeKind.Any+        : TypeKind.Object;+      // tslint:enable:no-bitwise++      function is(flags: ts.TypeFlags) {+        return isTypeFlagSet(type, flags);+      }+    }++    /**+     * Check if a specific TypeKind is present in an array+     * @param typesLeft array of TypeKinds+     * @param typesRight TypeKind to check+     */+    function getStrictestComparableType(+      typesLeft: TypeKind[],+      typesRight: TypeKind[],+    ): TypeKind | undefined {+      const overlappingTypes = typesLeft.filter(+        type => typesRight.indexOf(type) >= 0,+      );++      if (overlappingTypes.length > 0) {+        return getStrictestKind(overlappingTypes);+      } else {+        // In case one of the types is "any", get the strictest type of the other array+        if (arrayContainsKind(typesLeft, TypeKind.Any)) {+          return getStrictestKind(typesRight);+        }+        if (arrayContainsKind(typesRight, TypeKind.Any)) {+          return getStrictestKind(typesLeft);+        }++        // In case one array contains NullOrUndefined and the other an Object, return Object+        if (+          (arrayContainsKind(typesLeft, TypeKind.NullOrUndefined) &&+            arrayContainsKind(typesRight, TypeKind.Object)) ||+          (arrayContainsKind(typesRight, TypeKind.NullOrUndefined) &&+            arrayContainsKind(typesLeft, TypeKind.Object))+        ) {+          return TypeKind.Object;+        }+        return undefined;+      }+    }++    /**+     * Check if a specific TypeKind is present in an array+     * @param types array of TypeKinds+     * @param typeToCheck TypeKind to check+     */+    function arrayContainsKind(+      types: TypeKind[],+      typeToCheck: TypeKind,+    ): boolean {+      return types.some(type => type === typeToCheck);+    }++    /**+     * Return the strictest kind of an array+     * @param types array of TypeKinds+     */+    function getStrictestKind(types: TypeKind[]): TypeKind {+      // tslint:disable-next-line:no-unsafe-any+      return Math.max.apply(Math, types);+    }++    /**+     * Check if the operator is a comparison operator+     * @param operator the operator to check+     */+    function isComparisonOperator(operator: string): boolean {+      if (isEqualityOperator(operator)) {+        return true;+      }+      switch (operator) {+        case '<':+        case '>':+        case '<=':+        case '>=':+          return true;+        default:+          return false;+      }+    }++    /**+     * Check if the operator is an equality operator+     * @param operator the operator to check+     */+    function isEqualityOperator(operator: string): boolean {+      switch (operator) {+        case '==':+        case '!=':+        case '===':+        case '!==':+          return true;+        default:+          return false;+      }+    }++    /**+     * Helper function to get base type of node+     * @param node the node to be evaluated.+     */+    function getNodeType(node: TSESTree.Node): ts.Type {+      const tsNode = service.esTreeNodeToTSNodeMap.get(node);+      return typeChecker.getTypeAtLocation(tsNode);+    }++    return {+      BinaryExpression(node: TSESTree.BinaryExpression) {

you can omit this type

AndreasGassmann

comment created time in 2 months

issue openedtypescript-eslint/typescript-eslint

Rule proposal: prefer `as const`

In a lot of our code we have to cast string literals to literals types to conform to types so assignments work:

  type Styles = {
    position: 'relative' | 'absolute'
  }
  
  let styles = {
    position: 'relative' as 'relative'
  }
  
  let s: Styles = styles 

This is more common when using React HOCs but above example demonstrate the problem well enough.

With TypeScript 3.4 we'll have the as const literal expression which should be preferred to string or number literal types in this case because changing the value does not require changing the type.

Our example code would be better written as:

type Styles = {
  position: "relative" | "absolute";
};

let styles = {
  position: "relative" as const
};

let s: Styles = styles;

More examples:

let a: 'str' = 'str'; // bad 
let a = <'str'>'str'; // bad 
let a = 'str' as 'str' //bad 

let a = 'str' as const // good
// bad
let o = {
    foo: 'string' as 'string'
}

// good
let o = {
    foo: 'string' as const
}

Rule name

Please suggest rule name. I'm not sure how this rule should be named

Options

I can't think of any configurability for this rule

created time in 2 months

issue commentfacebookincubator/idx

Cannot find name 'bigint'

With TypeScript and @types/ packages the stance is that your code will break with any change, including patch versions. idx is shipping it's own types so it's a bit different. That being said, the types here require some minimum version of TypeScript anyways. We're using conditional types that was introduced in TypeScript 3 for instance. We don't want to make TypeScript a peer dependency of idx either, you don't need to have TypeScript to use idx.

I'll leave it to package maintainers to decide. Removing 'bigint' will not break too many people vs. depending on at least TypeScript@3.2

armanozak

comment created time in 2 months

issue commentpiotrwitek/utility-types

Include usage documentations in JSDoc

JSDoc is not that well specified but in most tools I have used the triple backtick was not working. It's not specific to a single directive like @example.

mohsen1

comment created time in 2 months

issue openedtypescript-eslint/typescript-eslint

Rule proposal: Disallow number literals where enums are expected

Do not allow number literals to be used instead of enums. I could think of three places that this can happen:

  • Function arguments
  • Binary expressions
  • Assignment expressions
enum Foo {
    ONE,
    TWO
}

function getFoo(f: Foo) {

    if (f === Foo.ONE) { // Good

    }

    if (f === 1) { // Bad

    }

    let ff: Foo;

    ff = Foo.TWO // Good
    ff = 1 // Bad

}

getFoo(Foo.ONE) // Good
getFoo(1) // Bad

Rule name

I need help with naming it according to conventions

Options

I don't think this rule needs any options. I don't see why anyone wants to use number literals for enums.

created time in 2 months

issue commentpiotrwitek/utility-types

Include usage documentations in JSDoc

note that the JSDoc markdown doesn't support triple backtick code blocks. You must indent code blocks.

mohsen1

comment created time in 2 months

issue commentfacebookincubator/idx

Cannot find name 'bigint'

You need to upgrade to TypeScript 3.2

armanozak

comment created time in 2 months

pull request commentfacebookincubator/idx

Fix UnboxDeepRequired type

@yungsters I believe this is good to go

mohsen1

comment created time in 2 months

Pull request review commentDefinitelyTyped/DefinitelyTyped

Include potential statusCode for next.js Error return

 declare namespace next {         /** Fetch Response object (client only) - from https://developer.mozilla.org/en-US/docs/Web/API/Response */         jsonPageRes?: NodeResponse;         /** Error object if any error is encountered during the rendering */-        err?: Error;+        err?: Error & {statusCode? : number};

It looks like that the type of err is not Error. Guessing it's a Response object?

rgbkrk

comment created time in 2 months

push eventmohsen1/typescript-eslint

Olga Isakova

commit sha 4de93058bb250a8a78af6f11fa359613d0c9d0f2

docs(eslint-plugin): correct version typo in documentation url (#302)

view details

Mohsen Azimi

commit sha 9540bac65b019559044281d8ff3901bbd4b1f5db

Merge branch 'master' into mohsen1--enum-style

view details

push time in 2 months

pull request commenttypescript-eslint/typescript-eslint

feat(eslint-plugin): add "enum-const-style" rule

I don't get any coverage errors locally. How can I re-run it?

mohsen1

comment created time in 2 months

more