-
Notifications
You must be signed in to change notification settings - Fork 0
Upgrading configuration to support ESLint 9 #27
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e1a6ac0
upgrading configuration to support ESLint 9
alexlanz bd807e6
adjust configuration
alexlanz 50d2b28
add prettier and fix lint issues
lukasvice b68c9fa
add pre-commit hook
lukasvice a4a2901
update tailwind config to new plugin major version
lukasvice 5d5eae4
add rules from old config
lukasvice 7882332
add unused-imports plugin
lukasvice a419846
enable case sensitive import sorting
lukasvice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
| set -o pipefail | ||
|
|
||
| npm run lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import formatjsPlugin from 'eslint-plugin-formatjs' | ||
| import jsonc from 'eslint-plugin-jsonc' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| plugins: { | ||
| formatjs: formatjsPlugin, | ||
| }, | ||
| rules: { | ||
| 'formatjs/enforce-default-message': ['error', 'literal'], | ||
| 'formatjs/enforce-placeholders': 'error', | ||
| 'formatjs/no-multiple-whitespaces': 'error', | ||
| 'formatjs/enforce-id': 'error', | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/translations/*.json'], | ||
| language: 'json/json', | ||
| plugins: { jsonc }, | ||
| rules: { | ||
| 'jsonc/sort-keys': 'error', | ||
| }, | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import jestPlugin from 'eslint-plugin-jest' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| ...jestPlugin.configs['flat/recommended'], | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { dirname } from 'path' | ||
| import { fileURLToPath } from 'url' | ||
| import { FlatCompat } from '@eslint/eslintrc' | ||
| import { defineConfig } from 'eslint/config' | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url) | ||
| const __dirname = dirname(__filename) | ||
|
|
||
| const compat = new FlatCompat({ | ||
| baseDirectory: __dirname, | ||
| }) | ||
|
|
||
| export default defineConfig([ | ||
| // coreWebVitals includes Next recommended rules | ||
| ...compat.extends('plugin:@next/next/core-web-vitals'), | ||
| { | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| rules: { | ||
| '@next/next/no-img-element': 'off', | ||
| }, | ||
| }, | ||
| ]) | ||
|
|
||
| // Alternative/modern approach: | ||
| // Working, but has some issues with the Next lint command (running with `next build`). | ||
| // This approach can probably be used with Next 16, as they removed Next lint completely. | ||
| // | ||
| // import next from '@next/eslint-plugin-next' | ||
| // import { defineConfig } from 'eslint/config' | ||
| // export default defineConfig([ | ||
| // { | ||
| // files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| // // coreWebVitals includes Next recommended rules | ||
| // ...next.flatConfig.coreWebVitals, | ||
| // rules: { | ||
| // '@next/next/no-img-element': 'off', | ||
| // }, | ||
| // }, | ||
| // ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import jsxA11y from 'eslint-plugin-jsx-a11y' | ||
| import reactPlugin from 'eslint-plugin-react' | ||
| import reactHooks from 'eslint-plugin-react-hooks' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| languageOptions: { | ||
| parserOptions: { | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| }, | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| extends: [ | ||
| reactPlugin.configs.flat.recommended, | ||
| reactPlugin.configs.flat['jsx-runtime'], | ||
| reactHooks.configs['recommended-latest'], | ||
| jsxA11y.flatConfigs.strict, | ||
| ], | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| }, | ||
| rules: { | ||
| 'react/jsx-curly-brace-presence': [ | ||
| 'error', | ||
| { props: 'never', children: 'never', propElementValues: 'always' }, | ||
| ], | ||
| 'react/self-closing-comp': [ | ||
| 'error', | ||
| { | ||
| component: true, | ||
| html: true, | ||
| }, | ||
| ], | ||
| 'react-hooks/rules-of-hooks': 'error', | ||
| 'react-hooks/exhaustive-deps': 'error', | ||
| 'jsx-a11y/no-autofocus': 'off', | ||
| }, | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import * as mdx from 'eslint-plugin-mdx' | ||
| import { configs as storybookConfigs } from 'eslint-plugin-storybook' | ||
| import { configs as tseslintConfigs } from 'typescript-eslint' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| extends: [storybookConfigs['flat/recommended']], | ||
| }, | ||
| { | ||
| ignores: ['!.storybook'], | ||
| }, | ||
| { | ||
| ...mdx.flat, | ||
| processor: mdx.createRemarkProcessor({ | ||
| lintCodeBlocks: false, // Disable linting of code blocks as it shows irrelevant errors. | ||
| }), | ||
| }, | ||
| { | ||
| ...mdx.flatCodeBlocks, | ||
| extends: [tseslintConfigs.disableTypeChecked], | ||
| rules: { | ||
| 'import/no-unresolved': 'off', | ||
| }, | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import eslintPluginBetterTailwindcss from 'eslint-plugin-better-tailwindcss' | ||
| import { getDefaultSelectors } from 'eslint-plugin-better-tailwindcss/api/defaults' | ||
| import { SelectorKind } from 'eslint-plugin-better-tailwindcss/types' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ['**/*.{js,cjs,mjs,jsx,ts,tsx}'], | ||
| extends: [eslintPluginBetterTailwindcss.configs['recommended-error']], | ||
| rules: { | ||
| // Configure rules | ||
| 'better-tailwindcss/enforce-consistent-line-wrapping': ['off'], // This rule is not compatible with prettier | ||
|
|
||
| // Additional rules | ||
| 'better-tailwindcss/enforce-consistent-variable-syntax': ['error'], | ||
| 'better-tailwindcss/enforce-consistent-important-position': ['error'], | ||
| 'better-tailwindcss/enforce-shorthand-classes': ['error'], | ||
| }, | ||
| settings: { | ||
| 'better-tailwindcss': { | ||
| selectors: [ | ||
| ...getDefaultSelectors(), | ||
| { | ||
| kind: SelectorKind.Callee, | ||
| match: [ | ||
| { type: 'strings' }, | ||
| { type: 'objectValues', pathPattern: '.*' }, | ||
| { type: 'objectKeys', pathPattern: '.*' }, | ||
| ], | ||
| name: '^classNames$', | ||
| }, | ||
| { | ||
| kind: SelectorKind.Variable, | ||
| match: [ | ||
| { type: 'strings' }, | ||
| { type: 'objectValues', pathPattern: '.*' }, | ||
| { type: 'objectKeys', pathPattern: '.*' }, | ||
| ], | ||
| name: '.*[cC]lassNames?$', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| /* | ||
| settings: { | ||
| 'better-tailwindcss': { | ||
| // Entrypoint for Tailwind CSS 4 | ||
| entryPoint: 'styles/index.css', | ||
| // Entrypoint for Tailwind CSS 3 | ||
| tailwindConfig: 'tailwind.config.js', | ||
| }, | ||
| }, | ||
| */ | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import eslint from '@eslint/js' | ||
| import json from '@eslint/json' | ||
| import { defineConfig } from 'eslint/config' | ||
| import importPlugin from 'eslint-plugin-import' | ||
| import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' | ||
| import unusedImports from 'eslint-plugin-unused-imports' | ||
| import globals from 'globals' | ||
| import { configs as tseslintConfigs } from 'typescript-eslint' | ||
|
|
||
| export default defineConfig([ | ||
| { | ||
| files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'], | ||
| languageOptions: { | ||
| parserOptions: { | ||
| projectService: true, | ||
| tsconfigRootDir: import.meta.dirname, | ||
| }, | ||
| globals: { | ||
| ...globals.browser, | ||
| ...globals.node, | ||
| }, | ||
| }, | ||
| extends: [ | ||
| eslint.configs.recommended, | ||
| tseslintConfigs.strictTypeChecked, | ||
| tseslintConfigs.stylisticTypeChecked, | ||
| importPlugin.flatConfigs.recommended, | ||
| importPlugin.flatConfigs.typescript, | ||
| eslintPluginPrettierRecommended, | ||
| ], | ||
| plugins: { | ||
| 'unused-imports': unusedImports, | ||
| }, | ||
| settings: { | ||
| 'import/resolver': { | ||
| typescript: true, | ||
| node: true, | ||
| }, | ||
| }, | ||
| rules: { | ||
| '@typescript-eslint/consistent-type-definitions': ['error', 'type'], | ||
| '@typescript-eslint/switch-exhaustiveness-check': 'error', | ||
| '@typescript-eslint/restrict-template-expressions': [ | ||
| 'error', | ||
| { | ||
| allowNumber: true, | ||
| allowAny: false, | ||
| allowNullish: false, | ||
| allowBoolean: false, | ||
| allowRegExp: false, | ||
| allowNever: false, | ||
| }, | ||
| ], | ||
| '@typescript-eslint/member-delimiter-style': 'off', | ||
| '@typescript-eslint/explicit-function-return-type': 'off', | ||
| '@typescript-eslint/no-deprecated': 'warn', | ||
| 'import/order': [ | ||
| 'error', | ||
| { | ||
| groups: [ | ||
| 'builtin', | ||
| 'external', | ||
| 'internal', | ||
| 'unknown', | ||
| 'parent', | ||
| 'sibling', | ||
| 'index', | ||
| 'object', | ||
| 'type', | ||
| ], | ||
| alphabetize: { | ||
| order: 'asc', | ||
| orderImportKind: 'asc', | ||
| caseInsensitive: false, | ||
| }, | ||
| 'newlines-between': 'never', | ||
| warnOnUnassignedImports: true, | ||
| named: true, | ||
| }, | ||
| ], | ||
| 'no-console': [ | ||
| 'error', | ||
| { | ||
| allow: ['warn', 'error', 'assert'], | ||
| }, | ||
| ], | ||
| 'no-implicit-coercion': 'error', | ||
| curly: ['error', 'all'], | ||
| 'object-shorthand': ['error'], | ||
| eqeqeq: 'error', | ||
|
|
||
| // Rules for eslint-plugin-unused-imports | ||
| '@typescript-eslint/no-unused-vars': 'off', | ||
| 'unused-imports/no-unused-imports': 'error', | ||
| 'unused-imports/no-unused-vars': [ | ||
| 'error', | ||
| { | ||
| argsIgnorePattern: '^_', | ||
| varsIgnorePattern: '^_', | ||
| caughtErrorsIgnorePattern: '^_', | ||
| destructuredArrayIgnorePattern: '^_', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| files: ['**/*.{js,mjs,cjs,jsx}'], | ||
| extends: [tseslintConfigs.disableTypeChecked], | ||
| }, | ||
| { | ||
| files: ['**/*.json'], | ||
| ignores: ['package-lock.json'], | ||
| plugins: { json }, | ||
| language: 'json/json', | ||
| extends: [eslintPluginPrettierRecommended, json.configs.recommended], | ||
| }, | ||
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { defineConfig } from 'eslint/config' | ||
| import ts from './configs/ts.js' | ||
|
|
||
| export default defineConfig([ | ||
| ts, | ||
| { | ||
| ignores: ['node_modules'], | ||
| }, | ||
| ]) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.