-
Notifications
You must be signed in to change notification settings - Fork 1
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
[#174416949] ESLint config #1
Conversation
Co-authored-by: Danilo Spinelli <[email protected]>
…nt-rules into 174416949-eslint-repo-config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from minor tuning
"functional/immutable-data": "error", | ||
"sonarjs/no-small-switch": "off", | ||
"sonarjs/no-duplicate-string": "error", | ||
"sonarjs/cognitive-complexity": ["error", 19], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must check on TSLint what is the current cap on cognitive complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value is 15
, we can use it and eventually tuning the value at the project level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a readme.md with the user manual ? (how to integrate in new projects and how to migrate from tslint in existing ones)
package.json
Outdated
@@ -0,0 +1,34 @@ | |||
{ | |||
"name": "io-eslint-rules", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the package and repo names diverge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tsconfig.json
Outdated
|
||
/* Basic Options */ | ||
// "incremental": true, /* Enable incremental compilation */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not es6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1 (comment)
tsconfig.json
Outdated
// "incremental": true, /* Enable incremental compilation */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | ||
"lib": ["es2015"], /* Specify library files to be included in the compilation. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1 (comment)
tsconfig.json
Outdated
@@ -0,0 +1,70 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a tsconfig.json here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added for local testing inside this project. We can safely remove it. Fixed in 1a44979
Co-authored-by: Emanuele De Cupis <[email protected]>
Co-authored-by: Emanuele De Cupis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart minor comments
"object-shorthand": "error", | ||
"no-var": "error", | ||
"no-param-reassign": "error", | ||
"no-underscore-dangle": "error", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it would break our convention of prefixing unused params with underscore. In case, we can add
"no-underscore-dangle": "error", | |
"no-underscore-dangle": ["error", { "allowFunctionParams": true }], |
See https://eslint.org/docs/rules/no-underscore-dangle#options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is, "allowFunctionParams": true (default) allows dangling underscores in function parameter names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we want it or not? I think we want to be able to write
const fn = (_p) => {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, maybe my comment wasn't clear. We can write const fn = (_p) => {}
, the option allowFunctionParams
has true
as default value.
complexity: "error", | ||
"arrow-body-style": "error", | ||
"import/no-internal-modules": "off", | ||
"import/order": "error", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine in having this, but I question if it's really useful
Great job guys! I'm loving this <3 |
…nt-rules into 174416949-eslint-repo-config
Co-authored-by: Emanuele De Cupis <[email protected]>
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "eslint-config", | |||
"name": "@pagopa/eslint-config", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
steps: | ||
- task: Npm@1 | ||
inputs: | ||
command: 'publish' | ||
workingDir: '.' | ||
publishEndpoint: 'NPM Registry' | ||
verbose: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't work as per this issue microsoft/azure-pipelines-tasks#14165
However we implemented a workaround here pagopa/io-functions-commons#131
I suggest you to do it in another PR in which you can refactor the whole pipeline
Porting TSLint rules configuration from
io-tslint-rules
to ESLint and merged withio-pay
ESLint configuration .The following TSLint rules are not supported for eslint at the moment: