Skip to content

Commit

Permalink
build: eslint configuration
Browse files Browse the repository at this point in the history
- Add eslint-plugin-react and eslint-plugin-jsx-a11y and use the
  recommended and jsx-runtime configurations and strict configuration on
  .tsx files only
- Add @eslint/json and use the recommended configuration on .json files,
  treat tsconfig files as jsonc
  • Loading branch information
matijs committed Oct 17, 2024
1 parent 8fc85ac commit a7076ad
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 56 deletions.
35 changes: 29 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,46 @@
import globals from 'globals';
import json from '@eslint/json';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
import eslintPluginReact from 'eslint-plugin-react';

export default tseslint.config(
{
name: 'global-ignores',
ignores: ['**/dist/'],
ignores: ['**/dist/', '**/node_modules/'],
},
{
languageOptions: {
globals: { ...globals.node },
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false,
},
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
languageOptions: {
globals: { ...globals.node },
},
...js.configs.recommended,
},
{
files: ['**/*.json'],
language: 'json/json',
...json.configs.recommended,
},
{
files: ['**/tsconfig.json', '**/tsconfig.*.json'],
language: 'json/jsonc',
...json.configs.recommended,
},
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.tsx'],
...eslintPluginReact.configs.flat.recommended,
...eslintPluginReact.configs.flat['jsx-runtime'],
...eslintPluginJsxA11y.flatConfigs.strict,
},
{
files: ['**/*.cjs'],
rules: {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@babel/preset-typescript": "7.25.7",
"@changesets/cli": "2.27.9",
"@eslint/js": "9.12.0",
"@eslint/json": "0.5.0",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-node-resolve": "15.3.0",
"@rollup/plugin-typescript": "12.1.1",
Expand All @@ -34,6 +35,7 @@
"@types/node": "22.7.5",
"eslint": "9.12.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jsx-a11y": "6.10.0",
"eslint-plugin-react": "7.37.1",
"globals": "15.11.0",
"husky": "9.1.6",
Expand Down
Loading

0 comments on commit a7076ad

Please sign in to comment.