Skip to content

Commit

Permalink
build: update deps and migrate code
Browse files Browse the repository at this point in the history
- eslint watch all projects
- fix linter errors in code
  • Loading branch information
juliencrn committed Sep 19, 2022
1 parent fc9d856 commit f374cba
Show file tree
Hide file tree
Showing 15 changed files with 12,116 additions and 18,173 deletions.
92 changes: 0 additions & 92 deletions .eslintrc

This file was deleted.

116 changes: 116 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
tsconfigRootDir: __dirname,
ecmaFeatures: {
jsx: true,
},
},
extends: [
'plugin:react-hooks/recommended',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
],
plugins: ['react', 'simple-import-sort', 'prettier', 'jsx-a11y'],
env: {
browser: true,
es6: true,
node: true,
},
settings: {
react: {
version: '16.8.0',
},
},
rules: {
'prettier/prettier': 'warn',
'react/prop-types': 'off',
'sort-imports': 'off',
'import/order': 'off',
'simple-import-sort/exports': 'warn',
'simple-import-sort/imports': [
'warn',
{
groups: [
['^\\u0000'], // side effect (E.g."import "normalize.css"")
['^react$'],
['^[^.]'], // Libs
['^../|^~/|^./'],
],
},
],
},
overrides: [
// Typescript related rules
{
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended'],
parserOptions: {
project: ['./tsconfig.json'],
},

rules: {
// We should absolutely avoid using ts-ignore, but it"s not always possible.
// particular when a dependencies types are incorrect.
'@typescript-eslint/ban-ts-comment': [
'warn',
{ 'ts-ignore': 'allow-with-description' },
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},

// Include website project
{
files: ['./website/*.ts', './website/*.tsx'],
parserOptions: {
project: ['./website/tsconfig.json'],
},
},

// Include CodeSandbox project
{
files: [
'./templates/codesandbox/src/**/*.ts',
'./templates/codesandbox/src/**/*.tsx',
],
parserOptions: {
project: ['./templates/codesandbox/tsconfig.json'],
},
},

// Track tree-shaking potential error in the lib
{
files: ['./src/**/!(*.test|*.spec).ts'],
plugins: ['tree-shaking'],
rules: {
'tree-shaking/no-side-effects-in-initialization': 2,
},
},

// Specials rules for testing
{
extends: ['plugin:jest/recommended'],
files: ['**/*.test.ts'],
plugins: ['jest'],
env: {
jest: true,
},
rules: {
// you should turn the original rule off *only* for test files
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
},
},
],
}
4 changes: 3 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const ignoreDirs = [

const config: Config.InitialOptions = {
testEnvironment: 'jsdom',
testEnvironmentOptions: {
url: `http://localhost`,
},
roots: packages,
transform: {
'^.+\\.[jt]sx?$': `<rootDir>/tests/jest-preprocess.js`,
Expand All @@ -33,7 +36,6 @@ const config: Config.InitialOptions = {
globals: {
__PATH_PREFIX__: ``,
},
testURL: `http://localhost`,
setupFiles: [`<rootDir>/tests/loadershim.js`],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.([tj]sx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
Expand Down
Loading

0 comments on commit f374cba

Please sign in to comment.