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

@kong/eslint-config-kong-ui

v1.1.1

Published

Sharable ESLint configuration for Kong's frontend repositories

Downloads

3,290

Readme

@kong/eslint-config-kong-ui

A shared ESLint configuration for Kong's frontend repositories.

[!Note] This package only supports ESLint flat config files and requires eslint >= 9.0.0.

Beginning in ESLint v9.0.0, the default configuration system utilizes a new flat config system. See the Migration Guide for more information.

Usage

Installation

Install the @kong/eslint-config-kong-ui package as a devDependency in your host project.

pnpm add -D @kong/eslint-config-kong-ui

# or for a mono repository, install to the workspace root
pnpm add -wD @kong/eslint-config-kong-ui

Available Configs

This package exports several ESLint configurations to use in your project. Read through the available configs below, and see the Setup section for instructions on how to add them to your project.

Default config

The default config provides linting for files matching this pattern **/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts,vue} and includes rules configured via:

  • ESLint recommended rules
  • TypeScript recommended rules
  • eslint-plugin-vue
  • eslint-plugin-promise
  • ESLint Stylistic rules configured for our preferred formatting settings
  • ...and more. See index.mjs to view the configuration.

The default config can be imported as shown here:

import eslintKongUiConfig from '@kong/eslint-config-kong-ui'
// or
import eslintKongUiConfig from '@kong/eslint-config-kong-ui/default'

JSON config

The JSON config provides linting for files matching this pattern **/*.{json,jsonc} and includes rules and preferred formatting settings configured via eslint-plugin-jsonc.

The JSON config can be imported as shown here:

import eslintKongUiConfigJson from '@kong/eslint-config-kong-ui/json'

[!Note] You will likely only want to apply the JSON config to a subset of file patterns in your project. See the section on applying a config to a subset of files for detailed instructions.

Cypress config

The Cypress config includes all settings from the Default config and provides additional rules for Cypress test files, given a pattern for files that your host project provides, and includes rules and preferred formatting settings configured via eslint-plugin-cypress, as well as the ESLint and TypeScript ESLint recommended settings. See cypress.mjs to view the configuration.

The Cypress config can be imported as shown here:

import eslintKongUiConfigCypress from '@kong/eslint-config-kong-ui/cypress'

[!Note] You will likely only want to apply the Cypress config to a subset of file patterns in your project. See the section on applying a config to a subset of files for detailed instructions.

Setup

To use the shared config, import the package inside of an eslint.config.mjs file and add it into the exported array, like this:

// eslint.config.mjs
import eslintKongUiConfig from '@kong/eslint-config-kong-ui'

export default [
  ...eslintKongUiConfig,
]

Overriding settings from the shared config

You can override settings from the shareable config by adding them directly into your eslint.config.mjs file after importing the shareable config. For example:

// eslint.config.mjs
import eslintKongUiConfig from '@kong/eslint-config-kong-ui'

export default [
  ...eslintKongUiConfig,
  // anything from here will override eslintKongUiConfig
  {
    rules: {
        'no-unused-vars': 'error',
    }
  }
]

Apply a config to a subset of files

You can apply a config array to just a subset of files by using the map() method to add a files key to each config object.

For example, you may only want to apply the JSON config to **/locales/**/*.json files in your project (this is our practice at Kong):

// eslint.config.mjs
import eslintKongUiConfig from '@kong/eslint-config-kong-ui'
import eslintKongUiConfigJson from '@kong/eslint-config-kong-ui/json'
import eslintKongUiConfigCypress from '@kong/eslint-config-kong-ui/cypress'

export default [
  // Use the main config for all other files
  ...eslintKongUiConfig,
  // Only apply the shared JSON config to files that match the given pattern
  ...eslintKongUiConfigJson.map(config => ({
    ...config,
    files: ['**/locales/**/*.json']
  })),
  // Only apply the shared Cypress config to files that match the given pattern
  ...eslintKongUiConfigCypress.map(config => ({
    ...config,
    files: [
      '**/*.cy.ts',
      '**/cypress/**',
      'cypress/integration/**.spec.{js,ts,jsx,tsx}',
      'cypress/integration/**.cy.{js,ts,jsx,tsx}',
    ]
  })),
  // your modifications
  {
    rules: {
      'no-unused-vars': 'error',
    }
  }
]

Contributing & Local Development

To get started, install the package dependencies

pnpm install

Lint and fix

Lint package files, and optionally auto-fix detected issues.

# ESLint only
pnpm lint

# ESLint and fix
pnpm lint:fix

Committing Changes

Commitizen friendly

This repo uses Conventional Commits.

Commitizen and Commitlint are used to help build and enforce commit messages.

It is highly recommended to use the following command in order to create your commits:

pnpm commit

This will trigger the Commitizen interactive prompt for building your commit message.

Enforcing Commit Format

Lefthook is used to manage Git Hooks within the repo.

  • A commit-msg hook is automatically setup that enforces commit message stands with commitlint, see lefthook.ymal
  • A pre-push hook is used that runs eslint before allowing you to push your changes to the repository

Additionally, CI will use commitlint to validate the commits associated with a PR in the Lint Commit Messages job.

Package Publishing

This repository utilizes Semantic Release for automated package publishing and version updates.