Skip to content

Commit

Permalink
Feature/fix docs TS-672 (#4170)
Browse files Browse the repository at this point in the history
* updated README
* fix category/type doc classification
* improve code readability
* updated packages and documentation
* fix tests
  • Loading branch information
codacy-vrhpires authored Nov 24, 2023
1 parent 0691a68 commit e24df7e
Show file tree
Hide file tree
Showing 18 changed files with 3,465 additions and 4,076 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,48 @@
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/88324e5ee7464c62abe07115b884c6a9)](https://app.codacy.com/gh/codacy/codacy-eslint/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![CircleCI](https://circleci.com/gh/codacy/codacy-eslint.svg?style=svg)](https://circleci.com/gh/codacy/codacy-eslint)

## Adding new plugins / configs
## Adding new packages / plugins / configs

1. Install the package using npm:
1. Install the package / plugin using npm:

```bash
npm install <package-name>
npm install --legacy-peer-deps --omit=dev <package-name>
```

2. \[Plugins only\] Add the plugin to the plugins section in the file `src/eslintDefaultOptions.ts`
only if it's stated in the plugin's documentation
### Configuring new plugins
---
**NOTE**
Before adding a plugin to the Codacy UI, make sure it has widespread use and is actively maintained. Otherwise, installing it as described in point `1` can be enough for users using configuration files.
Before adding a plugin to the Codacy UI, make sure it has widespread use and is actively maintained.

---
3. \[Plugins only\] If the plugin has descriptions for rules on GitHub, reference them
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(
(pattern) =>
`${githubBaseUrl}/Rantanen/eslint-plugin-xss/master/docs/rules/${pattern}.md`,
`${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 matcher the correct name of the plugin
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 patterns's prefix
["xss", xssRules] // the first value has to match the plugin name
```
4. Generate documentation so it adds the new plugin documentation
5. Add a new test in `/docs/multiple-tests` that uses the newly added plugin or config.
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.
You can use the Getting Started section of the package documentation to find a small usage example.
## Generating documentation
```bash
npm install
npm run generateDocs
```
```bash
npm run docs:generate
```
## 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).
Expand Down
21 changes: 17 additions & 4 deletions docs/description/no-unused-vars.md

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

4 changes: 2 additions & 2 deletions docs/multiple-tests/all-patterns-typescript/results.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="test.ts">
<error source="jsdoc_require-file-overview" line="1" message="Missing @file" severity="info" />
<error source="unicorn_no-empty-file" line="1" message="Empty files are not allowed." severity="info" />
<error source="jsdoc_require-file-overview" line="1" message="Missing @file" severity="warning" />
<error source="unicorn_no-empty-file" line="1" message="Empty files are not allowed." severity="warning" />
</file>
<!-- This test is specifically made to test that codacy-eslint -->
<!-- should only return specific errors to test and/or empty files. -->
Expand Down
2 changes: 1 addition & 1 deletion docs/multiple-tests/big-codacy-configuration/results.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="big-codacy-configuration.js">
<error source="id-length" line="1" message="Identifier name 's' is too short (&lt; 3)." severity="info" />
<error source="id-length" line="1" message="Identifier name 's' is too short (&lt; 3)." severity="warning" />
</file>
</checkstyle>
2 changes: 1 addition & 1 deletion docs/multiple-tests/custom-parser/results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<error source="comma-dangle" line="10" message="Missing trailing comma." severity="info" />
<error source="comma-dangle" line="18" message="Missing trailing comma." severity="info" />
<error source="jsx-quotes" line="17" message="Unexpected usage of doublequote." severity="info" />
<error source="no-unused-vars" line="15" message="'IndexLink' is assigned a value but never used." severity="info" />
<error source="no-unused-vars" line="15" message="'IndexLink' is assigned a value but never used." severity="error" />
<error source="react_no-deprecated" line="1" message="React.PropTypes is deprecated since React 15.5.0, use the npm module prop-types instead" severity="info" />
<error source="react_no-deprecated" line="15" message="React.createClass is deprecated since React 15.5.0, use the npm module create-react-class instead" severity="info" />
<error source="react_no-comment-textnodes" line="1" message="Definition for rule 'react/no-comment-textnodes' was not found." severity="info" />
Expand Down
2 changes: 1 addition & 1 deletion docs/multiple-tests/file-errors/results.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<checkstyle version="4.3">
<file name="file-errors-correct.js">
<error source="no-unused-vars" line="1" message="'s' is assigned a value but never used." severity="info" />
<error source="no-unused-vars" line="1" message="'s' is assigned a value but never used." severity="error" />
</file>
<file name="file-errors-broken.js">
<error message="Parsing error: Unexpected token a" />
Expand Down
2 changes: 1 addition & 1 deletion docs/multiple-tests/security-node/results.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="security-node.js">
<error source="security-node_non-literal-reg-expr" line="2" message="Found RegExp with non literal argument" severity="error" />
<error source="security-node_non-literal-reg-expr" line="2" message="Found RegExp with non literal argument" severity="warning" />
</file>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="empty.story.ts">
<error source="storybook_default-exports" line="1" message="The file should have a default export." severity="info" />
<error source="storybook_default-exports" line="1" message="The file should have a default export." severity="error" />
</file>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="ts-import-without-config-file.ts">
<error source="@typescript-eslint_explicit-function-return-type" line="4" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="4" message="Missing return type on function." severity="error" />
</file>
</checkstyle>
6 changes: 3 additions & 3 deletions docs/multiple-tests/typescript-with-config-file/results.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="typescript-with-config-file.ts">
<error source="@typescript-eslint_explicit-function-return-type" line="10" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="17" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="40" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="10" message="Missing return type on function." severity="error" />
<error source="@typescript-eslint_explicit-function-return-type" line="17" message="Missing return type on function." severity="error" />
<error source="@typescript-eslint_explicit-function-return-type" line="40" message="Missing return type on function." severity="error" />
</file>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="typescript-without-config-file.ts">
<error source="@typescript-eslint_explicit-function-return-type" line="10" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="17" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="40" message="Missing return type on function." severity="info" />
<error source="@typescript-eslint_explicit-function-return-type" line="10" message="Missing return type on function." severity="error" />
<error source="@typescript-eslint_explicit-function-return-type" line="17" message="Missing return type on function." severity="error" />
<error source="@typescript-eslint_explicit-function-return-type" line="40" message="Missing return type on function." severity="error" />
</file>
</checkstyle>
4 changes: 2 additions & 2 deletions docs/multiple-tests/with-config-file/results.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<checkstyle version="4.3">
<file name="with-config-file.js">
<error source="eol-last" line="18" message="Newline required at end of file but not found." severity="info" />
<error source="no-redeclare" line="10" message="'o' is already defined." severity="info" />
<error source="strict" line="3" message="Use the global form of 'use strict'." severity="info" />
<error source="no-redeclare" line="10" message="'o' is already defined." severity="warning" />
<error source="strict" line="3" message="Use the global form of 'use strict'." severity="warning" />
</file>
</checkstyle>
2 changes: 1 addition & 1 deletion docs/multiple-tests/without-config-file/results.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="without-config-file.js">
<error source="accessor-pairs" line="5" message="Getter is not present for setter 'a'." severity="info" />
<error source="accessor-pairs" line="5" message="Getter is not present for setter 'a'." severity="warning" />
</file>
</checkstyle>
Loading

0 comments on commit e24df7e

Please sign in to comment.