Skip to content

Commit

Permalink
Partially migrating monorepo linting to microservices using turborepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Cong Van authored and Thanh Cong Van committed Feb 2, 2022
1 parent 3311a26 commit 19ca3ee
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"dependsOn": [
"^build"
]
}
},
"lint": {}
}
},
"pnpm": {
Expand Down
110 changes: 110 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 165 additions & 0 deletions src/web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
module.exports = {
// env: {
// browser: true,
// commonjs: true,
// es2021: true,
// },
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2021,
},
extends: [
'airbnb',
'plugin:prettier/recommended',
'plugin:promise/recommended',
'plugin:jest-playwright/recommended',
'plugin:import/recommended',
],
plugins: ['prettier', 'promise', 'jest', 'anti-trojan-source'],
settings: {
'import/resolver': {
node: {},
},
react: {
version: '17.0',
},
},
overrides: [
// TypeScript for Next.js
{
files: ['src/web/**/*.ts', 'src/web/**/*.tsx'],
extends: [
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:import/typescript',
],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
env: {
browser: true,
},
rules: {
'react/prop-types': 'off',
'react/require-default-props': 'off',
'react/react-in-jsx-scope': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'react/jsx-filename-extension': ['error', { extensions: ['.ts', '.tsx'] }],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'jsx-a11y/anchor-is-valid': [
'error',
{
components: ['Link'],
specialLink: ['hrefLeft', 'hrefRight'],
aspects: ['invalidHref', 'preferButton'],
},
],
'import/extensions': 'off',
// Allow using TypeScript constructor shorthand: `Foo(public bar: string){}`
'no-useless-constructor': 'off',
'no-empty-function': 'off',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
},
],
rules: {
/**
* Force prettier formatting
*/
'prettier/prettier': 'error',
/**
* Disallow the use of console
* https://eslint.org/docs/rules/no-console
*/
'no-console': 'off',

/**
* Disallow Reassignment of Function Parameters
* https://eslint.org/docs/rules/no-param-reassign
*/
'no-param-reassign': ['error', { props: false }],

/** Disallows unnecessary return await
* https://eslint.org/docs/rules/no-return-await
*/
'no-return-await': 'error',
/**
* Disallow using an async function as a Promise executor
* https://eslint.org/docs/rules/no-async-promise-executor
*/
'no-async-promise-executor': 'error',
/**
* Disallow await inside of loops
* https://eslint.org/docs/rules/no-await-in-loop
*/
'no-await-in-loop': 'error',

/**
* Disallow assignments that can lead to race conditions due to
* usage of await or yield
* https://eslint.org/docs/rules/require-atomic-updates
*/
'require-atomic-updates': 'error',

/**
* Disallow async functions which have no await expression
* https://eslint.org/docs/rules/require-await
*/
'require-await': 'error',

/**
* Require or disallow named function expressions
* https://eslint.org/docs/rules/func-names
*/
'func-names': 'off',
/**
* Disallow enforcement of consistent linebreak style
* https://eslint.org/docs/rules/func-names
*/
'linebreak-style': 'off',

/**
* Prevent variables used in JSX to be incorrectly marked as unused
*/
'react/jsx-uses-vars': 'error',

/**
* Allow ES6 classes to override methods without using this
* https://eslint.org/docs/rules/class-methods-use-this
*/
'class-methods-use-this': 'off',

'react/jsx-props-no-spreading': 'off',
'react/jsx-wrap-multilines': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/no-danger': 'off',

'jsx-a11y/control-has-associated-label': 'warn',

/**
* Due to having our dev dependencies in a monorepo layout, this is
* difficult to configure properly. Disabling for now.
*/
'import/no-extraneous-dependencies': ['off'],
'no-new': 'off',

/**
* False positive of no-shadow rule with ENUMs
* https://github.com/typescript-eslint/typescript-eslint/issues/2483
*/
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',

/**
* Halt if a trojan source attack is found
* https://github.com/lirantal/eslint-plugin-anti-trojan-source
*/
'anti-trojan-source/no-bidi': 'error',
},
};
16 changes: 15 additions & 1 deletion src/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@
"@types/node": "16.11.18",
"@types/react": "17.0.38",
"babel-loader": "8.2.3",
"eslint": "7.32.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-anti-trojan-source": "1.1.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "25.3.4",
"eslint-plugin-jest-playwright": "0.2.1",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-prettier": "3.4.1",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-react": "7.28.0",
"eslint-plugin-react-hooks": "4.3.0",
"eslint-plugin-react-native": "4.0.0",
"terser-webpack-plugin": "5.3.0",
"typescript": "4.5.4"
},
Expand All @@ -42,7 +55,8 @@
"scripts": {
"build": "next build && next export",
"dev": "next dev -p 8000",
"start": "next start -p 8000"
"start": "next start -p 8000",
"lint": "pnpm eslint"
},
"version": "3.0.0"
}

0 comments on commit 19ca3ee

Please sign in to comment.