...
 
Commits (9)
# html-validate changelog
# [2.2.0](https://gitlab.com/html-validate/html-validate/compare/v2.1.0...v2.2.0) (2019-11-23)
### Bug Fixes
- **config:** throw ConfigError when elements cannot be loaded ([62c08e7](https://gitlab.com/html-validate/html-validate/commit/62c08e7c8bf9deaa47f8b9f1afbf48dcc69bba32))
- **docs:** update plugin docs ([340d0ca](https://gitlab.com/html-validate/html-validate/commit/340d0ca23875331b4267a7fd0226532904ed8fda))
- **plugin:** make all fields optional ([a587239](https://gitlab.com/html-validate/html-validate/commit/a5872397a9a0732a4cea1901c65e024767809d4a))
### Features
- **plugin:** allow specifying name ([6554f72](https://gitlab.com/html-validate/html-validate/commit/6554f72fb11e2da59ab07774f0898b20654e2a5b))
# [2.1.0](https://gitlab.com/html-validate/html-validate/compare/v2.0.1...v2.1.0) (2019-11-21)
### Bug Fixes
......
......@@ -12,9 +12,16 @@ export interface Plugin {
/**
* Name of the plugin.
*
* Read-only property set by config.
* If specified this is the name used when referring to the plugin. Default is
* to use the name/path the user used when loading the plugin. To be less
* confusing for users you should use the same name as your package.
*
* The name must be a valid package name according to NPM (basically lowercase
* characters, must not begin with dot, slash or non-url safe characters).
*
* Hint: import and use the name from `package.json`.
*/
name: string;
name?: string;
/**
* Initialization callback.
......@@ -43,12 +50,12 @@ export interface Plugin {
*
* "extends": ["my-plugin:foobar"]
*/
configs: { [key: string]: ConfigData };
configs?: { [key: string]: ConfigData };
/**
* List of new rules present.
*/
rules: { [key: string]: RuleConstructor };
rules?: { [key: string]: RuleConstructor };
/**
* Transformer available in this plugin.
......@@ -72,7 +79,7 @@ export interface Plugin {
* "^.*\\.foo$": "my-plugin:foobar"
* }
*/
transformer: Transformer | Record<string, Transformer>;
transformer?: Transformer | Record<string, Transformer>;
/**
* Extend metadata validation schema.
......
{
"name": "html-validate",
"version": "2.1.0",
"version": "2.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -3500,9 +3500,9 @@
}
},
"@semantic-release/changelog": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-3.0.5.tgz",
"integrity": "sha512-/U44eK5qL2olevbEi+GrJxq1lNGUABChqK58A3SkiDsZS6AoGO8CJHQ7OG0zx+spxwkY4TevZ85Whz/hYyO+5w==",
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-3.0.6.tgz",
"integrity": "sha512-9TqPL/VarLLj6WkUqbIqFiY3nwPmLuKFHy9fe/LamAW5s4MEW/ig9zW9vzYGOUVtWdErGJ1J62E3Edkamh3xaQ==",
"dev": true,
"requires": {
"@semantic-release/error": "^2.1.0",
......@@ -4177,9 +4177,9 @@
}
},
"@semantic-release/release-notes-generator": {
"version": "7.3.3",
"resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-7.3.3.tgz",
"integrity": "sha512-uF7f9+epsxGNE39i0Ssu56V4w/xd3L4/yWw7FeAFp+SNLXPWTkTErdF2wwkVpxpRpCdgXsoj6T01tMN8tPfciQ==",
"version": "7.3.4",
"resolved": "https://registry.npmjs.org/@semantic-release/release-notes-generator/-/release-notes-generator-7.3.4.tgz",
"integrity": "sha512-d5YlpzuWrsq1UrFeOgv6vIb11R0ICRRJwNzSM4NpljF8hZBYxaaNOw3FbfSufgOLiyvLznhh3/91QoRVPKVwqw==",
"dev": true,
"requires": {
"conventional-changelog-angular": "^5.0.0",
......@@ -4314,9 +4314,9 @@
}
},
"resolve": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
"integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.2.tgz",
"integrity": "sha512-cAVTI2VLHWYsGOirfeYVVQ7ZDejtQ9fp4YhYckWDEkFfqbVjaT11iM8k6xSAfGFMM+gDpZjMnFssPu8we+mqFw==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
......@@ -4563,13 +4563,12 @@
}
},
"@types/vfile-message": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/vfile-message/-/vfile-message-1.0.1.tgz",
"integrity": "sha512-mlGER3Aqmq7bqR1tTTIVHq8KSAFFRyGbrxuM8C/H82g6k7r2fS+IMEkIu3D7JHzG10NvPdR8DNx0jr0pwpp4dA==",
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/vfile-message/-/vfile-message-2.0.0.tgz",
"integrity": "sha512-GpTIuDpb9u4zIO165fUy9+fXcULdD8HFRNli04GehoMVbeNq7D6OBnqSmg3lxZnC+UvgUhEWKxdKiwYUkGltIw==",
"dev": true,
"requires": {
"@types/node": "*",
"@types/unist": "*"
"vfile-message": "*"
}
},
"@types/yargs": {
......@@ -6509,14 +6508,6 @@
"dev": true,
"requires": {
"lodash": "^4.17.14"
},
"dependencies": {
"lodash": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
"integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
"dev": true
}
}
},
"ccount": {
......@@ -8550,9 +8541,9 @@
}
},
"dgeni-packages": {
"version": "0.28.1",
"resolved": "https://registry.npmjs.org/dgeni-packages/-/dgeni-packages-0.28.1.tgz",
"integrity": "sha512-w44ZYsHsyZiwutRNBpK03EOeQCCap+ulrhgjKk845JjcacnOW3rf9JHE7B1FFPOh+YsIQmcgx8ldLaIwcR9ZaA==",
"version": "0.28.2",
"resolved": "https://registry.npmjs.org/dgeni-packages/-/dgeni-packages-0.28.2.tgz",
"integrity": "sha512-W8GsMjILSPOfbjxyXgUD/T20isQ0ojw4HChrN6NwXIQtFJioNPRX4WeIOAZxw0S77S4vbXh4wfOs9wof5sIh+Q==",
"dev": true,
"requires": {
"canonical-path": "^1.0.0",
......@@ -8584,12 +8575,6 @@
"resolved": "https://registry.npmjs.org/espree/-/espree-2.2.5.tgz",
"integrity": "sha1-32kbkxCIlAKuspzAZnCMVmkLhUs=",
"dev": true
},
"lodash": {
"version": "4.17.14",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
"integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
"dev": true
}
}
},
......@@ -11642,9 +11627,9 @@
}
},
"hast-util-from-parse5": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-5.0.1.tgz",
"integrity": "sha512-UfPzdl6fbxGAxqGYNThRUhRlDYY7sXu6XU9nQeX4fFZtV+IHbyEJtd+DUuwOqNV4z3K05E/1rIkoVr/JHmeWWA==",
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-5.0.2.tgz",
"integrity": "sha512-YXFjoRS7ES7PEoLx6uihtSfKTO1s3z/tzGiV5cVpsUiihduogFXubNRCzTIW3yOOGO1nws9CxPq4MbwD39Uo+w==",
"dev": true,
"requires": {
"ccount": "^1.0.3",
......@@ -11661,15 +11646,15 @@
"dev": true
},
"hast-util-parse-selector": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.2.tgz",
"integrity": "sha512-jIMtnzrLTjzqgVEQqPEmwEZV+ea4zHRFTP8Z2Utw0I5HuBOXHzUPPQWr6ouJdJqDKLbFU/OEiYwZ79LalZkmmw==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.3.tgz",
"integrity": "sha512-nxbeqjQNxsvo/uYYAw9kij6td05YVUlf1qti09rVfbWSLT5H6wo3c+USIwX6nzXWk5kFZzXnEqO82856r0aM2Q==",
"dev": true
},
"hast-util-to-html": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-6.0.1.tgz",
"integrity": "sha512-9LjLAsO2gPO9H6N0VxZsK4sqNZY1A0lMNDfdpMseryV18Hri2++guFfPmjY58PzmtBlBvDflqktxjSm2I1o1yg==",
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-6.0.2.tgz",
"integrity": "sha512-oiQzGHtjT6ZLhszCY89kCxGCo9O+YuPUHluv36fzp7Hv/E1W4428PgzcQAKlPUzbHAt3ELoPCSrYLWl8fQw7Ag==",
"dev": true,
"requires": {
"ccount": "^1.0.0",
......@@ -11677,7 +11662,7 @@
"hast-util-is-element": "^1.0.0",
"hast-util-whitespace": "^1.0.0",
"html-void-elements": "^1.0.0",
"property-information": "^5.0.0",
"property-information": "^5.2.0",
"space-separated-tokens": "^1.0.0",
"stringify-entities": "^2.0.0",
"unist-util-is": "^3.0.0",
......@@ -11691,14 +11676,14 @@
"dev": true
},
"hastscript": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-5.1.0.tgz",
"integrity": "sha512-7mOQX5VfVs/gmrOGlN8/EDfp1GqV6P3gTNVt+KnX4gbYhpASTM8bklFdFQCbFRAadURXAmw0R1QQdBdqp7jswQ==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-5.1.1.tgz",
"integrity": "sha512-xHo1Hkcqd0LlWNuDL3/BxwhgAGp3d7uEvCMgCTrBY+zsOooPPH+8KAvW8PCgl+GB8H3H44nfSaF0A4BQ+4xlYg==",
"dev": true,
"requires": {
"comma-separated-tokens": "^1.0.0",
"hast-util-parse-selector": "^2.2.0",
"property-information": "^5.0.1",
"hast-util-parse-selector": "^2.0.0",
"property-information": "^5.0.0",
"space-separated-tokens": "^1.0.0"
}
},
......@@ -20320,9 +20305,9 @@
},
"dependencies": {
"chokidar": {
"version": "2.1.6",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz",
"integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==",
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz",
"integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==",
"dev": true,
"optional": true,
"requires": {
......@@ -23121,9 +23106,9 @@
}
},
"property-information": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-5.1.0.tgz",
"integrity": "sha512-tODH6R3+SwTkAQckSp2S9xyYX8dEKYkeXw+4TmJzTxnNzd6mQPu1OD4f9zPrvw/Rm4wpPgI+Zp63mNSGNzUgHg==",
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-5.3.0.tgz",
"integrity": "sha512-IslotQn1hBCZDY7SaJ3zmCjVea219VTwmOk6Pu3z9haU9m4+T8GwaDubur+6NMHEU+Fjs/6/p66z6QULPkcL1w==",
"dev": true,
"requires": {
"xtend": "^4.0.1"
......@@ -23717,32 +23702,32 @@
}
},
"rehype-parse": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-6.0.1.tgz",
"integrity": "sha512-FrGSbOzcGxIvWty1qHjKTvHT4WBTt7C6JLs65EkvFPa7ZKraSmsoDDj6al1eBxaXS1t/kiGdPYazUe58Mgflgw==",
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/rehype-parse/-/rehype-parse-6.0.2.tgz",
"integrity": "sha512-0S3CpvpTAgGmnz8kiCyFLGuW5yA4OQhyNTm/nwPopZ7+PI11WnGl1TTWTGv/2hPEe/g2jRLlhVVSsoDH8waRug==",
"dev": true,
"requires": {
"hast-util-from-parse5": "^5.0.0",
"parse5": "^5.0.0",
"xtend": "^4.0.1"
"xtend": "^4.0.0"
},
"dependencies": {
"parse5": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz",
"integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==",
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz",
"integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==",
"dev": true
}
}
},
"rehype-stringify": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-6.0.0.tgz",
"integrity": "sha512-grV/hhA7z9GbUJZk0ILzprSE0YY9lvTmYuvgRjXdFXrrag5gNeqXBQIuG1m4zFW6PFm0YYnJ/qgf5y6yui4VsA==",
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-6.0.1.tgz",
"integrity": "sha512-JfEPRDD4DiG7jet4md7sY07v6ACeb2x+9HWQtRPm2iA6/ic31hCv1SNBUtpolJASxQ/D8gicXiviW4TJKEMPKQ==",
"dev": true,
"requires": {
"hast-util-to-html": "^6.0.0",
"xtend": "^4.0.1"
"xtend": "^4.0.0"
}
},
"remove-trailing-separator": {
......@@ -25919,9 +25904,9 @@
"dev": true
},
"ts-jest": {
"version": "24.1.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.1.0.tgz",
"integrity": "sha512-HEGfrIEAZKfu1pkaxB9au17b1d9b56YZSqz5eCVE8mX68+5reOvlM93xGOzzCREIov9mdH7JBG+s0UyNAqr0tQ==",
"version": "24.2.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.2.0.tgz",
"integrity": "sha512-Yc+HLyldlIC9iIK8xEN7tV960Or56N49MDP7hubCZUeI7EbIOTsas6rXCMB4kQjLACJ7eDOF4xWEO5qumpKsag==",
"dev": true,
"requires": {
"bs-logger": "0.x",
......@@ -26231,10 +26216,13 @@
"dev": true
},
"unist-util-stringify-position": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz",
"integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==",
"dev": true
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.2.tgz",
"integrity": "sha512-nK5n8OGhZ7ZgUwoUbL8uiVRwAbZyzBsB/Ddrlbu6jwwubFza4oe15KlyEaLNMXQW1svOQq4xesUeqA85YrIUQA==",
"dev": true,
"requires": {
"@types/unist": "^2.0.2"
}
},
"universal-user-agent": {
"version": "4.0.0",
......@@ -26310,9 +26298,9 @@
}
},
"upath": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz",
"integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz",
"integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==",
"dev": true,
"optional": true
},
......@@ -26511,20 +26499,36 @@
},
"dependencies": {
"is-buffer": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==",
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==",
"dev": true
},
"unist-util-stringify-position": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz",
"integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==",
"dev": true
},
"vfile-message": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz",
"integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==",
"dev": true,
"requires": {
"unist-util-stringify-position": "^1.1.1"
}
}
}
},
"vfile-message": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz",
"integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.2.tgz",
"integrity": "sha512-gNV2Y2fDvDOOqq8bEe7cF3DXU6QgV4uA9zMR2P8tix11l1r7zju3zry3wZ8sx+BEfuO6WQ7z2QzfWTvqHQiwsA==",
"dev": true,
"requires": {
"unist-util-stringify-position": "^1.1.1"
"@types/unist": "^2.0.0",
"unist-util-stringify-position": "^2.0.0"
}
},
"vm-browserify": {
......
......@@ -4,11 +4,12 @@ import { Source } from "../context";
import { UserError } from "../error/user-error";
import { Transformer, TRANSFORMER_API } from "../transform";
import { Config } from "./config";
import { ConfigError } from "./error";
import { Severity } from "./severity";
let mockElements: any;
jest.mock("mock-elements", () => mockElements, { virtual: true });
jest.mock("mock-plugin", () => ({ name: "mock plugin" }), { virtual: true });
jest.mock("mock-plugin", () => ({}), { virtual: true });
/* a mocked file which throws an exception when loaded */
jest.mock(
......@@ -316,6 +317,16 @@ describe("config", () => {
const metatable = config.getMetaTable();
expect(Object.keys(metatable.elements)).not.toHaveLength(0);
});
it("should throw ConfigError when module doesn't exist", () => {
const config = Config.fromObject({
elements: ["missing-module"],
});
expect(() => config.getMetaTable()).toThrow(ConfigError);
expect(() => config.getMetaTable()).toThrow(
/Failed to load elements from "missing-module": .*/
);
});
});
describe("transformSource()", () => {
......
......@@ -231,8 +231,15 @@ export class Config {
}
/* assume it is loadable with require() */
// eslint-disable-next-line security/detect-non-literal-require
metaTable.loadFromObject(require(entry));
try {
// eslint-disable-next-line security/detect-non-literal-require
metaTable.loadFromObject(require(entry));
} catch (err) {
throw new ConfigError(
`Failed to load elements from "${entry}": ${err.message}`,
err
);
}
}
metaTable.init();
......@@ -300,7 +307,7 @@ export class Config {
"<rootDir>",
this.rootDir
)) as Plugin;
plugin.name = moduleName;
plugin.name = plugin.name || moduleName;
return plugin;
});
}
......
......@@ -27,6 +27,56 @@ describe("Plugin", () => {
mockPlugin = require("mock-plugin");
});
describe("name", () => {
it("should use plugin name if set", () => {
expect.assertions(1);
mockPlugin.name = "my-plugin";
mockPlugin.configs = {
foo: {
rules: {
"my-rule": "error",
},
},
};
config = Config.fromObject({
extends: ["my-plugin:foo"],
plugins: ["mock-plugin"],
});
expect(config.get()).toEqual({
extends: ["my-plugin:foo"],
plugins: ["mock-plugin"],
rules: {
"my-rule": "error",
},
transform: {},
});
});
it("should default to package name", () => {
expect.assertions(1);
mockPlugin.name = null;
mockPlugin.configs = {
foo: {
rules: {
"my-rule": "error",
},
},
};
config = Config.fromObject({
extends: ["mock-plugin:foo"],
plugins: ["mock-plugin"],
});
expect(config.get()).toEqual({
extends: ["mock-plugin:foo"],
plugins: ["mock-plugin"],
rules: {
"my-rule": "error",
},
transform: {},
});
});
});
describe("configs", () => {
it("should add extendable predefined configurations", () => {
mockPlugin.configs = {
......
......@@ -13,9 +13,16 @@ export interface Plugin {
/**
* Name of the plugin.
*
* Read-only property set by config.
* If specified this is the name used when referring to the plugin. Default is
* to use the name/path the user used when loading the plugin. To be less
* confusing for users you should use the same name as your package.
*
* The name must be a valid package name according to NPM (basically lowercase
* characters, must not begin with dot, slash or non-url safe characters).
*
* Hint: import and use the name from `package.json`.
*/
name: string;
name?: string;
/**
* Initialization callback.
......@@ -44,12 +51,12 @@ export interface Plugin {
*
* "extends": ["my-plugin:foobar"]
*/
configs: { [key: string]: ConfigData };
configs?: Record<string, ConfigData>;
/**
* List of new rules present.
*/
rules: { [key: string]: RuleConstructor };
rules?: Record<string, RuleConstructor>;
/**
* Transformer available in this plugin.
......