Skip to content

Commit

Permalink
chore: use eslint-plugin-i (#15569)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Jan 11, 2024
1 parent 0fb9071 commit a1f8082
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 514 deletions.
11 changes: 5 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { defineConfig } = require('eslint-define-config')
const pkg = require('./package.json')

/// <reference types="@eslint-types/typescript-eslint" />
/// <reference types="@eslint-types/import" />

module.exports = defineConfig({
root: true,
Expand All @@ -16,7 +15,7 @@ module.exports = defineConfig({
'plugin:regexp/recommended',
],
ignorePatterns: ['packages/create-vite/template-**'],
plugins: ['import', 'regexp'],
plugins: ['i', 'regexp'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
Expand Down Expand Up @@ -93,12 +92,12 @@ module.exports = defineConfig({
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/prefer-function-type': 'off',

'import/no-nodejs-modules': [
'i/no-nodejs-modules': [
'error',
{ allow: builtinModules.map((mod) => `node:${mod}`) },
],
'import/no-duplicates': 'error',
'import/order': 'error',
'i/no-duplicates': 'error',
'i/order': 'error',
'sort-imports': [
'error',
{
Expand Down Expand Up @@ -213,7 +212,7 @@ module.exports = defineConfig({
'playground/tailwind/**', // blocked by https://github.com/postcss/postcss-load-config/issues/239
],
rules: {
'import/no-commonjs': 'error',
'i/no-commonjs': 'error',
},
},
{
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
},
"devDependencies": {
"@babel/types": "^7.23.6",
"@eslint-types/import": "^2.29.0-1",
"@eslint-types/typescript-eslint": "^6.12.0",
"@rollup/plugin-typescript": "^11.1.5",
"@types/babel__core": "^7.20.5",
Expand All @@ -68,7 +67,7 @@
"conventional-changelog-cli": "^4.1.0",
"eslint": "^8.55.0",
"eslint-define-config": "^2.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-i": "^2.29.1",
"eslint-plugin-n": "^16.4.0",
"eslint-plugin-regexp": "^2.1.2",
"execa": "^8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion playground/cli-module/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
import { URL } from 'url'
import { defineConfig } from 'vite'

Expand Down
2 changes: 1 addition & 1 deletion playground/css/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import './layered/index.css'
import './dep.css'
import './glob-dep.css'

// eslint-disable-next-line import/order
// eslint-disable-next-line i/order
import { barModuleClasses } from '@vitejs/test-css-js-dep'
document
.querySelector('.css-js-dep-module')
Expand Down
2 changes: 1 addition & 1 deletion playground/js-sourcemap/importee-pkg/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-commonjs
// eslint-disable-next-line i/no-commonjs
exports.foo = 'foo'
2 changes: 1 addition & 1 deletion playground/object-hooks/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-nodejs-modules */
/* eslint-disable i/no-nodejs-modules */
import assert from 'assert'
import { defineConfig } from 'vite'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
const events = require('events')

module.exports = 'foo' in events ? 'pong' : ''
4 changes: 2 additions & 2 deletions playground/optimize-deps/dep-with-builtin-module-cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// no node: protocol intentionally
// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
const fs = require('fs')
// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
const path = require('path')

// NOTE: require destructure would error immediately because of how esbuild
Expand Down
4 changes: 2 additions & 2 deletions playground/optimize-deps/dep-with-builtin-module-esm/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// no node: protocol intentionally
// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
import { readFileSync } from 'fs'
// eslint-disable-next-line import/no-nodejs-modules
// eslint-disable-next-line i/no-nodejs-modules
import path from 'path'

// access from named import
Expand Down
2 changes: 1 addition & 1 deletion playground/resolve/browser-field/relative.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-duplicates */
/* eslint-disable i/no-duplicates */
import ra from './no-ext'
import rb from './no-ext.js' // no substitution
import rc from './ext'
Expand Down
2 changes: 1 addition & 1 deletion playground/resolve/exports-with-module-condition/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable i/no-commonjs */
module.exports.msg = '[fail] exports with module condition (index.js)'
Loading

0 comments on commit a1f8082

Please sign in to comment.