Skip to content

Commit

Permalink
Merge pull request #60 from pegasystems/bugfix/linting
Browse files Browse the repository at this point in the history
clean up linting rules - upgrade libs
  • Loading branch information
ricmars authored May 12, 2024
2 parents f699c33 + c72b268 commit 2750909
Show file tree
Hide file tree
Showing 28 changed files with 640 additions and 1,365 deletions.
9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

170 changes: 9 additions & 161 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"root": true,
"extends": ["@pega"],
"parserOptions": {
"project": "tsconfig.json",
"ecmaVersion": 13
"project": "tsconfig.json"
},
"globals": {
"PCore": "readonly"
Expand All @@ -12,7 +11,7 @@
"import/resolver": {
"typescript": {},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
"extensions": [".ts", ".tsx"]
}
},
"react": {
Expand All @@ -29,179 +28,28 @@
"**/mock.stories.js",
"**/demo.stories.tsx",
"**/mock.stories.ts",
"**/*.mdx"
"**/*.mdx",
"babel.config.js",
"jest.config.js",
"**/*.html"
],
"rules": {
// Prettier recommends running separately from a linter.
// https://prettier.io/docs/en/integrating-with-linters.html#notes
"prettier/prettier": "off",

// Disable rules from shared configs we're not ready for yet.
"sonarjs/cognitive-complexity": "off",
"sonarjs/no-identical-functions": "off",
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",

//
// JA - Override some default lint handling here
"@typescript-eslint/array-type": "off",
// "import/extensions": ["warn", "never"], // Turning off for now (see below)

//
// Initial release: turning these off; phase in to "warn" or "error" over time
// For "quotes" and "@typescript-eslint/quotes", see override below for .ts/.tsx files
"import/extensions": ["off", "never"],
"import/named": "off",
"import/no-cycle": "off",
"import/no-duplicates": "off",
"import/no-relative-packages": "off",
"import/no-extraneous-dependencies": "off",
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"import/no-self-import": "off",
"import/no-unresolved": "off",
"import/no-useless-path-segments": "off",
"import/order": "off",

"no-else-return": "off",
"no-restricted-syntax": "off",
"no-underscore-dangle": "off",

"jsx-a11y/alt-text": "off",
"jsx-a11y/anchor-is-valid": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/label-has-associated-control": "off",
"jsx-a11y/no-static-element-interactions": "off",

"react/jsx-fragments": "off",
"react/jsx-no-bind": "off",
"react/self-closing-comp": "off",

"sonarjs/prefer-immediate-return": "off",

"@typescript-eslint/dot-notation": "off", // prefer warn but needs different parserOptions
"@typescript-eslint/naming-convention": "off", // prefer warn but needs different parserOptions
"@typescript-eslint/ban-types": "off", // also, see override below

//
// Initial release: set to error
"@typescript-eslint/no-inferrable-types": "error",
"eqeqeq": "off",
"no-alert": "off",
"no-console": "error",
"no-fallthrough": "error",
"no-undef": "error",
"no-unused-vars": "off",
"no-var": "off",
"yoda": "error",
"no-irregular-whitespace": "off",
"no-empty": "off",
"no-new-object": "off",
"import/no-relative-packages": "off",

"import/no-mutable-exports": "error",
"sonarjs/max-switch-cases": "error",
"sonarjs/no-collapsible-if": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-gratuitous-expressions": "error",
"sonarjs/no-ignored-return": "error",
"sonarjs/no-small-switch": "error",
"sonarjs/prefer-object-literal": "error",
"sonarjs/prefer-single-boolean-return": "error",
"@typescript-eslint/no-shadow": "error",
"react/default-props-match-prop-types": "error",
"react/no-unescaped-entities": "error",
"react/no-unused-prop-types": "error",
"react/static-property-placement": "error",
"array-callback-return": "error",
"camelcase": "error",
"func-names": "error",
"no-case-declarations": "error",
"no-lonely-if": "error",
"no-nested-ternary": "error",
"no-plusplus": "error",
"no-restricted-globals": "error",
"no-restricted-properties": "error",
"no-shadow": "error",
"radix": "error",
"spaced-comment": "error",

"import/newline-after-import": "error",
"sonarjs/no-nested-switch": "error",
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-useless-constructor": "error",
"react/button-has-type": "error",
"react/jsx-curly-brace-presence": "error",
"react/jsx-boolean-value": "error",
"react/no-array-index-key": "error",
"class-methods-use-this": "error",
"guard-for-in": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"operator-assignment": "error",
"prefer-template": "error",
"vars-on-top": "error",
"prefer-regex-literals": "off",

"no-use-before-define": "off", // doc for @typescript-eslint/no-use-before-define says to turn off the base implementation
"@typescript-eslint/no-use-before-define": "error"
},
"overrides": [
{
"files": "*.@(ts|tsx)",
"rules": {
"@typescript-eslint/method-signature-style": ["error", "property"],
"quotes": "off",
"@typescript-eslint/quotes": "off"
}
},
{
"files": "*.@(jsx|tsx|mdx)",
"rules": {
"react/react-in-jsx-scope": "off",
"react-hooks/exhaustive-deps": [
"off",
{
"additionalHooks": "useAfterInitialEffect"
}
]
}
},
{
// rules for typescript (keeping old rules for js)
"files": "*.@(ts|tsx)",
"rules": {
"no-undef": "off",
"no-console": "off",
"import/prefer-default-export": "off",
"import/no-relative-packages": "off",
"react/jsx-fragments": "off",
"react/react-in-jsx-scope": "off",
// Set up configuration for future sweep
"react-hooks/exhaustive-deps": [
"error",
{
"additionalHooks": "useAfterInitialEffect"
}
],
"sonarjs/cognitive-complexity": ["warn", 45]
}
},
{
"files": "*.@(js|jsx|ts|tsx|mdx)",
"rules": {}
},
{
"files": ".storybook/*.js",
"extends": ["@pega/eslint-config/script"]
},
{
"files": "*/**/mocks/**.@(mocks|styles).@(tsx|ts)",
"rules": {
"import/prefer-default-export": ["off"]
}
}
]
"import/order": "off"
}
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To build and compile the application - use the following commands:

Install npm from [nodejs.org](https://nodejs.org/en/download/)

You should have the following versions installed: System node version 18.13.0 and npm version 8.
You should have the following versions installed: System node version 18.x and npm version 8.x.

If you already have [VS Code](https://code.visualstudio.com/) and [Docker](https://docs.docker.com/get-docker/) installed, you can click [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/pegasystems/constellation-ui-gallery) to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.

Expand All @@ -36,6 +36,22 @@ npm install
npm run start
```

### Linting

Make sure to install the recommended VS Code extension. Before checking code, make sure that no error are reported:

```shell
npm run lint
```

To fix some of the issues:

```shell
npm run fix
```

The coverage report index.html will be in the 'coverage' folder

### Unit testing

For unit test results, you can run:
Expand Down
Loading

0 comments on commit 2750909

Please sign in to comment.