Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Upgrade to ESLint v9 #65

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.

## [4.0.0-alpha.0](https://github.com/burtek/eslint-config/compare/v3.0.1...v4.0.0-alpha.0) (2024-08-08)


### ⚠ BREAKING CHANGES

* **deps:** update dependency eslint to v9 (#41)
* there might be differences in a way this plugin works and this might require changes to project's own `eslint.config.js` files

* feat!(deps): Replace import with import-x (#64) ([b018dba](https://github.com/burtek/eslint-config/commit/b018dba0056c0a00a2ec11e7e6a7c8682b5c3ce5)), closes [#64](https://github.com/burtek/eslint-config/issues/64)


### Features

* **deps:** update dependency eslint to v9 ([#41](https://github.com/burtek/eslint-config/issues/41)) ([6a23fbe](https://github.com/burtek/eslint-config/commit/6a23fbe1d74125344738b94e0c112b5656a7edd7))


### Documentation changes:

* Update CHANGELOG ([781bca9](https://github.com/burtek/eslint-config/commit/781bca941c2ff24fa6b853d9420498cf5cb3f640))
* Update README.md ([f8a294c](https://github.com/burtek/eslint-config/commit/f8a294cd07d3cb2240baa072882591753ce44552))

## [3.0.1](https://github.com/burtek/eslint-config/compare/v3.0.0...v3.0.1) (2024-08-08)


Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
# @dtrw/eslint-config

<!-- support table - import no support for eslint@9 - https://github.com/import-js/eslint-plugin-import/issues/2948 -->

![npm version](https://img.shields.io/npm/v/@dtrw/eslint-config/latest)
![npm next version](https://img.shields.io/npm/v/@dtrw/eslint-config/next)
![NPM License](https://img.shields.io/npm/l/@dtrw/eslint-config)
![Release](https://img.shields.io/github/actions/workflow/status/burtek/eslint-config/release.yml?label=publish%20release)
![dependencies](https://img.shields.io/librariesio/release/npm/@dtrw/eslint-config)


This is repository with my `eslint` configs for multiple purposes that are used (or will be used) in my other projects.

## Install

```bash
yarn add -D @dtrw/eslint-config eslint@^8.56
yarn add -D @dtrw/eslint-config eslint
```

or

```bash
npm i -D @dtrw/eslint-config eslint@^8.56
npm i -D @dtrw/eslint-config eslint
```

## Usage

This config requires `eslint` `^8.56` (not compatible with `eslint@9` yet - see [#65](https://github.com/burtek/eslint-config/pull/65))


```js
// eslint.config.js

Expand Down
96 changes: 23 additions & 73 deletions configs/base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import js from '@eslint/js';
import stylisticPlugin from '@stylistic/eslint-plugin';
import * as importPlugin from 'eslint-plugin-import';
import * as importPlugin from 'eslint-plugin-import-x';
import promise from 'eslint-plugin-promise';
import tseslint from 'typescript-eslint';

Expand All @@ -23,83 +24,56 @@ export function prepareConfig() {
linterOptions: { reportUnusedDisableDirectives: true },
settings: {
...importPlugin.configs.typescript.settings,
'import/extensions': allImportExtensions,
'import/parsers': { '@typescript-eslint/parser': allImportExtensions },
'import/resolver': {
'import-x/extensions': allImportExtensions,
'import-x/parsers': { '@typescript-eslint/parser': allImportExtensions },
'import-x/resolver': {
node: { extensions: allImportExtensions },
typescript: true
}
},
plugins: {
import: importPlugin,
'import-x': importPlugin,
promise
},
rules: {
...js.configs.recommended.rules,
'accessor-pairs': 'error',
'array-callback-return': 'error',
'arrow-body-style': 'error',
'block-spacing': 'error',
'brace-style': 'error',
'camelcase': 'error',
'consistent-return': 'error',
'constructor-super': 'error',
'curly': 'error',
'default-case': 'error',
'default-case-last': 'error',
'dot-notation': 'error',
'eqeqeq': 'error',
'for-direction': 'error',
'func-names': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'getter-return': 'error',
'grouped-accessor-pairs': 'error',
'guard-for-in': 'error',
'new-cap': 'error',
'no-alert': 'error',
'no-array-constructor': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'always'],
'no-console': 'error',
'no-const-assign': 'error',
'no-constant-binary-expression': 'error',
'no-constant-condition': 'error',
'no-constructor-return': 'error',
'no-continue': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-div-regex': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-else-return': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-empty-character-class': 'error',
'no-empty-function': 'error',
'no-empty-pattern': 'error',
'no-empty-static-block': 'error',
'no-eval': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-fallthrough': ['error', { allowEmptyCase: true }],
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-implicit-coercion': ['error', { allow: ['!!'] }],
'no-implied-eval': 'error',
'no-import-assign': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-invalid-this': 'error',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
Expand All @@ -115,46 +89,28 @@ export function prepareConfig() {
ignoreDefaultValues: true
}
],
'no-misleading-character-class': 'error',
'no-multi-assign': 'error',
'no-multi-str': 'error',
'no-negated-condition': 'error',
'no-nested-ternary': 'warn',
'no-new': 'error',
'no-new-func': 'error',
'no-new-native-nonconstructor': 'error',
'no-new-wrappers': 'error',
'no-nonoctal-decimal-escape': 'error',
'no-obj-calls': 'error',
'no-object-constructor': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'error',
'no-promise-executor-return': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-return-assign': 'error',
'no-script-url': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-setter-return': 'error',
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'warn',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'error',
'no-unreachable': 'error',
'no-unreachable-loop': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unused-expressions': 'error',
'no-unused-labels': 'error',
'no-unused-vars': [
'error',
{
Expand All @@ -165,17 +121,14 @@ export function prepareConfig() {
],
'no-use-before-define': ['error', { classes: true, functions: false, variables: true }],
'no-useless-call': 'error',
'no-useless-catch': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'error',
'no-useless-escape': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-var': 'error',
'no-void': ['error', { allowAsStatement: true }],
'no-warning-comments': 'error',
'no-with': 'error',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'operator-assignment': 'error',
Expand All @@ -193,34 +146,30 @@ export function prepareConfig() {
'radix': 'error',
'require-atomic-updates': 'error',
'require-await': 'error',
'require-yield': 'error',
'symbol-description': 'error',
'use-isnan': 'error',
'valid-typeof': ['error', { requireStringLiterals: true }],
'yoda': ['error', 'never', { exceptRange: true }],

'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import/default': 'error',
'import/export': 'error',
'import/first': 'error',
'import/namespace': 'error',
'import/newline-after-import': [
...importPlugin.configs.recommended.rules,
'import-x/no-unresolved': 'off',
'import-x/named': 'off',
'import-x/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import-x/first': 'error',
'import-x/newline-after-import': [
'error',
{
considerComments: true,
count: 2
}
],
'import/no-anonymous-default-export': 'error',
'import/no-cycle': 'error',
'import/no-deprecated': 'warn',
'import/no-duplicates': 'error',
'import/no-empty-named-blocks': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'warn',
'import/no-named-as-default-member': 'warn',
'import/no-self-import': 'error',
'import/order': [
'import-x/no-anonymous-default-export': 'error',
'import-x/no-cycle': 'error',
'import-x/no-deprecated': 'warn',
'import-x/no-duplicates': 'error',
'import-x/no-empty-named-blocks': 'error',
'import-x/no-mutable-exports': 'error',
'import-x/no-self-import': 'error',
'import-x/order': [
'error',
{
'groups': [
Expand Down Expand Up @@ -355,6 +304,7 @@ export function prepareConfig() {
'no-magic-numbers': 'off',
'no-shadow': 'off',
'no-throw-literal': 'off', // extended by tseslint/only-throw-error
'no-unsafe-optional-chaining': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
Expand Down Expand Up @@ -441,7 +391,7 @@ export function prepareConfig() {
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/consistent-return': 'error',
'@typescript-eslint/no-implied-eval': 'error',
// import/consistent-type-specifier-style makes sure we don't inline `type` modifier
// import-x/consistent-type-specifier-style makes sure we don't inline `type` modifier
'@typescript-eslint/no-import-type-side-effects': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
Expand Down
4 changes: 3 additions & 1 deletion configs/node.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @import { TSESLint } from '@typescript-eslint/utils' */
import nPlugin from 'eslint-plugin-n';
import nodeSecurity from 'eslint-plugin-security-node';
import globals from 'globals';
Expand All @@ -7,7 +8,8 @@ import tseslint from 'typescript-eslint';
export function prepareConfig() {
return tseslint.config(
...nPlugin.configs['flat/mixed-esm-and-cjs'].map(c => ({
...c,
// cast to be removed after https://github.com/typescript-eslint/typescript-eslint/issues/9724
.../** @type {TSESLint.FlatConfig.Config} */(c),
files: /** @type {string[]} */(c.files).flatMap(f => [f, f.replace('.js', '.ts')])
})),
{
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default tseslint.config(
rules: {
'no-extra-parens': 'off',
'no-magic-numbers': 'off',
'import/no-named-as-default-member': 'off',
'import-x/no-named-as-default-member': 'off',
'@stylistic/quote-props': ['error', 'consistent-as-needed']
}
},
Expand Down
10 changes: 0 additions & 10 deletions import-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
declare module 'eslint-plugin-import' {
import type { TSESLint } from '@typescript-eslint/utils';
import type { Rule } from 'eslint';


export const configs: Record<'recommended' | 'error' | 'warnings' | 'react' | 'react-native' | 'electron' | 'typescript',
TSESLint.ClassicConfig.Config>;
export const rules: Record<string, Rule.RuleModule>;
}

declare module 'eslint-plugin-promise' {
import type { TSESLint } from '@typescript-eslint/utils';
import type { Rule } from 'eslint';
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dtrw/eslint-config",
"version": "3.0.1",
"version": "4.0.0-alpha.0",
"author": "Bartosz Dotryw <[email protected]>",
"description": "Custom eslint configs",
"keywords": [
Expand All @@ -16,7 +16,7 @@
"@stylistic/eslint-plugin": "~2.6.0",
"eslint-import-resolver-typescript": "~3.6.1",
"eslint-plugin-cypress": "~3.4.0",
"eslint-plugin-import": "~2.29.1",
"eslint-plugin-import-x": "~0.5.1",
"eslint-plugin-jest": "~28.8.0",
"eslint-plugin-jest-dom": "~5.4.0",
"eslint-plugin-jsonc": "~2.15.1 || ~2.16.0",
Expand All @@ -33,12 +33,12 @@
"typescript-eslint": "~8.0.0"
},
"devDependencies": {
"@types/eslint": "^8.56.8",
"@types/eslint": "^9.6.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.12",
"@types/node": "*",
"@types/node": "^20.14.2",
"commit-and-tag-version": "^12.2.0",
"eslint": "^8.57.0",
"eslint-plugin-mdx": "^3.1.5",
"eslint": "^9.4.0",
"exit-code": "^1.0.2",
"jest": "^29.7.0",
"rimraf": "^6.0.0",
Expand All @@ -47,7 +47,7 @@
"typescript": "~5.5.2"
},
"peerDependencies": {
"eslint": "^8.56",
"eslint": "^^9.4.0",
"typescript": ">=4.7.4"
},
"private": false,
Expand Down
Loading
Loading