Skip to content

Commit bd529a2

Browse files
Separate components into their own packages (#48)
* Separate components for base, jest, playwright, react, and typescript into their own packages * add deprecation note --------- Co-authored-by: jwilliamson-acquia <[email protected]> Co-authored-by: Joseph Phelan <[email protected]>
1 parent f1cc5f7 commit bd529a2

31 files changed

+774
-0
lines changed

.changeset/purple-coins-dream.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'eslint-config-widen-playwright': major
3+
'eslint-config-widen-typescript': major
4+
'eslint-config-widen-react': major
5+
'eslint-config-widen-base': major
6+
'eslint-config-widen-jest': major
7+
---
8+
9+
Create separate packages for each component. Allows users to import only the
10+
dependencies that they need, rather than all of them.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# eslint-config-widen-base
2+
3+
Widen's shared ESLint config base module
4+
5+
## Installation
6+
7+
```bash
8+
yarn add -D eslint eslint-plugin-widen eslint-config-widen-base eslint-plugin-sort @babel/{core,eslint-parser}
9+
```
10+
11+
## Usage
12+
13+
In your `eslint.config.mjs` file, add the following entries to your extends
14+
list.
15+
16+
```js
17+
import base from 'eslint-config-widen-base'
18+
19+
export default [
20+
...base,
21+
...[
22+
// you can specify what to ignore by using the `ignores` key before any other rule
23+
// this will filter out things we dont want this to run on
24+
{ ignores: ['*.test.*'] },
25+
// you can also override rules by specifying the rule and the new value
26+
{ files: ['*.spec.js'], rules: { 'no-unused-vars': 'off' } },
27+
],
28+
]
29+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"author": "Widen",
3+
"dependencies": {
4+
"eslint-config-prettier": "^9.1.0"
5+
},
6+
"description": "Widen's shared ESLint base config.",
7+
"exports": {
8+
".": "./lib/base.js"
9+
},
10+
"files": [
11+
"lib"
12+
],
13+
"type": "module",
14+
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-base#readme",
15+
"license": "ISC",
16+
"name": "eslint-config-widen-base",
17+
"peerDependencies": {
18+
"@babel/eslint-parser": "^7.22.15",
19+
"eslint": ">= 9",
20+
"eslint-plugin-sort": ">= 3",
21+
"eslint-plugin-widen": ">=3.0.0"
22+
},
23+
"repository": {
24+
"directory": "packages/eslint-config-widen-base",
25+
"type": "git",
26+
"url": "https://github.com/Widen/eslint-config"
27+
},
28+
"version": "1.0.0"
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import babelParser from '@babel/eslint-parser'
2+
import js from '@eslint/js'
3+
import prettier from 'eslint-plugin-prettier'
4+
import sort from 'eslint-plugin-sort'
5+
import widen from 'eslint-plugin-widen'
6+
import sharedGlobals from './sharedGlobals.js'
7+
8+
export default [
9+
{
10+
languageOptions: {
11+
globals: sharedGlobals,
12+
parser: babelParser,
13+
parserOptions: {
14+
requireConfigFile: false,
15+
},
16+
},
17+
plugins: {
18+
prettier,
19+
sort,
20+
widen,
21+
},
22+
rules: {
23+
'default-param-last': 'error',
24+
'dot-notation': 'error',
25+
eqeqeq: [
26+
'error',
27+
'always',
28+
{
29+
null: 'ignore',
30+
},
31+
],
32+
'no-console': ['error', { allow: ['error'] }],
33+
'no-dupe-args': 'error',
34+
'no-duplicate-imports': 'error',
35+
'no-else-return': 'error',
36+
'no-empty': ['error', { allowEmptyCatch: true }],
37+
'no-extra-bind': 'error',
38+
'no-param-reassign': 'error',
39+
'no-return-await': 'error',
40+
'no-template-curly-in-string': 'error',
41+
'no-unneeded-ternary': 'error',
42+
'no-unused-expressions': 'off',
43+
'no-unused-vars': [
44+
'error',
45+
{
46+
ignoreRestSiblings: true,
47+
varsIgnorePattern: '^_',
48+
},
49+
],
50+
'no-useless-computed-key': 'error',
51+
'no-var': 'error',
52+
'object-shorthand': 'error',
53+
'prefer-const': [
54+
'error',
55+
{
56+
destructuring: 'all',
57+
},
58+
],
59+
'require-await': 'error',
60+
'sort/exports': [
61+
'warn',
62+
{
63+
groups: [
64+
{ order: 6, type: 'default' },
65+
{ order: 5, type: 'sourceless' },
66+
{ order: 2, regex: '^@widen\\/' },
67+
{ order: 4, regex: '^\\.+' },
68+
{ order: 1, type: 'dependency' },
69+
{ order: 3, type: 'other' },
70+
],
71+
},
72+
],
73+
'sort/imports': [
74+
'warn',
75+
{
76+
groups: [
77+
{ order: 1, type: 'side-effect' },
78+
{ order: 3, regex: '^@widen\\/' },
79+
{ order: 5, regex: '^\\.+' },
80+
{ order: 2, type: 'dependency' },
81+
{ order: 4, type: 'other' },
82+
],
83+
},
84+
],
85+
},
86+
},
87+
js.configs.recommended,
88+
{
89+
plugins: {
90+
prettier,
91+
},
92+
rules: {
93+
...prettier.configs.recommended.rules,
94+
},
95+
},
96+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import globals from 'globals'
2+
3+
// delete an invalid global that causes error because of the trailing space
4+
const browser = globals.browser
5+
delete browser['AudioWorkletGlobalScope ']
6+
7+
const sharedGlobals = {
8+
...browser,
9+
...globals.es6,
10+
...globals.node,
11+
...globals.jest,
12+
}
13+
14+
export default sharedGlobals
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'globals'
2+
declare module 'eslint-plugin-widen'
3+
declare module 'eslint-plugin-prettier'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "lib",
5+
"rootDir": "src",
6+
"module": "esnext",
7+
"esModuleInterop": true,
8+
"target": "es2016"
9+
},
10+
"paths": {
11+
"@/*": ["./src/*"]
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# eslint-config-widen-jest
2+
3+
Widen's shared ESLint config for Jest.
4+
5+
## Installation
6+
7+
```bash
8+
yarn add -D eslint eslint-config-widen-jest eslint-plugin-jest
9+
```
10+
11+
## Usage
12+
13+
In your `eslint.config.mjs` file, add the following four entries to your extends
14+
list. If you don't need a specific configuration, simply remove it from the
15+
list.
16+
17+
```js
18+
import jest from 'eslint-config-widen-jest'
19+
20+
export default [
21+
...[
22+
// you can specify what to ignore by using the `ignores` key before any other rule
23+
// this will filter out things we dont want this to run on
24+
{ ignores: ['*.test.*'] },
25+
...jest,
26+
// you can also override rules by specifying the rule and the new value
27+
{ files: ['*.spec.js'], rules: { 'jest/expect-expect': 'off' } },
28+
],
29+
]
30+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"author": "Widen",
3+
"dependencies": {
4+
"eslint-config-prettier": "^9.1.0"
5+
},
6+
"description": "Widen's shared ESLint config for Jest.",
7+
"exports": {
8+
".": "./lib/jest.js"
9+
},
10+
"files": [
11+
"lib"
12+
],
13+
"type": "module",
14+
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-jest#readme",
15+
"license": "ISC",
16+
"name": "eslint-config-widen-jest",
17+
"peerDependencies": {
18+
"eslint": ">= 9",
19+
"eslint-plugin-jest": ">= 28"
20+
},
21+
"repository": {
22+
"directory": "packages/eslint-config-widen-jest",
23+
"type": "git",
24+
"url": "https://github.com/Widen/eslint-config"
25+
},
26+
"version": "1.0.0"
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import jest from 'eslint-plugin-jest'
2+
3+
export default [
4+
{
5+
files: [
6+
'*.spec.js',
7+
'*.test.js',
8+
'*.spec.jsx',
9+
'*.test.jsx',
10+
'*.spec.ts',
11+
'*.test.ts',
12+
'*.spec.tsx',
13+
'*.test.tsx',
14+
],
15+
plugins: {
16+
jest,
17+
},
18+
rules: {
19+
...jest.configs.recommended.rules,
20+
},
21+
},
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'eslint-plugin-jest'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "lib",
5+
"rootDir": "src",
6+
"module": "esnext",
7+
"esModuleInterop": true,
8+
"target": "es2016"
9+
},
10+
"paths": {
11+
"@/*": ["./src/*"]
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# eslint-config-widen-playwright
2+
3+
Widen's shared ESLint config for Playwright.
4+
5+
## Installation
6+
7+
```bash
8+
yarn add -D eslint eslint-config-widen-playwright eslint-plugin-playwright
9+
```
10+
11+
## Usage
12+
13+
In your `eslint.config.mjs` file, add the following four entries to your extends
14+
list.
15+
16+
```js
17+
import playwright from 'eslint-config-widen-playwright'
18+
19+
export default [...[{ files: ['e2e/**'] }, ...playwright]]
20+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"author": "Widen",
3+
"dependencies": {
4+
"eslint-config-prettier": "^9.1.0"
5+
},
6+
"description": "Widen's shared ESLint config for Playwright.",
7+
"exports": {
8+
".": "./lib/playwright.js"
9+
},
10+
"files": [
11+
"lib"
12+
],
13+
"type": "module",
14+
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-playwright#readme",
15+
"license": "ISC",
16+
"name": "eslint-config-widen-playwright",
17+
"peerDependencies": {
18+
"eslint": ">= 9",
19+
"eslint-plugin-playwright": ">= 1"
20+
},
21+
"repository": {
22+
"directory": "packages/eslint-config-widen-playwright",
23+
"type": "git",
24+
"url": "https://github.com/Widen/eslint-config"
25+
},
26+
"version": "1.0.0"
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import playwright from 'eslint-plugin-playwright'
2+
3+
delete playwright.configs['playwright-test'].env
4+
5+
export default [
6+
{
7+
plugins: {
8+
playwright,
9+
},
10+
rules: {
11+
'playwright/missing-playwright-await': [
12+
'error',
13+
{ customMatchers: ['toBeAccessible', 'toPassAxe'] },
14+
],
15+
'playwright/no-restricted-matchers': [
16+
'warn',
17+
{
18+
toEqualValue: 'Use `toHaveValue` instead.',
19+
toHaveSelector: 'Use `toBeVisible` instead.',
20+
toHaveSelectorCount: 'Use `toHaveCount` instead.',
21+
toMatchAttribute: 'Use `toHaveAttribute` instead.',
22+
toMatchText: 'Use `toHaveText` instead.',
23+
toMatchURL: 'Use `toHaveURL` instead.',
24+
toMatchValue: 'Use `toHaveValue` instead.',
25+
},
26+
],
27+
'playwright/prefer-lowercase-title': [
28+
'warn',
29+
{ ignoreTopLevelDescribe: true },
30+
],
31+
'playwright/prefer-strict-equal': 'warn',
32+
'playwright/prefer-to-be': 'warn',
33+
'playwright/prefer-to-have-length': 'warn',
34+
'playwright/require-top-level-describe': 'warn',
35+
},
36+
},
37+
{
38+
...playwright.configs['playwright-test'],
39+
plugins: {
40+
playwright,
41+
},
42+
},
43+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'eslint-plugin-playwright'

0 commit comments

Comments
 (0)