You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

eslint-plugin-demo-typescript

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-demo-typescript

Demonstrating an eslint plugin written in TypeScript

0.0.1
latest
Source
npm
Version published
Weekly downloads
4
-82.61%
Maintainers
0
Weekly downloads
 
Created
Source

Writing a custom ESLint plugin with TypeScript code

This repo is based on the "Writing a custom ESLint plugin with Typescript" Medium article written by Adam Thompson .

Why this repo?

I was expecting to find a link to a repo with the full code explained in Adam's article but I could not find it.

It will be a quick way to browse the full code on its own and possibly to enhance it by fixing issues.

Getting started

I worked on this repo using pnpm but I should work with other package manager.

Install

pnpm i

Build

pnpm build

Test

Tests were setup to work with jest and vitest both comes with pros and cons...

I would recommend Vitest but I also added Jest in case you want it.

JestVitest
Based on commonjsBased on ESM
✅ Mocking✅ Mocking
✅ Snapshots✅ Snapshots
✅ Parallel testing✅ Parallel testing
✅ Fast✅ Often faster
-✅ Support benches
❌ Require ts-jest lib❌ Requires setupFile and vitest.config.ts

NB: In order to use, the RuleTester from @typescript-eslint/rule-tester, we must:

  • Have a tsconfig.json with:
    {
      "compilerOptions": {
        "module": "nodenext",
        "moduleResolution": "nodenext"
      }
    }
    
    More info can be found on v6: Cannot find module @typescript-eslint/* or its corresponding type declarations.

    You can use bundler, node16, or nodenext for moduleResolution.

  • Use eslint with v8, typescript-eslint does not support v9 yet
Using vitest

pnpm test

Using jest

pnpm test:jest

Docs

npx eslint-doc-generator --init-rule-docs will create new files for each rule if necessary.

npx eslint-doc-generator will update existing files and the rules list.

You can see an example of generated documentation in the nex section.

Rules

💡 Manually fixable by editor suggestions.

NameDescription💡
my-ruleAn example ESLint rule💡

Keywords

eslint

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts