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

feat: fixes eslint config for v9 #7

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions .eslintrc.cjs

This file was deleted.

157 changes: 157 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { fixupPluginRules } from '@eslint/compat'
import stylistic from '@stylistic/eslint-plugin'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
import jsoncPlugin from 'eslint-plugin-jsonc'
import tsParser from '@typescript-eslint/parser'
import jsoncParser from 'jsonc-eslint-parser'
// import stylelint from 'eslint-plugin-stylelint'

const ignores = [
'app/javascript/**/*',
'app/frontend/types/serializers/**/*',
'app/frontend/lib/routes/urlParams.ts',
'app/frontend/lib/routes/routes.js',
'app/frontend/lib/routes/routes.d.ts',
'tmp/**/*',
'public/**/*',
]

export default [
// Typescript/Javascript files
{
...stylistic.configs.customize({
indent: 'tab',
}),

files: ['**/*.{js,jsx,ts,tsx}'],
ignores,
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: tsParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
'react': {
version: 'detect',
},
'import/resolver': {
typescript: {},
},
'jsx-a11y': {
polymorphicPropName: 'component',
},
},
plugins: {
'react-hooks': fixupPluginRules(reactHooksPlugin),
'jsx-a11y': jsxA11yPlugin,
'@stylistic': stylistic,
// stylelint: fixupPluginRules(stylelint),
},
rules: {
'@stylistic/indent': ['error', 'tab', {
SwitchCase: 1,
VariableDeclarator: 'first',
MemberExpression: 1,
ArrayExpression: 1,
ignoredNodes: [
"TSTypeParameterInstantiation",
],
}],
'@stylistic/brace-style': ['error', '1tbs', {
allowSingleLine: true,
}],
'@stylistic/object-curly-spacing': ['error', 'always', {
objectsInObjects: true,
}],
'@stylistic/jsx-curly-spacing': ['error', {
when: 'always',
children: true,
}],
'@stylistic/member-delimiter-style': ['error', {
multiline: {
delimiter: 'none',
},
singleline: {
delimiter: 'comma',
},
multilineDetection: 'brackets',
}],
'@stylistic/jsx-one-expression-per-line': 'off',
'@stylistic/keyword-spacing': ['error', {
after: true,
before: true,
overrides: {
if: { after: false },
for: { after: false },
while: { after: false },
switch: { after: false },
catch: { after: false },
},
}],
'@stylistic/comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'only-multiline',
}],
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
'@stylistic/space-infix-ops': 'error',
'@stylistic/space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {
'!': false,
'!!': false,
'+': true,
'-': true,
},
}],
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false
}],
'no-unused-vars': ['warn', {
vars: 'all',
args: 'none',
}],
'eqeqeq': 'error',
'no-console': 'warn',
'eol-last': ['error', 'always'],
// 'stylelint/no-invalid': 'error',
// ...stylelint.rules,
...reactHooksPlugin.configs.recommended.rules,
},
},
// Typescript declaration files
{
files: ['**/*.d.ts'],
ignores,
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'@stylistic/ts/indent': 'off',
},
},
// Json files
{
files: ['**/*.json', '**/*.jsonc'],
ignores,
plugins: {
jsonc: jsoncPlugin,
},
languageOptions: {
parser: jsoncParser,
},
rules: {
'jsonc/indent': ['error', 2, { ignoredNodes: ['Property'] }],
'@stylistic/no-multi-spaces': 'off',
},
},
]
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
"@babel/preset-typescript": "^7.24.7",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/compat": "^1.1.1",
"@stylistic/eslint-plugin": "^2.8.0",
"@tanstack/eslint-plugin-query": "^5.58.1",
"@tanstack/react-query-devtools": "^5.58.0",
"@testing-library/dom": "^10.4.0",
Expand All @@ -87,7 +89,7 @@
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@typescript-eslint/parser": "^8.8.0",
"@vitejs/plugin-react": "^4.3.1",
"@wyw-in-js/vite": "^0.5.4",
"autoprefixer": "^10.4.20",
Expand All @@ -97,6 +99,7 @@
"eslint": "^9.11.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-react": "^7.37.0",
"eslint-plugin-react-hooks": "^4.6.2",
Expand All @@ -105,6 +108,7 @@
"husky": "^9.1.6",
"jest": "^29.7.0",
"jsdom": "^25.0.1",
"jsonc-eslint-parser": "^2.4.0",
"lint-staged": "^15.2.10",
"postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1",
Expand Down
Loading
Loading