Skip to content

Commit

Permalink
remove eslint-plugin-import; install import-x and update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamlangford committed Oct 31, 2024
1 parent 46ce3a3 commit 43d3844
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 43 deletions.
2 changes: 1 addition & 1 deletion development.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ module.exports.rules = {
"security/detect-unsafe-regex": "off",

// It's a Webpack optimization, not necessary here
"import/dynamic-import-chunkname": "off",
"import-x/dynamic-import-chunkname": "off",
};
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const config = {
// Once some plugin configuration becomes "too large" it's extracted to its own file
"./plugins/jsdoc.js",
"./plugins/react.js",
"./plugins/import.js",
"./plugins/import-x.js",
"./plugins/typescript.js",
"./plugins/unicorn.js",

Expand Down Expand Up @@ -81,7 +81,7 @@ const config = {
rules: {
"unicorn/filename-case": "off",
"unicorn/no-useless-spread": "off", // Clashes with getDefaultMiddleware().concat
"import/no-anonymous-default-export": "off",
"import-x/no-anonymous-default-export": "off",
},
},
/**************************************************************
Expand Down
2 changes: 1 addition & 1 deletion no-restricted-syntax.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file File that verifies rules in `no-restricted-syntax`. Each line MUST be preceded by `eslint-disable-next-line`, which acts as an "expect" assertion */

/* Unrelated issues */
/* eslint-disable import/no-duplicates */
/* eslint-disable import-x/no-duplicates */
/* eslint-disable unicorn/no-useless-undefined */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
Expand Down
127 changes: 126 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"eslint-config-xo-typescript": "^5.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import-x": "^4.4.0",
"eslint-plugin-jest": "^28.2.0",
"eslint-plugin-jsdoc": "^50.2.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
Expand Down
26 changes: 13 additions & 13 deletions plugins/import.js → plugins/import-x.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
rules: {
// It helps us identify the chunks generated/loaded in the browser
"import/dynamic-import-chunkname": [
"import-x/dynamic-import-chunkname": [
"error",
{
webpackChunknameFormat: "[a-zA-Z0-57-9-/_\\[\\].]+",
webpackChunknameFormat: String.raw`[a-zA-Z0-57-9-/_\[\].]+`,
},
],

// Avoid imports with side effects
"import/no-unassigned-import": [
"import-x/no-unassigned-import": [
"error",
{
allow: [
Expand All @@ -21,27 +21,27 @@ module.exports = {
},
],

"import/no-extraneous-dependencies": "off", // Not worth it
"import-x/no-extraneous-dependencies": "off", // Not worth it

// Rules that duplicate TypeScript features
"import/default": "off",
"import/named": "off",
"import/no-named-as-default": "off", // Too slow
"import/no-named-as-default-member": "off", // It's common to use `React.memo` instead of just `memo`
"import-x/default": "off",
"import-x/named": "off",
"import-x/no-named-as-default": "off", // Too slow
"import-x/no-named-as-default-member": "off", // It's common to use `React.memo` instead of just `memo`

// Maybe later, opinionated
"import/order": "off",
"import/extensions": "off",
"import/no-mutable-exports": "off",
"import-x/order": "off",
"import-x/extensions": "off",
"import-x/no-mutable-exports": "off",
},
overrides: [
{
files: ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
settings: {
"import/resolver": {
"import-x/resolver": {
typescript: {},
},
"import/ignore": [
"import-x/ignore": [
"react-select", // For some reason it points to a flow JS file
],
},
Expand Down
48 changes: 24 additions & 24 deletions vendors/xo-plugins-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
"no-use-extend-native",
"unicorn",
"promise",
"import",
"import-x",
"n",
"@eslint-community/eslint-comments",
],
Expand All @@ -32,49 +32,49 @@ module.exports = {
"promise/valid-params": "error",
"promise/prefer-await-to-then": "error",

"import/default": "error",
"import/export": "error",
"import/extensions": [
"import-x/default": "error",
"import-x/export": "error",
"import-x/extensions": [
"error",
"always",
{
ignorePackages: true,
},
],
"import/first": "error",
"import-x/first": "error",

// Enabled, but disabled on TypeScript (https://github.com/xojs/xo/issues/576)
"import/named": "error",
"import-x/named": "error",

"import/namespace": [
"import-x/namespace": [
"error",
{
allowComputed: true,
},
],
"import/no-absolute-path": "error",
"import/no-anonymous-default-export": "error",
"import/no-named-default": "error",
"import/no-webpack-loader-syntax": "error",
"import/no-self-import": "error",
"import/no-cycle": [
"import-x/no-absolute-path": "error",
"import-x/no-anonymous-default-export": "error",
"import-x/no-named-default": "error",
"import-x/no-webpack-loader-syntax": "error",
"import-x/no-self-import": "error",
"import-x/no-cycle": [
"error",
{
ignoreExternal: true,
},
],
"import/no-useless-path-segments": "error",
"import/newline-after-import": "error",
"import/no-amd": "error",
"import/no-duplicates": "error",
"import-x/no-useless-path-segments": "error",
"import-x/newline-after-import": "error",
"import-x/no-amd": "error",
"import-x/no-duplicates": "error",

"import/no-extraneous-dependencies": "error",
"import/no-mutable-exports": "error",
"import/no-named-as-default-member": "error",
"import/no-named-as-default": "error",
"import-x/no-extraneous-dependencies": "error",
"import-x/no-mutable-exports": "error",
"import-x/no-named-as-default-member": "error",
"import-x/no-named-as-default": "error",

"import/order": "error",
"import/no-unassigned-import": [
"import-x/order": "error",
"import-x/no-unassigned-import": [
"error",
{
allow: [
Expand All @@ -93,7 +93,7 @@ module.exports = {

"n/no-unpublished-bin": "error",

// We have this enabled in addition to `import/extensions` as this one has an auto-fix.
// We have this enabled in addition to `import-x/extensions` as this one has an auto-fix.
"n/file-extension-in-import": [
"error",
"always",
Expand Down

0 comments on commit 43d3844

Please sign in to comment.