generated from morewings/react-library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
126 additions
and
141 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,146 +1,131 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
project: './tsconfig.linter.json', | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect' | ||
root: true, | ||
env: {browser: true, es2020: true}, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
// eslint-disable-next-line no-undef | ||
tsconfigRootDir: __dirname, | ||
sourceType: 'module', | ||
project: './tsconfig.linter.json', | ||
}, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
'plugin:ssr-friendly/recommended', | ||
'plugin:storybook/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['import', 'prettier', '@typescript-eslint', 'ssr-friendly', 'react-refresh'], | ||
rules: { | ||
/** | ||
* Allow empty arrow functions `() => {}`, while keeping other empty functions restricted | ||
* @see https://eslint.org/docs/latest/rules/no-empty-function#allow-arrowfunctions | ||
*/ | ||
'@typescript-eslint/no-empty-function': [ | ||
'error', | ||
{allow: ['arrowFunctions']}, | ||
], | ||
'@typescript-eslint/ban-ts-comment': 1, | ||
'no-const-assign': 'error', | ||
/** Restrict imports from devDependencies since they are not included in library build. peerDependencies are ok */ | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: false, | ||
peerDependencies: true, | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/stylistic-type-checked', | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
'plugin:ssr-friendly/recommended', | ||
'plugin:storybook/recommended', | ||
'plugin:prettier/recommended', | ||
], | ||
/** | ||
* Enforce import order with empty lines between import group | ||
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md | ||
*/ | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [ | ||
'builtin', | ||
'external', | ||
'internal', | ||
['parent', 'sibling', 'index'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['import', 'prettier', '@typescript-eslint', 'ssr-friendly', 'react-refresh'], | ||
rules: { | ||
/** | ||
* Allow empty arrow functions `() => {}`, while keeping other empty functions restricted | ||
* @see https://eslint.org/docs/latest/rules/no-empty-function#allow-arrowfunctions | ||
*/ | ||
'@typescript-eslint/no-empty-function': ['error', {allow: ['arrowFunctions']}], | ||
'@typescript-eslint/ban-ts-comment': 1, | ||
'no-const-assign': 'error', | ||
/** Restrict imports from devDependencies since they are not included in library build. peerDependencies are ok */ | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: false, | ||
peerDependencies: true, | ||
}, | ||
], | ||
pathGroups: [ | ||
{ | ||
pattern: '@/**', | ||
group: 'internal', | ||
}, | ||
/** | ||
* Enforce import order with empty lines between import group | ||
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md | ||
*/ | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']], | ||
pathGroups: [ | ||
{ | ||
pattern: '@/**', | ||
group: 'internal', | ||
}, | ||
], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
/** | ||
* Disallow combined module and type imports like this `import React, {FC} from 'react'`. | ||
* Eslint will try to split into type and module imports instead | ||
* @see https://typescript-eslint.io/rules/consistent-type-imports/ | ||
*/ | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
'import/no-cycle': 'error', | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
semi: true, | ||
singleQuote: true, | ||
jsxSingleQuote: false, | ||
trailingComma: 'es5', | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
arrowParens: 'avoid', | ||
}, | ||
], | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
'@typescript-eslint/consistent-type-definitions': [ | ||
'error', | ||
'type' | ||
] | ||
}, | ||
overrides: [ | ||
/* Allow require imports for internal scripts */ | ||
{ | ||
files: ['*.js', '*.cjs'], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 0, | ||
}, | ||
}, | ||
/* Allow devDependencies imports for tests and config files */ | ||
{ | ||
files: [ | ||
'**/*.spec.*', | ||
'**/testUtils/*.*', | ||
'**/*.js', | ||
'**/*.cjs', | ||
'**/setupTests.ts', | ||
'**/*.stories.*', | ||
'vite.config.ts' | ||
], | ||
rules: { | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: true, | ||
peerDependencies: true, | ||
}, | ||
/** | ||
* Disallow combined module and type imports like this `import React, {FC} from 'react'`. | ||
* Eslint will try to split into type and module imports instead | ||
* @see https://typescript-eslint.io/rules/consistent-type-imports/ | ||
*/ | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
'import/no-cycle': 'error', | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
semi: true, | ||
singleQuote: true, | ||
jsxSingleQuote: false, | ||
trailingComma: 'es5', | ||
bracketSpacing: false, | ||
jsxBracketSameLine: true, | ||
arrowParens: 'avoid', | ||
}, | ||
], | ||
}, | ||
'react-refresh/only-export-components': ['warn', {allowConstantExport: true}], | ||
'@typescript-eslint/consistent-type-definitions': ['error', 'type'], | ||
}, | ||
/* Disable `environment` directory imports for library files */ | ||
{ | ||
files: ['./src/lib/**/*.*'], | ||
rules: { | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: [ | ||
{ | ||
group: ['**/environment/**'], | ||
message: | ||
'Imports from environment directory are forbidden in the library files.', | ||
}, | ||
overrides: [ | ||
/* Allow require imports for internal scripts */ | ||
{ | ||
files: ['*.js', '*.cjs'], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 0, | ||
}, | ||
}, | ||
/* Allow devDependencies imports for tests and config files */ | ||
{ | ||
files: [ | ||
'**/*.spec.*', | ||
'**/testUtils/*.*', | ||
'**/*.js', | ||
'**/*.cjs', | ||
'**/setupTests.ts', | ||
'**/*.stories.*', | ||
'vite.config.ts', | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
rules: { | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: true, | ||
peerDependencies: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
/* Disable `environment` directory imports for library files */ | ||
{ | ||
files: ['./src/lib/**/*.*'], | ||
rules: { | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
patterns: [ | ||
{ | ||
group: ['**/environment/**'], | ||
message: 'Imports from environment directory are forbidden in the library files.', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; | ||
|
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends" : "./tsconfig.json", | ||
"include": ["**/*.stories.tsx", "**/*.stories.ts", "*.config.ts", "src"], | ||
"include": ["**/*.stories.tsx", "**/*.stories.ts", "*.config.ts", "src", ".eslintrc.cjs"], | ||
"exclude": ["./dist/**"] | ||
} |