Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: chore: use Nx workspace lint rules #3163

Merged
merged 5 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
module.exports = {
root: true,
extends: ['plugin:prettier/recommended'],
plugins: ['@nx', 'prefer-arrow', 'simple-import-sort', 'unused-imports'],
rules: {
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'no-console': ['warn', { allow: ['group', 'groupCollapsed', 'groupEnd'] }],
'no-unused-vars': 'off',
'no-control-regex': 0,
'no-undef': 'off',

'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: [],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],

'prefer-arrow/prefer-arrow-functions': [
'error',
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: false,
},
],

'simple-import-sort/imports': [
'error',
{
groups: [
['^react', '^@?\\w'],
['^(@|~)(/.*|$)'],
['^\\u0000'],
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
['^.+\\.?(css)$'],
],
},
],
'simple-import-sort/exports': 'error',

'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: ['plugin:@nx/typescript'],
rules: {
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'no-type-imports' },
],
},
},
{
files: ['*.js', '*.jsx'],
extends: ['plugin:@nx/javascript'],
rules: {},
},
{
files: ['*.spec.@(ts|tsx|js|jsx)', '*.test.@(ts|tsx|js|jsx)'],
env: {
jest: true,
},
rules: {},
},
],
};
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
!.yarn/releases
!.yarn/sdks
!.yarn/versions
coverage
.vercel

# yarn.lock should be managed at the root level only (nx monorepo)
**/yarn.lock
**/yarn.lock
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
/.nx/cache
2 changes: 1 addition & 1 deletion packages/twenty-front/.prettierrc → .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "auto"
}
}
18 changes: 10 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"recommendations": [
"ms-vscode-remote.remote-containers",
"styled-components.vscode-styled-components",
"arcanis.vscode-zipfs",
"dbaeumer.vscode-eslint",
"unifiedjs.vscode-mdx",
"ms-vscode.makefile-tools",
"esbenp.prettier-vscode",
"GraphQL.vscode-graphql",
"yoavbls.pretty-ts-errors",
"figma.figma-vscode-extension",
"firsttris.vscode-jest-runner",
"graphql.vscode-graphql-syntax",
"GraphQL.vscode-graphql",
"graphql.vscode-graphql",
"figma.figma-vscode-extension",
"ms-vscode-remote.remote-containers",
"ms-vscode.makefile-tools",
"nrwl.angular-console",
"styled-components.vscode-styled-components",
"unifiedjs.vscode-mdx",
"xyc.vscode-mdx-preview",
"arcanis.vscode-zipfs"
"yoavbls.pretty-ts-errors"
]
}
8 changes: 4 additions & 4 deletions .vscode/twenty.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"name": "ROOT",
"path": "../"
},
{
"name": "packages/eslint-plugin-twenty",
"path": "../packages/eslint-plugin-twenty"
},
{
"name": "packages/twenty-docker",
"path": "../packages/twenty-docker"
Expand Down Expand Up @@ -36,6 +32,10 @@
"name": "packages/twenty-zapier",
"path": "../packages/twenty-zapier"
},
{
"name": "tools/eslint-rules",
"path": "../tools/eslint-rules"
},
],
"settings": {
"files.exclude": {
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getJestProjects } from '@nx/jest';

export default {
projects: getJestProjects(),
};
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;

module.exports = { ...nxPreset };
24 changes: 22 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"targetDefaults": {
"build": {
"cache": true,
"dependsOn": ["^build"]
"dependsOn": [
"^build"
]
},
"lint": {
"cache": true
Expand All @@ -12,12 +14,30 @@
},
"e2e": {
"cache": true
},
"@nx/jest:jest": {
"cache": true,
"inputs": [
"default",
"^default",
"{workspaceRoot}/jest.preset.js"
],
"options": {
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
},
"installation": {
"version": "17.2.0"
"version": "17.2.7"
},
"affected": {
"defaultBase": "main"
}
}

85 changes: 80 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,95 @@
"license": "AGPL-3.0",
"workspaces": {
"packages": [
"packages/eslint-plugin-twenty",
"packages/twenty-front",
"packages/twenty-docs",
"packages/twenty-server",
"packages/twenty-utils",
"packages/twenty-zapier",
"packages/twenty-website"
"packages/twenty-website",
"tools/eslint-rules"
]
},
"devDependencies": {
"nx": "17.2.0",
"typescript": "^5.3.3"
"@graphql-codegen/cli": "^3.3.1",
"@graphql-codegen/client-preset": "^4.1.0",
"@graphql-codegen/typescript": "^3.0.4",
"@graphql-codegen/typescript-operations": "^3.0.4",
"@graphql-codegen/typescript-react-apollo": "^3.3.7",
"@nx/eslint": "17.2.7",
"@nx/eslint-plugin": "17.2.7",
"@nx/jest": "17.2.7",
"@nx/js": "17.2.7",
"@storybook/addon-actions": "^7.6.3",
"@storybook/addon-coverage": "^1.0.0",
"@storybook/addon-essentials": "^7.6.3",
"@storybook/addon-interactions": "^7.6.3",
"@storybook/addon-links": "^7.6.3",
"@storybook/addon-onboarding": "^1.0.9",
"@storybook/addon-themes": "^7.6.3",
"@storybook/blocks": "^7.6.3",
"@storybook/react": "^7.6.3",
"@storybook/react-vite": "^7.6.3",
"@storybook/test": "^7.6.3",
"@storybook/test-runner": "^0.16.0",
"@stylistic/eslint-plugin": "^1.5.0",
"@swc-node/register": "~1.6.7",
"@swc/core": "~1.3.100",
"@testing-library/jest-dom": "^6.1.5",
"@testing-library/react": "^13.4.0",
"@types/apollo-upload-client": "^17.0.2",
"@types/deep-equal": "^1.0.1",
"@types/jest": "^29.5.11",
"@types/js-cookie": "^3.0.3",
"@types/lodash.camelcase": "^4.3.7",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash.kebabcase": "^4.1.7",
"@types/lodash.snakecase": "^4.1.9",
"@types/luxon": "^3.3.0",
"@types/node": "20.10.0",
"@types/react": "^18.2.39",
"@types/react-datepicker": "^4.11.2",
"@types/react-dom": "^18.2.15",
"@types/scroll-into-view": "^1.16.0",
"@types/uuid": "^9.0.1",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@typescript-eslint/utils": "^6.9.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"chromatic": "^6.18.0",
"concurrently": "^8.0.1",
"cross-var": "^1.1.0",
"dotenv-cli": "^7.2.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-unused-imports": "^3.0.0",
"http-server": "^14.1.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"msw": "^2.0.11",
"msw-storybook-addon": "2.0.0--canary.122.b3ed3b1.0",
"nx": "17.2.7",
"prettier": "3.1.0",
"storybook": "^7.6.3",
"storybook-addon-cookie": "^3.1.0",
"storybook-addon-pseudo-states": "^2.1.2",
"ts-jest": "^29.1.1",
"ts-node": "10.9.1",
"typescript": "^5.3.3",
"vite": "^5.0.0",
"vite-plugin-svgr": "^4.2.0"
},
"dependencies": {
"patch-package": "^8.0.0"
"patch-package": "^8.0.0",
"tslib": "^2.3.0"
}
}
70 changes: 0 additions & 70 deletions packages/eslint-plugin-twenty/.eslintrc.js

This file was deleted.

Loading
Loading