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

Fe 1045 eslint v9 upgrade #39

Merged
merged 17 commits into from
Jul 11, 2024
10 changes: 10 additions & 0 deletions .changeset/tidy-steaks-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'eslint-config-widen': major
'eslint-plugin-widen': major
---

Update to eslint 9, Apps will need to be on eslint 9+ alongside this update.
They will also need to convert their .eslintrc and .eslint ignore into the new
format of eslint.config.mjs. Here is a migration guide that goes over the basics
https://eslint.org/docs/latest/use/configure/migration-guide. For general usage
and a sample eslint.config.mjs see the updated readme in this repo.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .eslintrc

This file was deleted.

18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: yarn install --immutable
- run: yarn lint
Expand All @@ -17,11 +17,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
Expand All @@ -32,12 +32,12 @@ jobs:
needs: [lint, test]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
cache: yarn
- run: yarn install --immutable
- name: Create release pull request or publish to npm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
- run: yarn install --immutable
- run: yarn prettier --write .
- name: Commit changes
Expand Down
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,27 @@ yarn add -D eslint-plugin-jest

## Usage

In your `.eslintrc` file, add the following four entries to your extends list.
If you don't need a specific configuration, simply remove it from the list.

```json
{
"extends": ["widen", "widen/typescript", "widen/react"],
"overrides": [
{
"files": ["e2e/**"],
"extends": "widen/playwright"
},
{
"files": ["frontend/**"],
"extends": "widen/jest"
}
]
}
In your `eslint.config.mjs` file, add the following four entries to your extends
list. If you don't need a specific configuration, simply remove it from the
list.

```js
import { base, typescript, react, playwright, jest } from 'eslint-config-widen'

export default [
// Base Widen configurations
...base,
...typescript,
...react,

// Overrides for specific directories
{
files: ['e2e/**'],
...playwright,
},
{
files: ['frontend/**'],
...jest,
},
]
```
44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
allConfig: js.configs.all,
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
})

export default [
{
ignores: ['**/lib/'],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:sort/recommended',
),
{
languageOptions: {
globals: {
...globals.jest,
...globals.node,
},

parser: tsParser,
},

plugins: {
'@typescript-eslint': typescriptEslint,
},

rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
]
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
"ts": "tsc -b"
},
"devDependencies": {
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/preset-typescript": "^7.23.2",
"@changesets/cli": "^2.26.2",
"@types/jest": "^29.5.7",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.52.0",
"eslint-plugin-sort": "^2.11.0",
"@babel/core": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@changesets/cli": "^2.27.7",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.6.0",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"eslint": "^9.6.0",
"eslint-plugin-sort": "^3.0.2",
"globals": "^15.8.0",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"prettier": "^3.3.2",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.0"
}
}
40 changes: 23 additions & 17 deletions packages/eslint-config-widen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ yarn add -D eslint-plugin-jest

## Usage

In your `.eslintrc` file, add the following four entries to your extends list.
If you don't need a specific configuration, simply remove it from the list.

```json
{
"extends": ["widen", "widen/typescript", "widen/react"],
"overrides": [
{
"files": ["e2e/**"],
"extends": "widen/playwright"
},
{
"files": ["frontend/**/*.spec.js"],
"extends": "widen/jest"
}
]
}
In your `eslint.config.mjs` file, add the following four entries to your extends
list. If you don't need a specific configuration, simply remove it from the
list.

```js
import { base, typescript, react, playwright, jest } from 'eslint-config-widen'

export default [
// Base Widen configurations
...base,
...typescript,
...react,

// Overrides for specific directories
{
files: ['e2e/**'],
...playwright,
},
{
files: ['frontend/**'],
...jest,
},
]
```
18 changes: 7 additions & 11 deletions packages/eslint-config-widen/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"author": "Widen",
"dependencies": {
"eslint-config-prettier": "^9.0.0"
"eslint-config-prettier": "^9.1.0"
},
"description": "Widen's shared ESLint config.",
"exports": {
".": "./lib/index.js",
"./jest": "./lib/jest.js",
joephela marked this conversation as resolved.
Show resolved Hide resolved
"./playwright": "./lib/playwright.js",
"./react": "./lib/react.js",
"./typescript": "./lib/typescript.js"
".": "./lib/index.js"
},
"files": [
"lib"
Expand All @@ -21,14 +17,14 @@
"@babel/eslint-parser": "^7.22.15",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": ">= 8",
"eslint-plugin-jest": ">= 27",
"eslint": ">= 9",
"eslint-plugin-jest": ">= 28",
"eslint-plugin-jsx-a11y": ">= 6",
"eslint-plugin-playwright": ">=0.16.0",
"eslint-plugin-playwright": ">=1.0.0",
joephela marked this conversation as resolved.
Show resolved Hide resolved
"eslint-plugin-react": ">= 7",
"eslint-plugin-react-hooks": ">= 4",
"eslint-plugin-sort": ">= 2",
"eslint-plugin-widen": ">=2.0.0"
"eslint-plugin-sort": ">= 3",
"eslint-plugin-widen": ">=3.0.0"
joephela marked this conversation as resolved.
Show resolved Hide resolved
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
Expand Down
97 changes: 97 additions & 0 deletions packages/eslint-config-widen/src/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import js from '@eslint/js'
import sort from 'eslint-plugin-sort'
import widen from 'eslint-plugin-widen'

Check warning on line 3 in packages/eslint-config-widen/src/base.ts

View workflow job for this annotation

GitHub Actions / lint

Imports should be sorted
import globals from 'globals'
import babelParser from '@babel/eslint-parser'

export default [
{
languageOptions: {
globals: {
...globals.browser,
...globals.es6,
...globals.jest,
...globals.node,
},
parser: babelParser,
parserOptions: {
requireConfigFile: false,
},
},
plugins: {
sort,
widen,
},
rules: {
'default-param-last': 'error',
'dot-notation': 'error',
eqeqeq: [
'error',
'always',
{
null: 'ignore',
},
],
'no-console': ['error', { allow: ['error'] }],
'no-dupe-args': 'error',
'no-duplicate-imports': 'error',
'no-else-return': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-extra-bind': 'error',
'no-param-reassign': 'error',
'no-return-await': 'error',
'no-template-curly-in-string': 'error',
'no-unneeded-ternary': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
},
],
'no-useless-computed-key': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
'require-await': 'error',
'sort/exports': [
'warn',
{
groups: [
{ order: 6, type: 'default' },
{ order: 5, type: 'sourceless' },
{ order: 2, regex: '^@widen\\/' },
{ order: 4, regex: '^\\.+' },
{ order: 1, type: 'dependency' },
{ order: 3, type: 'other' },
],
},
],
'sort/imports': [
'warn',
{
groups: [
{ order: 1, type: 'side-effect' },
{ order: 3, regex: '^@widen\\/' },
{ order: 5, regex: '^\\.+' },
{ order: 2, type: 'dependency' },
{ order: 4, type: 'other' },
],
},
],
},
},
js.configs.recommended,
{
files: ['**/*.js', '**/*.mjs'],
rules: {
'prettier/prettier': 'error', // Assuming you have `eslint-plugin-prettier` setup
},
},
]
Loading
Loading