You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/developers/contributing.md
+17-22Lines changed: 17 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ New contributions to the library are welcome, but we ask that you please follow
6
6
7
7
- Before opening a PR for major additions or changes, please discuss the expected API and/or implementation by [filing an issue](https://github.com/chartjs/Chart.js/issues) or asking about it in the [Chart.js Slack](https://chartjs-slack.herokuapp.com/) #dev channel. This will save you development time by getting feedback upfront and make review faster by giving the maintainers more context and details.
8
8
- Consider whether your changes are useful for all users, or if creating a Chart.js [plugin](plugins.md) would be more appropriate.
9
-
- Check that your code will pass tests and `eslint` code standards. `gulp test` will run both the linter and tests for you.
9
+
- Check that your code will pass tests and `eslint` code standards. `npm test` will run both the linter and tests for you.
10
10
- Add unit tests and document new functionality (in the `test/` and `docs/` directories respectively).
11
11
- Avoid breaking changes unless there is an upcoming major release, which are infrequent. We encourage people to write plugins for most new advanced features, and care a lot about backwards compatibility.
12
12
- We strongly prefer new methods to be added as private whenever possible. A method can be made private either by making a top-level `function` outside of a class or by prefixing it with `_` and adding `@private` JSDoc if inside a class. Public APIs take considerable time to review and become locked once implemented as we have limited ability to change them without breaking backwards compatibility. Private APIs allow the flexibility to address unforeseen cases.
@@ -17,40 +17,34 @@ Active committers and contributors are invited to introduce yourself and request
17
17
18
18
## Building and Testing
19
19
20
-
Chart.js uses <ahref="https://gulpjs.com/"target="_blank">gulp</a> to build the library into a single JavaScript file.
21
-
22
20
Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
23
21
24
22
```bash
25
23
> npm install
26
-
> npm install -g gulp-cli
27
24
```
28
25
29
-
This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <ahref="https://gulpjs.com/"target="_blank">gulp</a>.
26
+
This will install the local development dependencies for Chart.js.
30
27
31
28
The following commands are now available from the repository root:
32
29
33
30
```bash
34
-
> gulp build // build dist files in ./dist
35
-
> gulp build --watch // build and watch for changes
36
-
> gulp unittest // run tests from ./test/specs
37
-
> gulp unittest --watch // run tests and watch forsource changes
38
-
> gulp unittest --coverage // run tests and generate coverage reports in ./coverage
39
-
> gulp lint // perform code linting (ESLint)
40
-
> gulp test // perform code linting and run unit tests
41
-
> gulp test --browsers ... // test with specified browsers (comma-separated)
31
+
> npm run build // build dist files in ./dist
32
+
> npm run autobuild // build and watch forsource changes
33
+
> npm run dev // run tests and watch forsource and test changes
34
+
> npm run lint // perform code linting (ESLint, tsc)
35
+
> npm test // perform code linting and run unit tests with coverage
42
36
```
43
37
44
-
More information can be found in [gulpfile.js](https://github.com/chartjs/Chart.js/blob/master/gulpfile.js).
38
+
`npm run dev` and `npm test`can be appended with a string that is used to match the spec filenames. For example: `npm run dev plugins` will start karma in watch mode for `test/specs/**/*plugin*.js`.
45
39
46
40
### Documentation
47
41
48
42
We use [Docusaurus v2](https://v2.docusaurus.io/docs/introduction) to manage the docs which are contained as Markdown files in the docs directory. You can run the doc server locally using the commands provided by Docusaurus:
49
43
50
-
```
51
-
$ cd docs
52
-
$ npm install
53
-
$ npm run start
44
+
```bash
45
+
>cd docs
46
+
> npm install
47
+
> npm run start
54
48
```
55
49
56
50
### Image-Based Tests
@@ -60,10 +54,11 @@ Some display-related functionality is difficult to test via typical Jasmine unit
60
54
Generated charts in image-based tests should be **as minimal as possible** and focus only on the tested feature to prevent failure if another feature breaks (e.g. disable the title and legend when testing scales).
61
55
62
56
You can create a new image-based test by following the steps below:
57
+
63
58
- Create a JS file ([example](https://github.com/chartjs/Chart.js/blob/f7b671006a86201808402c3b6fe2054fe834fd4a/test/fixtures/controller.bubble/radius-scriptable.js)) or JSON file ([example](https://github.com/chartjs/Chart.js/blob/4b421a50bfa17f73ac7aa8db7d077e674dbc148d/test/fixtures/plugin.filler/fill-line-dataset.json)) that defines chart config and generation options.
64
59
- Add this file in `test/fixtures/{spec.name}/{feature-name}.json`.
65
60
- Add a [describe line](https://github.com/chartjs/Chart.js/blob/4b421a50bfa17f73ac7aa8db7d077e674dbc148d/test/specs/plugin.filler.tests.js#L10) to the beginning of `test/specs/{spec.name}.tests.js` if it doesn't exist yet.
66
-
- Run `gulp unittest --watch --inputs=test/specs/{spec.name}.tests.js`.
61
+
- Run `npm run dev`.
67
62
- Click the *"Debug"* button (top/right): a test should fail with the associated canvas visible.
68
63
- Right click on the chart and *"Save image as..."*`test/fixtures/{spec.name}/{feature-name}.png` making sure not to activate the tooltip or any hover functionality
69
64
- Refresh the browser page (`CTRL+R`): test should now pass
@@ -81,8 +76,8 @@ Well structured, detailed bug reports are hugely valuable for the project.
81
76
82
77
Guidelines for reporting bugs:
83
78
84
-
- Check the issue search to see if it has already been reported
85
-
- Isolate the problem to a simple test case
86
-
- Please include a demonstration of the bug on a website such as [JS Bin](https://jsbin.com/), [JS Fiddle](https://jsfiddle.net/), or [Codepen](https://codepen.io/pen/). ([Template](https://codepen.io/pen?template=JXVYzq)). If filing a bug against `master`, you may reference the latest code via https://www.chartjs.org/dist/master/Chart.min.js (changing the filename to point at the file you need as appropriate). Do not rely on these files for production purposes as they may be removed at any time.
79
+
- Check the issue search to see if it has already been reported
80
+
- Isolate the problem to a simple test case
81
+
- Please include a demonstration of the bug on a website such as [JS Bin](https://jsbin.com/), [JS Fiddle](https://jsfiddle.net/), or [Codepen](https://codepen.io/pen/). ([Template](https://codepen.io/pen?template=JXVYzq)). If filing a bug against `master`, you may reference the latest code via <https://www.chartjs.org/dist/master/Chart.min.js> (changing the filename to point at the file you need as appropriate). Do not rely on these files for production purposes as they may be removed at any time.
87
82
88
83
Please provide any additional details associated with the bug, if it's browser or screen density specific, or only happens with a certain configuration or data.
0 commit comments