bradzacher Github contribution chart
bradzacher Github Stats
bradzacher Most Used Languages

Activity

29 Sep 2022

Bradzacher

Question: [@typescript-eslint/naming-convention] Disable rule for certain typescript types

Before You File a Bug Report Please Confirm You Have Done The Following...

  • [X] I have tried restarting my IDE and the issue persists.
  • [X] I have updated to the latest version of the packages.
  • [X] I have searched for related issues and found none that matched my issue.
  • [X] I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.8.3&sourceType=module&showAST=es&code=MYewdgzgLgBAZgUwQEwPICMBWDhQFwwAeAtgDYB0AGmRtrjALwwDeAUDDAE4QQEDa7DixgB9AIZQonAsxgA3BNwCW4AgHIATOQAMagDQw1JUpDwSQxNeoAWkgA54A9I4Dub8i4DM5EJwDmjhra2gCsjgCCUBZqMAC+cXqCALqJsQDcQA

Repro Code

const feedObject = {
   rss: [
      { _attr: { version: '2.0', 'xmlns:atom': 'http://www.w3.org/2005/Atom' } },
   ],
}; 

ESLint Config

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "warnOnUnsupportedTypeScriptVersion": false,
    "project": "tsconfig.json",
    "sourceType": "module",
    "ecmaVersion": "latest"
  },
  "rules": {
    "@typescript-eslint/naming-convention": [
      "error",
      {
        "selector": "TSQualifiedName[name=XmlObject]",
        "format": null
      }
    ]
  }
} 

tsconfig

{
  "module": "node16",
  "compilerOptions": {
    "moduleResolution": "node16",
    "resolveJsonModule": true,
    "types": [
      "node"
    ],
  },
} 

Expected Result

I would expect the "naming-convention" rule to be disabled on any object of type XmlObject.

Actual Result

BaseConfig: Configuration for rule "@typescript-eslint/naming-convention" is invalid: Value "TSQualifiedName[name=XmlObject]" should be array. Value "TSQualifiedName[name=XmlObject]" should be equal to one of the allowed values.

Additional Info

