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-config-outsider

v0.0.1

Published

eslint config for hybrid web

Downloads

4

Readme

English | 中文

eslint-config-outsider

本项目是一个eslint的可扩展配置,用于配置前端代码规范,支持Javascript、Typescript、React、Vue项目。

本项目有以下特点:

  1. 支持JavaScript、Typescript、React、Vue项目。
  2. 如果使用本项目不需要再使用 prettier 进行代码美化,拥抱stylistic。参考这篇文章 antfu - 为什么我不使用 Prettier.
  3. 兼容并继承了eslint-config-airbnb-base的最佳实践。由于eslint-config-airbnb-base年久失修,本项目关闭了和code style相关的规则,使用了stylistic进行代码风格的校验。
  4. 兼容并继承了eslint-config-airbnb-typescript的最佳实践。由于eslint-config-airbnb-typescript年久失修,本项目移除了 typescript-eslint@8 废弃的规则,使其可以完美地在 typescript-eslint@8 下工作。

在全局上,使用了stylistic进行代码风格的美化校验。

在JavaScript规则上,本项目扩展了优秀的javascript规范 eslint-config-airbnb-base,但是由于该项目很久没有维护,为了兼容新的eslint变更,本项目关闭了和code style相关的规则。

在TypeScript规则上,本项目扩展了优秀的typescript规范 eslint-config-airbnb-typescript,但是由于该项目也很久没有维护,对于eslint-typescript@8存在兼容性问题,本项目仅沿用了eslint-config-airbnb-typescript的部分规则,解决了eslint-typescript@8的兼容性问题。

在 React 规则上,本项目使用了 eslin-plugin-react/recommendedeslint-plugin-react-hooks/recommended。如果需要 a11y 的内容请自行添加。

在 Vue 规则上,本项目使用了 eslint-plugin-vue/recommended

本项目继续使用 eslint@8,并没有使用 eslint@9 新增的 flat config 特性。

用法

本项目为以下类型的项目提供可配置项:

  • JavaScript
  • Typescript
  • React
  • Vue3
  • Vue2

| 项目类型 | extends | 描述 | | ---- | ------- | ----------- | | JavaScript | eslint-config-outsider/javascript | 为JavaScript项目提供eslint配置 | | Typescript | eslint-config-outsider | (默认)为JavaScript + Typescript混合项目提供eslint配置 | | React | eslint-config-outsider/react | 为React项目提供eslint配置 | | Vue3 | eslint-config-outsider/vue3 | 为Vue3代码风格项目提供eslint配置 支持Vue2.7 | | Vue2 | eslint-config-outsider/vue2 | 为Vue2代码风格项目提供eslint配置 |

安装

npm i -D eslint-config-outsider

假设以 typescript 项目为例,在项目根目录创建 .eslintrc.cjs文件:

module.exports = {
  root: true,
  extends: [
    'eslint-config-outsider'
  ],
  parserOptions: {
    project: true, // or replaced by path of tsconfig.json file
  },
  ignorePatterns: [
    'node_modules',
    'dist',
    'public',
  ],
};

Typescript

如果是Typescript项目,需要额外配置parserOptions.project,指向你的tsconfig.json文件。

可以设置parserOptions.projecttrue,表示使用当前目录下的tsconfig.json文件。如果项目表示找不到tsconfig.json文件,可以设置parserOptions.project为具体的tsconfig.json文件路径。

Vite

如果你的项目使用Vite,tsconfig文件可能有references字段,如:

{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" }
  ]
}

需要将parserOptions.project设置为数组:

parserOptions: {
  project: [
    `${__dirname}/tsconfig.json`,
    `${__dirname}/tsconfig.app.json`,
    `${__dirname}/tsconfig.node.json`,
  ]
},

参考