Skip to content

Commit

Permalink
migrating to eslint 9.6.0 (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Dec 5, 2024
1 parent 64fecd8 commit 813e375
Show file tree
Hide file tree
Showing 54 changed files with 4,993 additions and 7,552 deletions.
174 changes: 0 additions & 174 deletions .eslintrc.cjs

This file was deleted.

3 changes: 1 addition & 2 deletions e2e/storybook.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {type Page, test, expect} from '@playwright/test'
// eslint-disable-next-line import/extensions, import/no-unresolved
// eslint-disable-next-line importPlugin/no-unresolved
import data from '../docs/storybook/storybook-static/stories.json' assert {type: 'json'}
// eslint-disable-next-line import/extensions, import/no-unresolved
import colorData from '../dist/docs/functional/themes/light.json' assert {type: 'json'}

const extractNameAndValue = Object.entries(colorData)
Expand Down
179 changes: 179 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import tseslint from 'typescript-eslint';
import * as parser from '@typescript-eslint/parser'
import {fixupPluginRules} from '@eslint/compat'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import eslintPluginReact from 'eslint-plugin-react'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
import eslintPluginGithub from 'eslint-plugin-github'
import eslintPluginTypescript from 'typescript-eslint'

export default tseslint.config([
eslintPluginGithub.getFlatConfigs().recommended,
eslintPluginGithub.getFlatConfigs().browser,
eslintPluginGithub.getFlatConfigs().react,
...eslintPluginGithub.getFlatConfigs().typescript,
jsxA11y.flatConfigs.recommended,
tseslint.configs.recommended,
{
plugins: {
react: eslintPluginReact,
'react-hooks': fixupPluginRules(eslintPluginReactHooks),
},
rules: {
...eslintPluginReactHooks.configs.recommended.rules,
...eslintPluginReact.configs['jsx-runtime'].rules,
...eslintPluginGithub.getFlatConfigs().rules,
},
},
eslintPluginPrettierRecommended,
eslintConfigPrettier,
{
ignores: ['node_modules', 'coverage/**', 'docs/**', 'dist/**/*', 'CHANGELOG.md', 'src/@types/', ".prettierrc.js", 'integration/build/'],
},
{
languageOptions: {
parser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
__DEV__: 'readonly',
browser: true,
commonjs: true,
es6: true,
jest: true,
node: true,
},
},
ignores: ['README.md'],
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {}, // this loads <rootdir>/tsconfig.json to eslint
},
},
// rules which apply to JS, TS, etc.
rules: {
'i18n-text/no-en': 0,
'importPlugin/no-nodejs-modules': "off",
"importPlugin/extensions": ['error', "never", {
"js": "ignorePackages",
"json": "always",
}],
'github/filenames-match-regex': ['error', '^([a-z0-9]+)([A-Z][a-z0-9]+)*([.test])?(.[a-z0-9-]+)?$'],
'eslint-comments/no-unused-disable': 0,
'react/prop-types': 0,
'react/display-name': 0,
'react-hooks/exhaustive-deps': 'error',
'jsx-a11y/label-has-for': [
2,
{
components: [],
},
],
camelcase: [
'error',
{
allow: [
'light_high_contrast',
'light_colorblind',
'light_tritanopia',
'dark_dimmed',
'dark_high_contrast',
'dark_colorblind',
'dark_tritanopia',
],
},
],
},
},
// rules which apply only to JS
{
files: ['**/*.{js,jsx}'],
rules: {
'eslint-comments/no-use': 0,
'import/no-namespace': 0,
'no-shadow': 0,
'import/no-commonjs': 0,
'no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
},
],
},
},
{
plugins: {
eslintPluginTypescript: eslintPluginTypescript.configs.recommended,
},
files: ['**/*.{ts,tsx}'],
},
// rules which apply only to TS
{
languageOptions: {
parserOptions: {
project: 'tsconfig.json',
},
},
files: ['**/*.{ts,tsx}'],
rules: {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-explicit-any': 2,
'@typescript-eslint/no-unnecessary-condition': 2,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
// rules which apply only to tests files
{
files: ['**/*.test.{ts,tsx,js,jsx}'],
rules: {
'i18n-text/no-en': 0,
},
},
// rules which apply only to Markdown code blocks
{
files: ['**/*.{md,mdx}/**'],
languageOptions: {
parserOptions: {
project: false,
},
},
rules: {
camelcase: 0,
'import/no-unresolved': 0,
'no-constant-condition': 0,
'no-console': 0,
'no-empty-pattern': 0,
'no-unused-vars': 0,
'no-undef': 0,
'react/no-unescaped-entities': 0,
'react/react-in-jsx-scope': 0,
'react/jsx-no-undef': 0,
'react/jsx-key': 0,
'react/jsx-no-comment-textnodes': 0,
'i18n-text/no-en': 0,
'import/no-anonymous-default-export': 0,
'import/extensions': 0,
'prettier/prettier': 0,
'@typescript-eslint/no-unnecessary-condition': 0,
'@typescript-eslint/no-unused-vars': 0,
'no-redeclare': 0,
},
},
])
2 changes: 1 addition & 1 deletion integration/baseline.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary.js'
import {PrimerStyleDictionary} from '../src/primerStyleDictionary.js'
import fs from 'fs'

describe('PrimerStyleDictionary', async () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PrimerStyleDictionary} from '../src/PrimerStyleDictionary.js'
import {PrimerStyleDictionary} from '../src/primerStyleDictionary.js'
import fs from 'fs'

describe('PrimerStyleDictionary', async () => {
Expand Down
Loading

0 comments on commit 813e375

Please sign in to comment.