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

A2.2 #7

Open
wants to merge 1 commit into
base: a2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions _explicacoes/a2.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## A2.2: Linter - garantindo de forma padronizada entre projetos a nossa code style guide

- https://eslint.org/
- `npm init @eslint/config@latest`
- https://docs.npmjs.com/cli/v7/using-npm/workspaces#ignoring-missing-scripts
- `npm run test --workspaces --if-present`
1 change: 1 addition & 0 deletions apps/company-front/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "@devsoutinho/commons-lint";
6 changes: 4 additions & 2 deletions apps/company-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"lint": "eslint './**/*.{jsx,tsx,js,ts}'",
"dev": "next dev",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -17,8 +18,9 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@devsoutinho/commons-lint": "*",
"typescript": "^5.4.5",
"@types/node": "^20.14.1",
"@types/react": "^18.3.3",
"typescript": "^5.4.5"
"@types/react": "^18.3.3"
}
}
1 change: 1 addition & 0 deletions apps/company-server/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "@devsoutinho/commons-lint";
2 changes: 2 additions & 0 deletions apps/company-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"lint": "eslint './**/*.{jsx,tsx,js,ts}'",
"start": "ts-node ./index.ts",
"dev": "nodemon ./index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -15,6 +16,7 @@
"@devsoutinho/commons-http-client": "*"
},
"devDependencies": {
"@devsoutinho/commons-lint": "*",
"@types/node": "^20.14.2",
"nodemon": "^3.1.3",
"ts-node": "^10.9.2",
Expand Down
1 change: 1 addition & 0 deletions commons/demo-test/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "@devsoutinho/commons-lint";
5 changes: 4 additions & 1 deletion commons/demo-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "1.0.0",
"main": "index.ts",
"scripts": {
"lint": "eslint './**/*.{jsx,tsx,js,ts}'"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {}
"devDependencies": {
"@devsoutinho/commons-lint": "*"
}
}
5 changes: 5 additions & 0 deletions commons/generator/plopfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ function commonPackage(plop: NodePlopAPI) {
type: "add",
path: path.resolve(ROOT_MONOREPO, "commons", "{{lowerCase packageName}}", "package.json"),
templateFile: "templates/common-package/package.json.hbs"
},
{
type: "add",
path: path.resolve(ROOT_MONOREPO, "commons", "{{lowerCase packageName}}", "eslint.config.mjs"),
templateFile: "templates/common-package/eslint.config.mjs.hbs"
}
] // Executar ações em cima dessas perguntas
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as default } from "@devsoutinho/commons-lint";
5 changes: 4 additions & 1 deletion commons/generator/templates/common-package/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"version": "1.0.0",
"main": "index.ts",
"scripts": {
"lint": "eslint './**/*.{jsx,tsx,js,ts}'"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {}
"devDependencies": {
"@devsoutinho/commons-lint": "*"
}
}
36 changes: 36 additions & 0 deletions commons/lint/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
import { fixupConfigRules } from "@eslint/compat";


export default [
{
languageOptions: { globals: {...globals.browser, ...globals.node} },
rules: {
"no-console": ["error", { allow: ["warn", "error"] }],
}
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
{
files: ["**/*.jsx"], languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } }
},
...fixupConfigRules({
...pluginReactConfig,
rules: {
...pluginReactConfig.rules,
// 0 - Desliga a validação
// 1 - Warn
// 2 - Error
"react/react-in-jsx-scope": 0,
}
}),
{
ignores: [
"node_modules/*",
".next",
]
}
];
19 changes: 19 additions & 0 deletions commons/lint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@devsoutinho/commons-lint",
"version": "1.0.0",
"main": "index.mjs",
"scripts": {
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"eslint": "^9.4.0",
"@eslint/compat": "^1.1.0",
"@eslint/js": "^9.4.0",
"eslint-plugin-react": "^7.34.2",
"globals": "^15.4.0",
"typescript-eslint": "^7.13.0"
}
}
Loading