-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate components for base, jest, playwright, react, and typescript…
… into their own packages
- Loading branch information
1 parent
f1cc5f7
commit c2223d6
Showing
29 changed files
with
1,057 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# eslint-config-widen-base | ||
|
||
Widen's shared ESLint config base module | ||
|
||
## Installation | ||
```bash | ||
yarn add -D eslint eslint-plugin-widen eslint-config-widen-base eslint-plugin-sort @babel/{core,eslint-parser} | ||
``` | ||
|
||
## Usage | ||
|
||
In your `eslint.config.mjs` file, add the following entries to your extends | ||
list. | ||
|
||
```js | ||
import base from 'eslint-config-widen-base' | ||
|
||
export default [ | ||
...base, | ||
...[ | ||
// you can specify what to ignore by using the `ignores` key before any other rule | ||
// this will filter out things we dont want this to run on | ||
{ ignores: ['*.test.*'] }, | ||
// you can also override rules by specifying the rule and the new value | ||
{ files: ['*.spec.js'], rules: { 'no-unused-vars': 'off' } }, | ||
], | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"author": "Widen", | ||
"dependencies": { | ||
"eslint-config-prettier": "^9.1.0" | ||
}, | ||
"description": "Widen's shared ESLint base config.", | ||
"exports": { | ||
".": "./lib/base.js" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"type": "module", | ||
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-base#readme", | ||
"license": "ISC", | ||
"name": "eslint-config-widen-base", | ||
"peerDependencies": { | ||
"@babel/eslint-parser": "^7.22.15", | ||
"eslint": ">= 9", | ||
"eslint-plugin-sort": ">= 3", | ||
"eslint-plugin-widen": ">=3.0.0" | ||
}, | ||
"repository": { | ||
"directory": "packages/eslint-config-widen-base", | ||
"type": "git", | ||
"url": "https://github.com/Widen/eslint-config" | ||
}, | ||
"version": "1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import babelParser from '@babel/eslint-parser' | ||
import js from '@eslint/js' | ||
import prettier from 'eslint-plugin-prettier' | ||
import sort from 'eslint-plugin-sort' | ||
import widen from 'eslint-plugin-widen' | ||
import sharedGlobals from './sharedGlobals.js' | ||
|
||
export default [ | ||
{ | ||
languageOptions: { | ||
globals: sharedGlobals, | ||
parser: babelParser, | ||
parserOptions: { | ||
requireConfigFile: false, | ||
}, | ||
}, | ||
plugins: { | ||
prettier, | ||
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, | ||
{ | ||
plugins: { | ||
prettier, | ||
}, | ||
rules: { | ||
...prettier.configs.recommended.rules, | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import globals from 'globals' | ||
|
||
// delete an invalid global that causes error because of the trailing space | ||
const browser = globals.browser | ||
delete browser['AudioWorkletGlobalScope '] | ||
|
||
const sharedGlobals = { | ||
...browser, | ||
...globals.es6, | ||
...globals.node, | ||
...globals.jest, | ||
} | ||
|
||
export default sharedGlobals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module 'globals' | ||
declare module 'eslint-plugin-widen' | ||
declare module 'eslint-plugin-prettier' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src", | ||
"module": "esnext", | ||
"esModuleInterop": true, | ||
"target": "es2016" | ||
}, | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# eslint-config-widen-jest | ||
|
||
Widen's shared ESLint config for Jest. | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add -D eslint eslint-config-widen-jest eslint-plugin-jest | ||
``` | ||
|
||
## Usage | ||
|
||
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 jest from 'eslint-config-widen-jest' | ||
|
||
export default [ | ||
...[ | ||
// you can specify what to ignore by using the `ignores` key before any other rule | ||
// this will filter out things we dont want this to run on | ||
{ ignores: ['*.test.*'] }, | ||
...jest, | ||
// you can also override rules by specifying the rule and the new value | ||
{ files: ['*.spec.js'], rules: { 'jest/expect-expect': 'off' } }, | ||
], | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"author": "Widen", | ||
"dependencies": { | ||
"eslint-config-prettier": "^9.1.0" | ||
}, | ||
"description": "Widen's shared ESLint config for Jest.", | ||
"exports": { | ||
".": "./lib/jest.js" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"type": "module", | ||
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-jest#readme", | ||
"license": "ISC", | ||
"name": "eslint-config-widen-jest", | ||
"peerDependencies": { | ||
"eslint": ">= 9", | ||
"eslint-plugin-jest": ">= 28" | ||
}, | ||
"repository": { | ||
"directory": "packages/eslint-config-widen-jest", | ||
"type": "git", | ||
"url": "https://github.com/Widen/eslint-config" | ||
}, | ||
"version": "1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import jest from 'eslint-plugin-jest' | ||
|
||
export default [ | ||
{ | ||
files: [ | ||
'*.spec.js', | ||
'*.test.js', | ||
'*.spec.jsx', | ||
'*.test.jsx', | ||
'*.spec.ts', | ||
'*.test.ts', | ||
'*.spec.tsx', | ||
'*.test.tsx', | ||
], | ||
plugins: { | ||
jest, | ||
}, | ||
rules: { | ||
...jest.configs.recommended.rules, | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'eslint-plugin-jest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "lib", | ||
"rootDir": "src", | ||
"module": "esnext", | ||
"esModuleInterop": true, | ||
"target": "es2016" | ||
}, | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# eslint-config-widen-playwright | ||
|
||
Widen's shared ESLint config for Playwright. | ||
|
||
## Installation | ||
|
||
```bash | ||
yarn add -D eslint eslint-config-widen-playwright eslint-plugin-playwright | ||
``` | ||
|
||
## Usage | ||
|
||
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 playwright from 'eslint-config-widen-playwright' | ||
|
||
export default [ | ||
...[{ files: ['e2e/**'] }, ...playwright], | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"author": "Widen", | ||
"dependencies": { | ||
"eslint-config-prettier": "^9.1.0" | ||
}, | ||
"description": "Widen's shared ESLint config for Playwright.", | ||
"exports": { | ||
".": "./lib/playwright.js" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"type": "module", | ||
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen-playwright#readme", | ||
"license": "ISC", | ||
"name": "eslint-config-widen-playwright", | ||
"peerDependencies": { | ||
"eslint": ">= 9", | ||
"eslint-plugin-playwright": ">= 1" | ||
}, | ||
"repository": { | ||
"directory": "packages/eslint-config-widen-playwright", | ||
"type": "git", | ||
"url": "https://github.com/Widen/eslint-config" | ||
}, | ||
"version": "1.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import playwright from 'eslint-plugin-playwright' | ||
|
||
delete playwright.configs['playwright-test'].env | ||
|
||
export default [ | ||
{ | ||
plugins: { | ||
playwright, | ||
}, | ||
rules: { | ||
'playwright/missing-playwright-await': [ | ||
'error', | ||
{ customMatchers: ['toBeAccessible', 'toPassAxe'] }, | ||
], | ||
'playwright/no-restricted-matchers': [ | ||
'warn', | ||
{ | ||
toEqualValue: 'Use `toHaveValue` instead.', | ||
toHaveSelector: 'Use `toBeVisible` instead.', | ||
toHaveSelectorCount: 'Use `toHaveCount` instead.', | ||
toMatchAttribute: 'Use `toHaveAttribute` instead.', | ||
toMatchText: 'Use `toHaveText` instead.', | ||
toMatchURL: 'Use `toHaveURL` instead.', | ||
toMatchValue: 'Use `toHaveValue` instead.', | ||
}, | ||
], | ||
'playwright/prefer-lowercase-title': [ | ||
'warn', | ||
{ ignoreTopLevelDescribe: true }, | ||
], | ||
'playwright/prefer-strict-equal': 'warn', | ||
'playwright/prefer-to-be': 'warn', | ||
'playwright/prefer-to-have-length': 'warn', | ||
'playwright/require-top-level-describe': 'warn', | ||
}, | ||
}, | ||
{ | ||
...playwright.configs['playwright-test'], | ||
plugins: { | ||
playwright, | ||
}, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'eslint-plugin-playwright' |
Oops, something went wrong.