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

chore: update ESLint configuration and improve code structure #515

Merged
merged 5 commits into from
Jan 30, 2025
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

45 changes: 0 additions & 45 deletions .eslintrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ react-test-bed

# Ignore Gradle build output directory
build

## Panda
styled-system
styled-system-studio
73 changes: 73 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import _import from 'eslint-plugin-import';
import react from 'eslint-plugin-react';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import jsxA11Y from 'eslint-plugin-jsx-a11y';
import typescriptSortKeys from 'eslint-plugin-typescript-sort-keys';
import sortKeysFix from 'eslint-plugin-sort-keys-fix';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
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({
allConfig: js.configs.all,
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

export default [
{
ignores: ['src/demo/*', 'src/assets/*', 'src/examples/*'],
},
...fixupConfigRules(
compat.extends(
'plugin:import/typescript',
'plugin:react/recommended',
'prettier',
'plugin:react/jsx-runtime',
),
),
{
languageOptions: {
ecmaVersion: 12,

globals: {
...globals.browser,
},
parser: tsParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},

sourceType: 'module',
},

plugins: {
'@typescript-eslint': typescriptEslint,
import: fixupPluginRules(_import),
'jsx-a11y': jsxA11Y,
react: fixupPluginRules(react),
'sort-keys-fix': sortKeysFix,
'typescript-sort-keys': typescriptSortKeys,
},

rules: {
'sort-keys-fix/sort-keys-fix': 'error',
'typescript-sort-keys/interface': 'error',
'typescript-sort-keys/string-enum': 'error',
},

settings: {
react: {
version: '18.1.0',
},
},
},
];
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"cypress:runner": "start-server-and-test start http://localhost:4444 cypress:record",
"cypress:test": "start-server-and-test start http://localhost:4444 cypress",
"cypress:quiet": "cypress run --quiet --headless",
"eslint": "eslint src/**/*.{tsx,ts}",
"fix-js": "eslint src/**/*.{tsx,ts} --fix",
"eslint": "eslint src/**/*.{tsx,ts} --no-warn-ignored",
"fix-js": "eslint src/**/*.{tsx,ts} --fix --no-warn-ignored",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx}\"",
"lint:all": "pnpm eslint && pnpm lint:css && pnpm lint",
Expand Down Expand Up @@ -67,6 +67,9 @@
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@emotion/babel-plugin": "^11.13.5",
"@eslint/compat": "^1.2.5",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0",
"@jest/types": "^29.6.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-buble": "^1.0.3",
Expand Down Expand Up @@ -108,6 +111,7 @@
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^3.3.0",
"globals": "^15.14.0",
"husky": "^9.1.7",
"intersection-observer": "^0.12.2",
"jsdom": "^26.0.0",
Expand Down
Loading
Loading