Am I safe to assume the @typescript-reslint/* rule do not allow for the full AST identifier selectors? I foud the following example, which is a ESLint rule, which does seem to correctly parse: https://typescript-eslint.io/docs/linting/troubleshooting/#how-can-i-ban-specific-language-feature

Versions

| package | version | | -------------------------------------- | ------- | | @typescript-eslint/eslint-plugin | 5.35.1 | | @typescript-eslint/parser | 5.35.1 | | TypeScript | 4.8.3 | | ESLint | 8.22.0 | | node | 16.17.0 | | xo | 0.52.3 |

Forked On 29 Sep 2022 at 09:05:40

Bradzacher

It does not allow for arbitrary AST selectors. The only supported selectors are listed in the docs.

The docs also list ways in which you can allowlist/ignore specific names. Check out the examples under this heading https://typescript-eslint.io/rules/naming-convention/#ignore-properties-that-require-quotes


Arbitrary AST selectors wouldn't make sense in the context of the rule IMO - the basic cases are already covered by the selectors and modifiers in the rule, and the advanced cases would be too hyper-specific to be useful beyond one or two cases.

Commented On 29 Sep 2022 at 09:05:40

Bradzacher

Enhancement: [prefer-optional-chain] Suggest optional chain when the start of the expression is already optionally chained

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • [X] I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/prefer-optional-chain/

Description

I propose that the prefer-optional-chain should suggest combining logical expressions that start with an optional chain

Discovered while making test cases in #5594

Fail

foo?.bar && foo.bar?.() && foo.bar?.().baz 

Pass

foo?.bar?.()?.baz 

Additional Info

No response

Forked On 29 Sep 2022 at 01:49:35

Bradzacher

Yeah the only issue I've found is that it really is suuuper complicated to write all the logic to make this work.

It looks so easy on paper, but comparing two asts and understanding how they relate in the general case to determine the appropriate fix is just really difficult to do.

Commented On 29 Sep 2022 at 01:49:35

Bradzacher

Bug: [no-floating-promises] Incorrect handling of finally calls

Before You File a Bug Report Please Confirm You Have Done The Following...

  • [X] I have tried restarting my IDE and the issue persists.
  • [X] I have updated to the latest version of the packages.
  • [X] I have searched for related issues and found none that matched my issue.
  • [X] I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.8.3&sourceType=module&code=MYewdgzgLgBAJgUwLYgGIFczCgS3ALhgAocwAHdKQgIxBABsEBDMAShgF4A+GABQCcQSHBAQAeaP1IBzHh2KkKVGLQbM2nHgG8AUDBg4AZgvKV2u-fv4Io6fmD6DhogHTWIDAG4IiAcgAWCPT0IDAA7iD89HC+rADcejAAvjBBojAWlta29o5CIghuCABWCNh+ipThTBAwhkz0orEJ+kk6bTqIKBhYuOBEUPzoCKwuUIFgRETs3BmJoJBqLiHSfgCiYFAI1nAw4whgze2jhqQN9ACeUzPa8+AejMsgq74bWzt1Z8EXR0nxQA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDN4OBDfMwDmtYtA4BbSshTooiaBOiRwYAL4h1QA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

demoFunction(true).then(() => {
  console.log('Entered then');
}).finally(() => {
  console.log('Entered finally');
}); 

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-floating-promises": ["error"],
  },
}; 

tsconfig

No response

Expected Result

There is no .catch call, and the rule should report it.

Actual Result

Nothing reported

Additional Info

No response

Versions

| package | version | | -------------------------------------- | ------- | | @typescript-eslint/eslint-plugin | 5.31.0 | | @typescript-eslint/parser | 5.31.0 | | TypeScript | 4.7.4 | | ESLint | 8.20.0 | | node | 18.7.0 |

Forked On 27 Sep 2022 at 08:00:46

Bradzacher

In #1620 it was written that .finally should be treated like a .catch, which isn't correct, because .finally is "transparent" in regards to the promise chain - the value returned from .finally does not change the settled value of the promise unless the .finally handler throws an error.

So what should the handling be?

I think that .finally should essentially be completely ignored by the rule - it shouldn't end a chain, it shouldn't start a new chain - it should just be skipped over and the rule should pretend like it wasn't there.

I.e.

// BAD
prom;
prom.then(f); 
prom.finally(f);
prom.then(f).finally(f);
prom.finally(f).then(f).finally(f);

// GOOD
prom.then(f, f).finally(f);
prom.catch(f).finally(f);
prom.then(f).catch(f).finally(f);
prom.then(f).finally(f).catch(f).finally(f);
prom.catch(f).finally(f).finally(f).finally(f).finally(f).finally(f).finally(f).finally(f); 

Commented On 27 Sep 2022 at 08:00:46

Bradzacher

Rule proposal: disallow duplicate union and intersection types

I would like to propose a new rule: no-duplicate-union-intersection.

This rule reports duplicates in unions and intersections. The autofixer will remove all duplicates, keeping the first one.

The following lines will be reported:

type A = 1 | 2 | 3 | 1;
type B = 'foo' | 'bar' | 'foo';
type C = A | B | A | B; 

This will be autofixed to:

type A = 1 | 2 | 3;
type B = 'foo' | 'bar';
type C = A | B; 

The rule won’t try to resolve references. This may be an addition for later.

If this is accepted, I’m willing to implement this.

Forked On 27 Sep 2022 at 07:33:13

Bradzacher

Currently open for anyone to work on - just needs a champion to implement it!

Commented On 27 Sep 2022 at 07:33:13

Bradzacher

Review and change

Before You File a Proposal Please Confirm You Have Done The Following...

Description

I want to learn about all information how I can get fast action of my auto review required setting request.

Impacted Configurations

I need review my all setting and Change Automatically. Also I want to learn Code to conduct information how I can apply on my all time.

Additional Info

How I get all valuable information about ( should follow its contributing guidelines and code of conduct.) Please review and give me Automatic Button.

Forked On 25 Sep 2022 at 12:13:05

Bradzacher

I'm not sure I understand what you're asking. I can't see anything about bugs or enhancements for our project, or even a question related to our project.

Cpuod you please clarify what you're asking?

Commented On 25 Sep 2022 at 12:13:05

Bradzacher

Bug: [@typescript-eslint/no-shadow] false positive with augmented modules

Before You File a Bug Report Please Confirm You Have Done The Following...

  • [X] I have tried restarting my IDE and the issue persists.
  • [X] I have updated to the latest version of the packages.
  • [X] I have searched for related issues and found none that matched my issue.
  • [x] I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=4.8.3&sourceType=module&code=JYWwDg9gTgLgBDAnmApnA3nAsogKstAXzgDMoIQ4ByAOgHolUBnKgbgCh2ATFAYwBsAhlDQgIXAK780tBgRYZ2cBAWx5VAXgykIEAFxwmMKMAB2AcziEOhTigAekWHF4RTRuACNhBnPlRwWpgkugZUAIwATFRWHEA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1uQAsBDACYcA7uiiJo0DtEjgwAXxDygA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA

Repro Code

import type { MyType } from './types';

declare module './types' {
  type MyType = { foo: string };
}

export const bar: MyType = { foo: '' }; 

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/no-shadow": "error"
  },
}; 

tsconfig

No response

Expected Result

No error is expected on line 4 column 8.

Actual Result

Error is reported: 'MyType' is already declared in the upper scope on line 1 column 15.

Additional Info

No response

Versions

| package | version | | -------------------------------------- | ------- | | @typescript-eslint/eslint-plugin | 5.33.0 | | @typescript-eslint/parser | 5.35.1 | | TypeScript | 4.7.4 | | ESLint | 8.23.0 | | node | 16.14.2 |

Forked On 25 Sep 2022 at 12:09:27

Bradzacher

It's not technically shadowing - it's declaration merging. This particular form is a really rare pattern, but it's valid.

Commented On 25 Sep 2022 at 12:09:27

Bradzacher

chore: Bump @swc/core from 1.3.2 to 1.3.3 (#5687)

Bumps @swc/core from 1.3.2 to 1.3.3.


updated-dependencies:

  • dependency-name: "@swc/core" dependency-type: direct:development update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Pushed On 24 Sep 2022 at 07:23:46

Bradzacher

chore: Bump @swc/core from 1.3.2 to 1.3.3

Created On 24 Sep 2022 at 07:23:46

Bradzacher

chore: Bump rollup from 2.79.0 to 2.79.1 (#5686)

Bumps rollup from 2.79.0 to 2.79.1.


updated-dependencies:

  • dependency-name: rollup dependency-type: direct:development update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Pushed On 24 Sep 2022 at 07:23:34

Bradzacher

chore: Bump rollup from 2.79.0 to 2.79.1

Created On 24 Sep 2022 at 07:23:34

Bradzacher

chore: Bump @types/prettier from 2.7.0 to 2.7.1 (#5685)

Bumps @types/prettier from 2.7.0 to 2.7.1.


updated-dependencies:

  • dependency-name: "@types/prettier" dependency-type: direct:production update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Pushed On 24 Sep 2022 at 07:23:23

Bradzacher

chore: Bump @types/prettier from 2.7.0 to 2.7.1

Created On 24 Sep 2022 at 07:23:23

Bradzacher

chore: Bump @microsoft/api-extractor from 7.31.1 to 7.31.2 (#5684)

Bumps @microsoft/api-extractor from 7.31.1 to 7.31.2.


updated-dependencies:

  • dependency-name: "@microsoft/api-extractor" dependency-type: direct:development update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Pushed On 24 Sep 2022 at 07:23:13

Bradzacher

chore: Bump @microsoft/api-extractor from 7.31.1 to 7.31.2

Created On 24 Sep 2022 at 07:23:13

Bradzacher

chore: Bump lerna from 5.5.1 to 5.5.2 (#5683)

Bumps lerna from 5.5.1 to 5.5.2.


updated-dependencies:

  • dependency-name: lerna dependency-type: direct:development update-type: version-update:semver-patch ...

Signed-off-by: dependabot[bot] support@github.com

Signed-off-by: dependabot[bot] support@github.com Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Pushed On 24 Sep 2022 at 07:23:03

Bradzacher

chore: Bump lerna from 5.5.1 to 5.5.2

Created On 24 Sep 2022 at 07:23:03

Bradzacher

Docs: How is `@typescript-eslint/no-unused-vars` different than TypeScript’s own errors?

Suggested Changes

Every unused variable is marked by both TypeScript and this rule. Why does it exist? It seems to be a duplicate. If it isn't a duplicate, can you explain why in the documentation?

'a' is assigned a value but never used. eslint[@typescript-eslint/no-unused-vars](https://typescript-eslint.io/rules/no-unused-vars)
'a' is declared but its value is never read. ts(6133) 

It would also be great to include this explanation or a link to it in the documentation:

  • https://github.com/typescript-eslint/typescript-eslint/issues/438

Affected URL(s)

https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unused-vars.md

Forked On 24 Sep 2022 at 04:19:02

Bradzacher

@sukima https://typescript-eslint.io/docs/linting/troubleshooting#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code

Commented On 24 Sep 2022 at 04:19:02

Bradzacher

feat: update resume

Pushed On 23 Sep 2022 at 06:31:57

Bradzacher

chore(website): update outdated custom rule example (#5674)

Pushed On 23 Sep 2022 at 03:53:14

Bradzacher

chore(website): update outdated custom rule example

Created On 23 Sep 2022 at 03:53:10

Bradzacher

chore(website): update outdated custom rule example

PR Checklist

Overview

Updates the rule example to use createRule the way the rest of the file does.

fyi @vkarpov15

Merged On 23 Sep 2022 at 03:53:02

Bradzacher

Commented On 23 Sep 2022 at 03:53:02