Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Overriding default rules #297

Open
ubbe-xyz opened this issue Jun 11, 2020 · 5 comments
Open

Overriding default rules #297

ubbe-xyz opened this issue Jun 11, 2020 · 5 comments

Comments

@ubbe-xyz
Copy link

ubbe-xyz commented Jun 11, 2020

Summary

Hi 👋🏻 ,

I'm using dstlint to help type an existing library, next-auth, that runs on top of NextJS:

nextauthjs/next-auth#220

The library depends on a few types from NextJS...

import type { NextApiRequest, NextApiResponse } from 'next';
// ...
function NextAuth(req: NextApiRequest, res: NextApiResponse, options?: InitOptions): Promise<void>;

When running dtslint, it tries to parse the types from NextJS and throws an error given there's a // ts-ignore comment somewhere on them:

$ npx dtslint types
Error: At /Users/lluis.agusti/Code/next-auth/node_modules/next/types/index.d.ts:{"line":14,"character":6}: 'ts-ignore' is forbidden.
    at /Users/lluis.agusti/Code/next-auth/node_modules/dtslint/bin/index.js:198:19
    at Generator.next (<anonymous>)
    at fulfilled (/Users/lluis.agusti/Code/next-auth/node_modules/dtslint/bin/index.js:6:58) 

Following the docs, I tried to override that linting rule by writing my own tslint.json but it didn't make the error go away ( maybe it only applies to our declaration files? )

Any chance we could get some help on this?

@orta
Copy link
Contributor

orta commented Jul 20, 2020

We shouldn't raise errors like this for .d.ts files inside node_modules IMO

@Haroenv
Copy link

Haroenv commented Aug 21, 2020

Where would the code be for that?

dtslint/src/lint.ts

Lines 51 to 55 in 285e5a9

if (!isExternalDependency(file, dirPath, lintProgram) &&
(inTypesVersionDirectory || !isTypesVersionPath(fileName, dirPath))) {
linter.lint(fileName, text, config);
}
}

but then add it behind a feature flag to not lint "dependencies" at all? Or am I misunderstanding the code?

@orta
Copy link
Contributor

orta commented Aug 21, 2020

It looks like there's some intentional code under that to run linters against external code - @sandersn any idea what the goal for that is?

@afontcu
Copy link

afontcu commented Nov 24, 2020

Hi! Stumbled upon this issue because I'm facing the same problem – a broken CI pipeline due to a dependency using ts-ignore. Has anyone found a valid workaround? 😃 Adding a local tslint.json and disabling the check did not work.

@JounQin
Copy link

JounQin commented Feb 20, 2021

related #89 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants