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

@soybeanjs/eslint-config

v1.4.2

Published

SoybeanJS's eslint flat config presets with prettier.

Downloads

404

Readme

@soybeanjs/eslint-config

English | 中文

SoybeanJS 的 ESLint 扁平化配置预设,包含 prettier。

  • 默认配置支持 JavaScript 和 TypeScript。
  • 支持 Vue、React、ReactNative、Solid、Svelte 和 Astro。
  • 使用 ESlint 和 Prettier 格式化 HTML、CSS、LESS、SCSS、JSON、JSONC、YAML、TOML、Markdown。

用法

安装

pnpm i -D eslint typescript @soybeanjs/eslint-config

ESLint 配置文件

  • package.json 中添加 "type": "module"

  • 创建配置文件 eslint.config.js

  • 导入配置 @soybeanjs/eslint-config

import { defineConfig } from '@soybeanjs/eslint-config';

export default defineConfig({
  // options
});

[!NOTE] 查看 Options 获取更多细节。

VSCode 中的 ESLint 设置

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },
  "editor.formatOnSave": false,
  "eslint.experimental.useFlatConfig": true,
  "eslint.validate": [
    // "javascript", // 默认支持
    // "javascriptreact", // 默认支持
    // "typescript",  // 默认支持
    // "typescriptreact", // 默认支持
    // "vue", // 默认支持
    // 添加你想要检查和格式化的语言
    "svelte",
    "astro",
    "html",
    "css",
    "json",
    "jsonc",
    "yaml"
    "toml",
    "markdown"
  ],
  "prettier.enable": false
}

在package.json 中添加命令

{
  "scripts": {
    "lint": "eslint . --fix"
  }
}

配置

interface Options

interface Options {
  /**
   * 项目根目录
   *
   * @default process.cwd()
   */
  cwd: string;
  /**
   * 被忽略的 glob
   */
  ignores: string[];
  /**
   * 覆盖的规则
   */
  overrides?: FlatConfigItem['rules'];
  /**
   * 默认的Prettier配置
   *
   * @default
   * ```json
   * {
   *   "printWidth": 120,
   *   "singleQuote": true,
   *   "trailingComma": "none",
   *   "arrowParens": "avoid",
   *   "htmlWhitespaceSensitivity": "ignore"
   * }
   * ```
   */
  prettierRules: PartialPrettierExtendedOptions;
  /**
   * 是否使用 prettierrc 进行 prettier 配置
   *
   * 如果为 true,prettierrc 中的规则将会覆盖默认规则
   *
   * @default true
   */
  usePrettierrc: boolean;

  /**
   * 格式化器
   * @default 默认支持的格式化器
   * {
   *  "html": true,
   *  "css": true,
   *  "json": true,
   * }
   */
  formatter: {
    html?: boolean;
    css?: boolean;
    json?: boolean;
    markdown?: boolean;
    yaml?: boolean;
    toml?: boolean;
  };
  vue?: VueOptions | boolean;
  react?: RuleBaseOptions | boolean;
  'react-native'?: RuleBaseOptions | boolean;
  solid?: RuleBaseOptions | boolean;
  svelte?: RuleBaseOptions | boolean;
  astro?: RuleBaseOptions | boolean;
}

type RuleBaseOptions<T = NonNullable<unknown>> = T & {
  /**
   * 需要被检测的文件
   */
  files?: string[];
};

type VueOptions = RuleBaseOptions<{
  /**
   * Vue 版本
   *
   * @default 3
   */
  version?: 2 | 3;
}>;

感谢

灵感来自以下项目: