Skip to content

Commit 540257e

Browse files
authored
Extend linting to types and markdown, fix errors (#368)
1 parent 3a2e7f3 commit 540257e

File tree

15 files changed

+472
-51
lines changed

15 files changed

+472
-51
lines changed

.markdownlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MD013: false # line-length
2+
MD033: false # inline HTML
3+
MD041: false # first line heading

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Contributing
2+
13
Contributions to Chart.js are welcome and encouraged, but please have a look through the guidelines in this document before raising an issue, or writing code for the project.
24

35
## Using issues

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Annotations work with line, bar, scatter and bubble charts that use linear, loga
1919

2020
[View this example on CodePen](https://codepen.io/compwright/full/mmQMrZ/)
2121

22-
23-
24-
2522
## To-do Items
2623

2724
The following features still need to be done:

package-lock.json

Lines changed: 388 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
"dev": "karma start --auto-watch --no-single-run --browsers chrome",
2222
"docs": "npm run build && vuepress build docs --dest dist/docs",
2323
"docs:dev": "npm run build && vuepress dev docs",
24-
"lint": "eslint \"old_samples/**/*.html\" \"test/**/*.js\" \"src/**/*.js\"",
24+
"lint": "concurrently \"npm:lint-*\"",
25+
"lint-js": "eslint \"old_samples/**/*.html\" \"test/**/*.js\" \"src/**/*.js\"",
26+
"lint-md": "markdownlint-cli2 \"**/*.md\" \"**/*.mdx\" \"#**/node_modules\"",
27+
"lint-types": "eslint \"types/**/*.ts\" && tsc -p types/tests/",
2528
"test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
26-
"test-types": "tsc -p types/test/",
29+
"test-types": "tsc -p types/tests/",
2730
"test-lint": "npm run lint",
2831
"test-karma": "karma start --auto-watch --single-run"
2932
},
3033
"devDependencies": {
3134
"@rollup/plugin-node-resolve": "^11.2.0",
3235
"chart.js": "^3.0.0-rc.3",
36+
"@typescript-eslint/eslint-plugin": "^4.19.0",
37+
"@typescript-eslint/parser": "^4.19.0",
3338
"chartjs-plugin-autocolors": "0.0.3",
3439
"chartjs-test-utils": "^0.2.2",
3540
"concurrently": "^6.0.0",
@@ -45,6 +50,7 @@
4550
"karma-jasmine": "^4.0.1",
4651
"karma-jasmine-html-reporter": "^1.5.4",
4752
"karma-rollup-preprocessor": "^7.0.7",
53+
"markdownlint-cli2": "0.0.15",
4854
"pixelmatch": "^5.2.1",
4955
"rollup": "^2.42.3",
5056
"rollup-plugin-istanbul": "^3.0.0",

types/.eslintrc.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
parser: '@typescript-eslint/parser'
2+
3+
plugins:
4+
- '@typescript-eslint'
5+
6+
extends:
7+
- chartjs
8+
- plugin:@typescript-eslint/recommended
9+
10+
rules:
11+
# Replace stock eslint rules with typescript-eslint equivalents for proper
12+
# TypeScript support.
13+
no-use-before-define: "off"
14+
'@typescript-eslint/no-use-before-define': "error"
15+
no-shadow: "off"
16+
'@typescript-eslint/no-shadow': "error"
17+
18+
# These rules were set to warning to make the linting pass initially,
19+
# without making any major changes to types.
20+
object-curly-spacing: ["warn", "always"]
21+
'@typescript-eslint/no-empty-interface': "warn"
22+
'@typescript-eslint/ban-types': "warn"
23+
'@typescript-eslint/adjacent-overload-signatures': "warn"

types/element.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnnotationOptions } from "./options";
1+
import { AnnotationOptions } from './options';
22

33
export interface AnnotationElement {
44
x: number,

types/events.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Chart } from "chart.js";
2-
import { AnnotationElement } from "./element";
1+
import { Chart } from 'chart.js';
2+
import { AnnotationElement } from './element';
33

44
export interface EventContext {
55
chart: Chart,

types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { Plugin, ChartType } from 'chart.js';
22
import { AnnotationPluginOptions } from './options';
33

44
declare module 'chart.js' {
5-
interface PluginOptionsByType<TType extends ChartType> {
6-
annotation: AnnotationPluginOptions;
7-
}
5+
interface PluginOptionsByType<TType extends ChartType> {
6+
annotation: AnnotationPluginOptions;
7+
}
88
}
99

1010
declare const Annotation: Plugin;

types/label.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Color, FontSpec } from "chart.js";
2-
import { DrawTime } from "./options";
1+
import { Color, FontSpec } from 'chart.js';
2+
import { DrawTime } from './options';
33

44
export interface LabelOptions {
55
backgroundColor?: Color,
@@ -54,15 +54,15 @@ export interface LabelOptions {
5454
* Text to display in label. Provide an array to display multiple lines
5555
*/
5656
content: string | string[] | HTMLImageElement | null,
57-
57+
5858
/**
59-
* Overrides the width of the image. Could be set in pixel by a number,
59+
* Overrides the width of the image. Could be set in pixel by a number,
6060
* or in percentage of current width of image by a string
6161
*/
6262
width: number | string,
6363

6464
/**
65-
* Overrides the height of the image. Could be set in pixel by a number,
65+
* Overrides the height of the image. Could be set in pixel by a number,
6666
* or in percentage of current height of image by a string
6767
*/
6868
height: number | string,

0 commit comments

Comments
 (0)