Skip to content

Commit

Permalink
console: Update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ryaplots committed Jan 10, 2025
1 parent 54b2077 commit ad3cdee
Show file tree
Hide file tree
Showing 3 changed files with 2,458 additions and 2,851 deletions.
274 changes: 274 additions & 0 deletions config/eslintrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
import { fileURLToPath } from 'node:url'
import path from 'node:path'

import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
import jsdoc from 'eslint-plugin-jsdoc'
import prettier from 'eslint-plugin-prettier'
import _import from 'eslint-plugin-import'
import cypress from 'eslint-plugin-cypress'
import preferArrow from 'eslint-plugin-prefer-arrow'
import globals from 'globals'
import babelParser from '@babel/eslint-parser'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

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

export default [
...fixupConfigRules(
compat.extends(
'ttn',
'plugin:jest/recommended',
'plugin:jsdoc/recommended',
'plugin:import/recommended',
'plugin:cypress/recommended',
'prettier',
),
),
{
plugins: {
jsdoc: fixupPluginRules(jsdoc),
prettier,
import: fixupPluginRules(_import),
cypress: fixupPluginRules(cypress),
'prefer-arrow': preferArrow,
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
shallow: true,
render: true,
mount: true,
snapshotDiff: true,
},

parser: babelParser,
ecmaVersion: 5,
sourceType: 'commonjs',

parserOptions: {
ecmaFeatures: {
legacyDecorators: true,
},
},
},

settings: {
'import/ignore': ['node_modules', 'sdk'],

'import/resolver': {
webpack: {
config: './config/webpack.config.babel.js',
},
},
},

rules: {
'prettier/prettier': 'error',

'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',

pathGroups: [
{
pattern: '\\@{ttn-lw,console,account}/constants',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/api',
group: 'internal',
position: 'after',
},
{
pattern: '\\@ttn-lw/components/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@ttn-lw/containers/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@ttn-lw/lib/components/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/components/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/containers/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/lib/components/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/views/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@ttn-lw/lib/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/lib/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/store/actions/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/store/reducers/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/store/selectors/**',
group: 'internal',
position: 'after',
},
{
pattern: '\\@{console,account}/store/middleware/**',
group: 'internal',
position: 'after',
},
{
pattern: '(\\@assets/**|\\@ttn-lw/styles/**)',
group: 'sibling',
position: 'after',
},
{
pattern: './*.styl',
group: 'sibling',
position: 'after',
},
],
},
],

'import/no-useless-path-segments': [
'error',
{
noUselessIndex: true,
},
],

'import/newline-after-import': 'warn',
'import/no-named-as-default': 'off',

'jest/no-large-snapshots': [
'warn',
{
maxSize: 400,
},
],

'jest/no-conditional-expect': 'off',
'jest/no-try-expect': 'off',
'jest/no-done-callback': 'off',
'jest/expect-expect': 'off',
'react/default-props-match-prop-types': 'error',
'react/require-default-props': 'error',
'react/no-unused-prop-types': 'error',
'react/prop-types': 'error',
'react/sort-prop-types': 'warn',
'react/forbid-foreign-prop-types': 'off',
'react/jsx-no-undef': 'warn',
'react/jsx-no-bind': 'off',

'react/forbid-prop-types': [
'warn',
{
forbid: ['any', 'array', 'object'],
checkContextTypes: true,
checkChildContextTypes: true,
},
],

'no-console': ['warn'],

'capitalized-comments': [
'warn',
'always',
{
ignoreConsecutiveComments: true,
},
],

'jsdoc/require-jsdoc': 'off',
'jsdoc/require-hyphen-before-param-description': 'warn',
'jsdoc/check-indentation': 'warn',
'jsdoc/require-description-complete-sentence': 'warn',
'jsdoc/multiline-blocks': 'off',
'jsdoc/tag-lines': 'off',

'prefer-arrow/prefer-arrow-functions': [
'warn',
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: false,
allowStandaloneDeclarations: false,
},
],

'arrow-body-style': ['warn', 'as-needed'],

'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
},
],
},
},
{
files: ['**/*.spec.js'],

rules: {
'jest/valid-expect': 'off',
'no-invalid-this': 'off',
'jest/valid-title': 'off',
},
},
{
files: ['cypress/plugins/**/*.js'],

rules: {
'import/no-commonjs': 'off',
},
},
{
files: ['cypress/integration/smoke/**/*.js'],

rules: {
'jest/no-standalone-expect': 'off',
},
},
]
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
"@babel/preset-react": "^7.26.3",
"@babel/register": "^7.25.9",
"@babel/runtime-corejs2": "^7.26.0",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@inquirer/prompts": "^7.2.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@storybook/addon-actions": "8.4.7",
"@storybook/addon-designs": "8.0.4",
"@storybook/addon-essentials": "8.4.7",
"@storybook/addon-mdx-gfm": "8.4.7",
"@storybook/addon-actions": "8.4.7",
"@storybook/cli": "8.4.7",
"@storybook/react": "8.4.7",
"@storybook/react-webpack5": "8.4.7",
Expand Down Expand Up @@ -55,6 +58,7 @@
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "^7.37.3",
"file-loader": "^6.2.0",
"globals": "^15.14.0",
"html-webpack-plugin": "^5.6.3",
"http-proxy-middleware": "^3.0.3",
"jest": "^29.7.0",
Expand All @@ -69,9 +73,9 @@
"pg": "^8.13.1",
"prettier": "3.4.2",
"react-refresh": "^0.16.0",
"storybook": "^8.1.8",
"stylelint": "^16.12.0",
"stylelint-stylus": "^1.0.0",
"storybook": "^8.1.8",
"stylus": "^0.64.0",
"stylus-loader": "^8.1.1",
"wait-on": "^8.0.1",
Expand All @@ -82,7 +86,6 @@
"yargs": "^17.7.2"
},
"dependencies": {
"@tabler/icons-react": "^3.26.0",
"@formatjs/intl-datetimeformat": "^6.17.1",
"@formatjs/intl-displaynames": "^6.8.8",
"@formatjs/intl-listformat": "^7.7.8",
Expand All @@ -93,6 +96,7 @@
"@reduxjs/toolkit": "^2.5.0",
"@sentry/integrations": "^7.114.0",
"@sentry/react": "^8.47.0",
"@tabler/icons-react": "^3.26.0",
"@tippyjs/react": "^4.2.6",
"apexcharts": "^4.3.0",
"autobind-decorator": "^2.4.0",
Expand Down
Loading

0 comments on commit ad3cdee

Please sign in to comment.