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

[OSCI][Enhancement] precommit(husky) and tsconfig changes #931

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ module.exports = {
extends: ["@elastic/eslint-config-kibana", "plugin:@elastic/eui/recommended"],
rules: {
// "@osd/eslint/require-license-header": "off"
"import/no-default-export": "off",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
],
"@osd/eslint/no-restricted-paths": [
"error",
{
basePath: __dirname,
zones: [
{
target: ["(public|server)/**/*"],
from: ["../../packages/**/*", "packages/**/*"],
},
],
},
],
Comment on lines +28 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the idea behind this rule, can you add a message that can explain, like here https://github.com/opensearch-project/OpenSearch-Dashboards/blame/791210de027467f95b13f7e0c9582fa149e08eb5/.eslintrc.js#L277

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn
The "@osd/eslint/no-restricted-paths" rule in the ESLint configuration was added to enforce module import restrictions within the codebase.
"@typescript-eslint/naming-convention" rule: it was added to enforce consistent naming conventions across the codebase. This rule specifies that all identifiers (like variables, classes, interfaces, etc.) should follow one of the defined formats: camelCase, UPPER_CASE, PascalCase, or snake_case. It also allows for leading and trailing underscores.

Please let me know if you want me to remove any/both of these rules

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for @osd/eslint/no-restricted-paths part, I suppose it's restricting import from packages in public or server. I am just not sure what's the ideo behind this. @kohinoor98

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osd/eslint/no-restricted-paths: It prevents certain parts of your codebase (like public-facing or server-side code) from importing modules from restricted directories, which might be private and not intended for such use.
@bowenlan-amzn

},
overrides: [
{
Expand Down
8 changes: 7 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"*.{ts,tsx,js,jsx,json,css,md}": ["prettier --write", "git add"]
"*.{ts,tsx}": [
"npx eslint --fix",
"prettier --write"
],
"*.{js,jsx,json,css,md}": [
"prettier --write"
]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"osd": "node ../../scripts/osd",
"opensearch": "node ../../scripts/opensearch",
"lint": "node ../../scripts/eslint . && node ../../scripts/stylelint",
"eslint:fix": "npx eslint '**/*.{ts,tsx}' --fix",
kohinoor98 marked this conversation as resolved.
Show resolved Hide resolved
"eslint:run": "npx eslint '**/*.{ts,tsx}'",
"plugin-helpers": "node ../../scripts/plugin_helpers",
"test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js",
"build": "yarn plugin-helpers build",
Expand Down Expand Up @@ -73,4 +75,4 @@
"engines": {
"yarn": "^1.21.1"
}
}
}
Loading