惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
爱范儿
爱范儿
小众软件
小众软件
K
Kaspersky official blog
P
Proofpoint News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
V
Vulnerabilities – Threatpost
博客园_首页
Microsoft Security Blog
Microsoft Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
V2EX
C
Check Point Blog
S
Schneier on Security
P
Palo Alto Networks Blog
IT之家
IT之家
GbyAI
GbyAI
T
Threat Research - Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
Project Zero
Project Zero
Y
Y Combinator Blog
V
Visual Studio Blog
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
S
Securelist
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理

博客园 - sekihin

【SQLSERVER】备份还原除当前数据库~之外的其他数据库的bak备份 【前端】常用VsCode插件 React席哪个能优化 20 GitHub 仓库帮助你成为 React专家 Export a named export for each HTTP method instead.(Next.js 15) Error occurred prerendering page "/_not-found".(Next.js 15) Error: Attempted to call generateViewport() from the server (Next.js 15) [cause]: TypeError: e_.createContext is not a function (Next.js 15) Cursor - AI代码编辑器的使用指南 Next.js项目中.prettierrc.json的配置 nvm: Node Version Manager PHP slim 部署Apache NestJS 部署Apache NestJS导出API文档 ChatGPT plugins Obisidian plugins Build nest.js by tsconfig.json Data Transfer Objects (DTOs) in NestJS TypeError: stringWidth is not a function
Next.js项目中.eslintrc.js的配置
sekihin · 2024-12-22 · via 博客园 - sekihin
print 'hello world!'module.exports = {
  // 扩展配置,包含Next.js的核心Web Vitals插件和TypeScript支持插件等
  extends: ['next/core-web-vitals', 'plugin:@typescript-eslint/recommended', 'plugin:import/recommended', 'prettier'],
  rules: {
    // 关闭jsx-a11y插件的alt-text规则,通常用于图像的alt属性检查
    'jsx-a11y/alt-text': 'off',
    // 关闭React插件的display-name规则,检查组件是否有displayName
    'react/display-name': 'off',
    // 关闭React插件的no-children-prop规则,防止使用children属性
    'react/no-children-prop': 'off',
    // 关闭Next.js插件的no-img-element规则,不允许使用img元素
    '@next/next/no-img-element': 'off',
    // 关闭Next.js插件的no-page-custom-font规则,不允许使用自定义字体
    '@next/next/no-page-custom-font': 'off',
    // 强制使用一致的类型导入形式
    '@typescript-eslint/consistent-type-imports': 'error',
    // 关闭TypeScript插件的ban-ts-comment规则,不允许使用ts注释
    '@typescript-eslint/ban-ts-comment': 'off',
    // 关闭TypeScript插件的no-explicit-any规则,不允许使用any类型
    '@typescript-eslint/no-explicit-any': 'off',
    // 强制禁止未使用的变量
    '@typescript-eslint/no-unused-vars': 'error',
    // 关闭TypeScript插件的no-non-null-assertion规则,不允许使用非空断言
    '@typescript-eslint/no-non-null-assertion': 'off',
    // 在注释前后强制使用空行
    'lines-around-comment': [
      'error',
      {
        beforeBlockComment: true, // 在块注释前使用空行
        beforeLineComment: true, // 在行注释前使用空行
        allowBlockStart: true, // 允许在块开始时使用空行
        allowObjectStart: true, // 允许在对象开始时使用空行
        allowArrayStart: true // 允许在数组开始时使用空行
      }
    ],
    // 在特定的语句之间强制使用空行
    'padding-line-between-statements': [
      'error',
      {
        blankLine: 'any', // 在任意export语句之间可以有或没有空行
        prev: 'export',
        next: 'export'
      },
      {
        blankLine: 'always', // 在变量声明和任意语句之间强制使用空行
        prev: ['const', 'let', 'var'],
        next: '*'
      },
      {
        blankLine: 'any', // 在连续的变量声明之间可以有或没有空行
        prev: ['const', 'let', 'var'],
        next: ['const', 'let', 'var']
      },
      {
        blankLine: 'always', // 在任意语句和函数或多行const、多行块之间强制使用空行
        prev: '*',
        next: ['function', 'multiline-const', 'multiline-block-like']
      },
      {
        blankLine: 'always', // 在函数或多行const、多行块和任意语句之间强制使用空行
        prev: ['function', 'multiline-const', 'multiline-block-like'],
        next: '*'
      }
    ],
    // return语句之前强制使用空行
    'newline-before-return': 'error',
    // 在导入语句之后强制使用空行
    'import/newline-after-import': [
      'error',
      {
        count: 1
      }
    ],
    // 强制导入的顺序
    'import/order': [
      'error',
      {
        groups: ['builtin', 'external', ['internal', 'parent', 'sibling', 'index'], ['object', 'unknown']],
        pathGroups: [
          {
            pattern: 'react', // react导入之前使用空行
            group: 'external',
            position: 'before'
          },
          {
            pattern: 'next/**', // next导入之前使用空行
            group: 'external',
            position: 'before'
          },
          {
            pattern: '~/**', // 在自定义路径导入之前使用空行
            group: 'external',
            position: 'before'
          },
          {
            pattern: '@/**', // 在内部导入之前使用空行
            group: 'internal'
          }
        ],
        pathGroupsExcludedImportTypes: ['react', 'type'],
        'newlines-between': 'always-and-inside-groups' // 在分组内和分组之间强制使用空行
      }
    ],
    // 禁用不推荐的类型,并推荐使用更具体的类型
    '@typescript-eslint/ban-types': [
      'error',
      {
        extendDefaults: true,
        types: {
          Function: 'Use a specific function type instead', // 使用具体的函数类型替代
          Object: 'Use object instead', // 使用object代替
          Boolean: 'Use boolean instead', // 使用boolean代替
          Number: 'Use number instead', // 使用number代替
          String: 'Use string instead', // 使用string代替
          Symbol: 'Use symbol instead', // 使用symbol代替
          any: false, // 禁用any类型
          '{}': false // 禁用空对象类型
        }
      }
    ]
  },
  settings: {
    react: {
      version: 'detect' // 自动检测React的版本
    },
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx'] // 使用TypeScript解析器解析.ts.tsx文件
    },
    'import/resolver': {
      node: {},
      typescript: {
        project: './tsconfig.json' // 使用项目中的tsconfig.json文件进行解析
      }
    }
  },
  overrides: [
    {
      files: ['*.ts', '*.tsx', 'src/iconify-bundle/*'], // 指定文件匹配模式
      rules: {
        '@typescript-eslint/explicit-module-boundary-types': 'off', // 关闭显式模块边界类型检查
        '@typescript-eslint/no-var-requires': 'off' // 关闭不允许使用require语句的规则
      }
    }
  ]
};