Code Monkey home page Code Monkey logo

Comments (8)

spence-s avatar spence-s commented on July 29, 2024 1

ahh I see - ok - yah that works, I can pin my version to be the same. thanks for the quick help @Shinigami92!

Going to leave this open for the community in case someone else runs into the same thing, but feel free to close if you want.

from eslint-define-config.

spence-s avatar spence-s commented on July 29, 2024 1

@Shinigami92 - I actually changed my approach a bit so that this libs types override anything from eslint so I no longer have the problem at all. (even without the patch) - I do appreciate your quick attention to this though! 🙌🏻

from eslint-define-config.

Shinigami92 avatar Shinigami92 commented on July 29, 2024

Hope that issue was clear, thanks!

Not 100% yet, could you link me the definitely typed and maybe also provide a reproducible so I understand better what the issue is?

from eslint-define-config.

spence-s avatar spence-s commented on July 29, 2024

https://stackblitz.com/edit/typescript-zgntds?file=index.ts

import type { Rules } from 'eslint-define-config';
import type { Linter } from 'eslint';

const rules1: Rules = {};
const rules2: Linter.RulesRecord = {};

const rules: Linter.RulesRecord = {
  ...rules1,
  ...rules2,
};

Yes here is a minimal example showing the problem with a stackblitz. In strict mode Rules are not assignable to Linter.RulesRecord

from eslint-define-config.

Shinigami92 avatar Shinigami92 commented on July 29, 2024

eslint-define-config uses

https://github.com/Shinigami92/eslint-define-config/blob/48e0ae4e6789056d4c8a4aefab45d537692f8cac/package.json#LL57C25-L57C26

Could you try downgrading and pin your @types/eslint to that? And try again?
The version did change really much and sometimes breaking changes are not covered in semver for TS types.
So maybe I just then need to bump the deps and recreate the Rules and everything. But when I have the time...

from eslint-define-config.

Shinigami92 avatar Shinigami92 commented on July 29, 2024

ahh I see - ok - yah that works, I can pin my version to be the same. thanks for the quick help @Shinigami92!

Going to leave this open for the community in case someone else runs into the same thing, but feel free to close if you want.

Perfect 👍
Thanks for the info
I will act when I have the time

from eslint-define-config.

Shinigami92 avatar Shinigami92 commented on July 29, 2024

I had a first look and it takes more time than just some minutes

I need to update many rules especially the generation for eslint-plugin-{node/N} and there seems not to be two changes that might have made my own type-defs incompatible with eslint new defs

// These are my own types
export type RuleSeverity = 'off' | 'warn' | 'error' | 0 | 1 | 2;

export type RuleConfig<Options extends unknown[] = unknown[]> =
  | RuleSeverity
  | [RuleSeverity, ...Options];


// These are the new eslint types
type Prepend<Tuple extends any[], Addend> = ((_: Addend, ..._1: Tuple) => any) extends (..._: infer Result) => any
    ? Result
    : never;

type Severity = 0 | 1 | 2;

type RuleLevel = Severity | "off" | "warn" | "error";
type RuleLevelAndOptions<Options extends any[] = any[]> = Prepend<Partial<Options>, RuleLevel>;

type RuleEntry<Options extends any[] = any[]> = RuleLevel | RuleLevelAndOptions<Options>;
  1. it extends any[] instead of unknown[]
  2. It uses Partial for Options

I assume one of these both breaks it
But also that way my types are stronger!

Maybe I could even harden the types on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/808bf075ca716aab85e3e317b49d8638cacc23a5/types/eslint/index.d.ts#L717-L719 instead of loosing my types

The biggest problem!: I cannot use @types/eslint in my src!!! Because then I would enforce @types/eslint to be installed for everyone using my plugin. But it is "just" a devDependency and so I would need to sync my types with them somehow.

... I need more time to investigate this and dig deeper (so sadly maybe not today)

from eslint-define-config.

Shinigami92 avatar Shinigami92 commented on July 29, 2024

@spence-s would you like to give me feedback if everything is working as needed?

from eslint-define-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.