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

Fix/Codacy issues TS-724 #4247

Merged
merged 10 commits into from
Jan 4, 2024
Merged
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
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
env: {
es6: true,
node: true,
mocha: true
},
extends: [
"eslint:recommended",
Expand All @@ -11,7 +12,16 @@ module.exports = {
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
describe: true,
it: true
},
ignorePatterns: [
"node_modules/",
"dist/",
"tests/",
"tsconfig.json",
".eslintrc*"
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
Expand All @@ -34,4 +44,12 @@ module.exports = {
"simple-import-sort/imports": "error",
'@typescript-eslint/unbound-method': 'off'
},
overrides: [
{
files: ["*.spec.js", "*.spec.ts"],
env: {
mocha: true
}
}
]
}
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ARG NODE_IMAGE_VERSION=node:lts-alpine3.19

FROM $NODE_IMAGE_VERSION as builder
FROM node:lts-alpine3.19 as builder

COPY . ./

Expand All @@ -10,7 +8,7 @@ RUN npm install --legacy-peer-deps --omit=dev &&\
npm test &&\
npm run build:docs

FROM $NODE_IMAGE_VERSION
FROM node:lts-alpine3.19

COPY --from=builder dist dist
COPY --from=builder docs docs
Expand Down
103 changes: 55 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,74 @@

## Adding new packages / plugins / configs

1. Install the package / plugin using npm:
Install the package / plugin using npm:
```shell
npm install --legacy-peer-deps --omit=dev package-name
```

```bash
npm install --legacy-peer-deps --omit=dev <package-name>
```
## Configuring new plugins

### Configuring new plugins
---
**NOTE**
Before adding a plugin to the Codacy UI, make sure it has widespread use and is actively maintained.
**NOTE**: Before adding a plugin to the Codacy UI, make sure it has widespread use and is actively maintained.

---
1. If the plugin has descriptions for rules on GitHub, reference them
at `src/docGeneratorMain.ts` to include them on the generated documentation. To do this, add a section similar to the following example:

```typescript
console.log("Generate xss description files")
await docGenerator.downloadDocs(
`${githubBaseUrl}/Rantanen/eslint-plugin-xss/master/docs/rules/`,
"xss", // this is the pattern's prefix, like: xss/some-pattern-id
false // Add false for plugins not having .md files for all the patterns
)
```
As well, in `src/eslintPlugins.ts` add two new entries
```typescript
import { rules as xssRules } from "eslint-plugin-xss" // make sure this one matches the correct name of the package
```
and in the const plugins list
```typescript
["xss", xssRules] // the first value has to match the plugin name
at `src/docGeneratorMain.ts` to include them on the generated documentation.

- Add a section similar to the following example:
```typescript
await docGenerator.downloadDocs(
// path to .md pattern files within github
`/Rantanen/eslint-plugin-xss/master/docs/rules/`,
// this is the pattern's prefix (e.g., xss/some-pattern-id)
"xss",
// (default) change to true if it should fail in case of missing .md files for any pattern
false
)
```

- In `src/eslintPlugins.ts` add two new entries similar to the following examples:
```typescript
// make sure this one matches the correct name of the package
import { rules as xssRules } from "eslint-plugin-xss"
```
```typescript
// the first value has to match the plugin name
["xss", xssRules]
```

2. Generate documentation so it adds the new plugin documentation.

```shell
npm run build:docs
```
3. Generate documentation so it adds the new plugin documentation.
4. Add a new test in `/docs/multiple-tests` that uses the newly added plugin.

3. Add a new test in `/docs/multiple-tests` that uses the newly added plugin.
You can use the Getting Started section of the package documentation to find a small usage example.

## Generating documentation

```bash
npm run build:docs
```
```shell
npm run build:docs
```

## Test changes to codacy-seed locally

You may need to test changes that comes from our [codacy-engine-typescript-seed](https://github.com/codacy/codacy-engine-typescript-seed).

1. Create a package with your changes on the seed:
* Don't forget to update the dependencies: `npm install`
* Compile the library: `npm run compile`
* Package the library: `npm pack`
> This should generate a codacy-seed-0.0.1.tgz on your codacy-seed repository
* Don't forget to update the dependencies: `npm install`
* Compile the library: `npm run compile`
* Package the library: `npm pack`
> This should generate a codacy-seed-0.0.1.tgz on your codacy-seed repository

2. Copy the `codacy-seed-0.0.1.tgz` into the root of this repository

3. Install the package: `npm install codacy-seed-0.0.1.tgz`

4. Update Dockerfile and `.dockerignore` so you copy the `codacy-seed-0.0.1.tgz` inside the docker you will be building
* Add `!codacy-seed-0.0.1.tgz` to your `.dockerignore`
* Add the package to the docker before `RUN npm install`: `COPY codacy-seed-0.0.1.tgz ./`
* Remove multi-stage docker steps
* Lines from `FROM node:$NODE_IMAGE_VERSION` to `RUN rm -rf /package.json /package-lock.json`
* Add `!codacy-seed-0.0.1.tgz` to your `.dockerignore`
* Add the package to the docker before `RUN npm install`: `COPY codacy-seed-0.0.1.tgz ./`
* Remove multi-stage docker steps
- Lines from the beginning of the file until `RUN rm -rf /package.json /package-lock.json`
> This way you skip copying the files to the other docker, and another `npm install`

5. Publish your docker locally as normal: `docker build -t codacy-eslint:local .`
Expand All @@ -72,23 +81,21 @@ You may need to test changes that comes from our [codacy-engine-typescript-seed]

### Incompatible rules

There are some ESLint rules that will be ignored when running this Docker container. For more details on the ignored
rules, check `blacklistRegexes` defined at [blacklist.ts](src/blacklist.ts).
There are some ESLint rules that will be ignored when running this Docker container. For more details on the ignored rules, check `blacklistRegexes` defined at [blacklist.ts](src/blacklist.ts).

Usually, these rules need an Internet connection and/or to check `node_modules`, and would not run successfully
on our Docker container environment.
Usually, these rules need an Internet connection and/or to check `node_modules`, and would not run successfully on our Docker container environment.

## What is Codacy

[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

### Among Codacy’s features

- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories
- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions docs/description/@typescript-eslint_no-floating-promises.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 41 additions & 23 deletions docs/description/@typescript-eslint_switch-exhaustiveness-check.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/description/description.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading