Skip to content

Commit

Permalink
chore: create base eslint config (nodejs#7057)
Browse files Browse the repository at this point in the history
* chore: create base eslint config

* chore(eslint): remove typescript from base config

* fix: ts parser

* chore: remove typescript-eslint from root

* chore: update package-lock.json
  • Loading branch information
araujogui authored Oct 21, 2024
1 parent 64db5a2 commit d6d445d
Show file tree
Hide file tree
Showing 7 changed files with 3,363 additions and 3,735 deletions.
53 changes: 6 additions & 47 deletions apps/site/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import importX from 'eslint-plugin-import-x';
import * as mdx from 'eslint-plugin-mdx';
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
import react from 'eslint-plugin-react';
import storybook from 'eslint-plugin-storybook';
import tseslint from 'typescript-eslint';

// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
import baseConfig from '../../eslint.config.js';

const compat = new FlatCompat();

const compatConfig = compat.config({
Expand All @@ -20,62 +21,20 @@ const compatConfig = compat.config({
});

export default tseslint.config(
{
ignores: [
'node_modules',
'.next',
'.swc',
'.turbo',
'build',
'coverage',
'global.d.ts',
'junit.xml',
'storybook-static/**',
],
},
...baseConfig,
{
extends: [
js.configs.recommended,
importX.flatConfigs.recommended,
importX.flatConfigs.typescript,
react.configs.flat['jsx-runtime'],
...tseslint.configs.recommended,
importX.flatConfigs.typescript,
...compatConfig,
],
files: ['**/*.{js,md,mdx,mjs,ts,tsx}'],
plugins: {
'no-relative-import-paths': noRelativeImportPaths,
},
rules: {
'@next/next/no-duplicate-head': 'off',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-require-imports': 'off',
'import-x/namespace': 'off',
'import-x/no-named-as-default-member': 'off',
'import-x/no-unresolved': 'off',
'import-x/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['sibling', 'parent'],
'index',
'unknown',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'no-relative-import-paths/no-relative-import-paths': [
'warn',
{ allowSameFolder: true, prefix: '@' },
],
'@next/next/no-duplicate-head': 'off',
},
settings: {
react: {
Expand Down
3 changes: 0 additions & 3 deletions apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,9 @@
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/semver": "~7.5.8",
"eslint": "~9.10.0",
"eslint-config-next": "15.0.0-rc.1",
"eslint-import-resolver-typescript": "~3.6.3",
"eslint-plugin-import-x": "~4.3.1",
"eslint-plugin-mdx": "~3.1.5",
"eslint-plugin-no-relative-import-paths": "~1.5.5",
"eslint-plugin-react": "~7.37.1",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-storybook": "0.10.0--canary.156.ce8985b.0",
Expand Down
53 changes: 53 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import js from '@eslint/js';
import importX from 'eslint-plugin-import-x';
import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';

export default [
js.configs.recommended,
importX.flatConfigs.recommended,
{
ignores: [
'node_modules',
'.turbo',
'.next',
'build',
'coverage',
'global.d.ts',
'junit.xml',
'storybook-static/**',
],
},
{
files: ['**/*.{js,mjs,ts,tsx}'],
plugins: {
'no-relative-import-paths': noRelativeImportPaths,
},
rules: {
'import-x/namespace': 'off',
'import-x/no-named-as-default-member': 'off',
'import-x/no-unresolved': 'off',
'import-x/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['sibling', 'parent'],
'index',
'unknown',
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
'no-relative-import-paths/no-relative-import-paths': [
'warn',
{ allowSameFolder: true, prefix: '@' },
],
},
},
];
Loading

0 comments on commit d6d445d

Please sign in to comment.