Skip to content

Commit

Permalink
update config, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joephela committed Jul 10, 2024
1 parent dbd3d29 commit 241aa91
Show file tree
Hide file tree
Showing 18 changed files with 1,674 additions and 270 deletions.
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"eslint": "^9.6.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-playwright": "^1.6.2",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-sort": "^3.0.2",
"globals": "^15.8.0",
"jest": "^29.7.0",
"prettier": "^3.3.2",
"typescript": "^5.5.3"
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.0"
}
}
12 changes: 6 additions & 6 deletions packages/eslint-config-widen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
},
"description": "Widen's shared ESLint config.",
"exports": {
".": "./lib/index.js",
"./jest": "./lib/jest.js",
"./playwright": "./lib/playwright.js",
"./react": "./lib/react.js",
"./typescript": "./lib/typescript.js"
".": "./src/index.js",
"./jest": "./src/jest.js",
"./playwright": "./src/playwright.js",
"./react": "./src/react.js",
"./typescript": "./src/typescript.js"
},
"files": [
"lib"
"src"
],
"homepage": "https://github.com/Widen/eslint-config/tree/master/packages/eslint-config-widen#readme",
"license": "ISC",
Expand Down
97 changes: 97 additions & 0 deletions packages/eslint-config-widen/src/index.js
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 babelParser from '@babel/eslint-parser'

Check warning on line 3 in packages/eslint-config-widen/src/index.js

View workflow job for this annotation

GitHub Actions / lint

Imports should be sorted
import globals from 'globals'
import widen from 'eslint-plugin-widen'

export default [
{
languageOptions: {
parser: babelParser,

Check warning on line 10 in packages/eslint-config-widen/src/index.js

View workflow job for this annotation

GitHub Actions / lint

Object properties should be sorted alphabetically
parserOptions: {
requireConfigFile: false,
},
globals: {
...globals.browser,
...globals.es6,
...globals.jest,
...globals.node,
},
},
plugins: {
widen,

Check warning on line 22 in packages/eslint-config-widen/src/index.js

View workflow job for this annotation

GitHub Actions / lint

Object properties should be sorted alphabetically
sort,
},
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
},
},
]
78 changes: 0 additions & 78 deletions packages/eslint-config-widen/src/index.ts

This file was deleted.

22 changes: 22 additions & 0 deletions packages/eslint-config-widen/src/jest.js
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,
},
},
]
18 changes: 0 additions & 18 deletions packages/eslint-config-widen/src/jest.ts

This file was deleted.

36 changes: 36 additions & 0 deletions packages/eslint-config-widen/src/playwright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import playwright from 'eslint-plugin-playwright'

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'],
]
30 changes: 0 additions & 30 deletions packages/eslint-config-widen/src/playwright.ts

This file was deleted.

71 changes: 71 additions & 0 deletions packages/eslint-config-widen/src/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import eslintReact from 'eslint-plugin-react'

Check warning on line 1 in packages/eslint-config-widen/src/react.js

View workflow job for this annotation

GitHub Actions / lint

Imports should be sorted
import eslintReactHooks from 'eslint-plugin-react-hooks'
import eslintJsxA11y from 'eslint-plugin-jsx-a11y'

export default [
eslintReact.configs.recommended,
eslintReactHooks.configs.recommended,
eslintJsxA11y.configs.recommended,
{
files: ['*.tsx', '*.{spec,test}.{js,jsx}'],
rules: {
'react/prop-types': 'off',
},
},
{
files: ['*.{spec,test}.{tsx,js,jsx}'],
rules: {
'react/button-has-type': 'off',
'react/display-name': 'off',
},
},
{
files: ['*.tsx', '*.{spec,test}.{js,jsx}'],
rules: {
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/label-has-associated-control': [
'error',
{
controlComponents: ['TextInput'],
},
],
'jsx-a11y/no-autofocus': [
'warn',
{
ignoreNonDOM: true,
},
],
'react/button-has-type': 'warn',
// https://reactjs.org/docs/jsx-in-depth.html#props-default-to-true
'react/jsx-boolean-value': ['warn', 'always'],
'react/jsx-curly-brace-presence': ['warn', 'never'],
'react/jsx-first-prop-new-line': ['error', 'multiline'],
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-useless-fragment': 'error',
'react/jsx-sort-props': [
'error',
{
ignoreCase: true,
reservedFirst: true,
},
],
'react/no-find-dom-node': 'warn',
'react/no-unescaped-entities': 'off',
'react/no-unknown-property': ['error', { ignore: ['css'] }],
'react/self-closing-comp': 'warn',
'react/sort-prop-types': [
'error',
{
ignoreCase: true,
},
],
'widen/jsx-fragments': 'error',
'widen/jsx-import': 'error',
},
settings: {
react: {
version: 'detect',
},
},
},
]
Loading

0 comments on commit 241aa91

Please sign in to comment.