npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-interface-method-style

v1.1.5

Published

ESLint plugin to enforce consistent method style between interfaces and their implementations

Downloads

1,593

Readme

eslint-plugin-interface-method-style

ESLint rule to enforce consistent method implementation styles between TypeScript interfaces and their implementations.

npm npm GitHub FOSSA Status

Table of Contents

Introduction

In large TypeScript codebases, maintaining consistency between interfaces and their implementations is crucial for code readability and maintainability. This ESLint plugin ensures that methods and properties defined in TypeScript interfaces or type aliases are implemented using the same syntax in classes and object literals.

Features

  • 🎯 Method Style Consistency: Ensures consistent method and property styles.
  • 🚀 Supports Classes and Object Literals: Works with classes and object literals.
  • TypeScript Compatibility: Supports TypeScript interfaces and type aliases.

Installation

npm

npm install eslint-plugin-interface-method-style --save-dev

Yarn

yarn add eslint-plugin-interface-method-style --dev

pnpm

pnpm add eslint-plugin-interface-method-style --save-dev

Usage

Add interface-method-style to your ESLint configuration.

Config (eslint.config.mjs)

import interfaceMethodStyle from "eslint-plugin-interface-method-style";

export default [
  // ...
  interfaceMethodStyle.configs.recommended,
];

Legacy Config (.eslintrc.json)

Add interface-method-style to the plugins section of your configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["interface-method-style"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "interface-method-style/interface-method-style": "error"
  }
}

Rule Details

This rule enforces that the implementation of methods and properties matches their definitions in the interfaces or type aliases:

  • Methods defined with method(): void must be implemented as methods
  • Properties defined with method: () => void must be implemented as arrow functions

✅ Correct

interface Foo {
  method(): void;
  property: () => void;
}

class Bar implements Foo {
  method() {
    console.log("method");
  }

  property = () => {
    console.log("property");
  };
}

❌ Incorrect

interface Foo {
  method(): void;
  property: () => void;
}

class Bar implements Foo {
  method = () => {
    console.log("method");
  };

  property() {
    console.log("property");
  }
}

License

FOSSA Status