Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Metadata for each rule #1311

Merged
merged 9 commits into from
Jun 16, 2016
Merged

Metadata for each rule #1311

merged 9 commits into from
Jun 16, 2016

Conversation

jkillian
Copy link
Contributor

@jkillian jkillian commented Jun 13, 2016

Pushing up my work on metadata for rules. This metadata is currently used to generate large parts of http://palantir.github.io/tslint/.

Metadata contains:

  • A short description of the rule
  • A more detailed description of the rule
  • A rationale behind the rule
  • A JSON Schema for the options for the rule
  • Examples of sensible rule option configurations
  • The category of the rule

This PR:

  • Adds metadata for each rule
  • Adds a gulp docs command that runs a script which reads the metadata from each rule and outputs file into the Jekyll docs site
  • Removes docs/sample.tslint.json because it's redundant documentation and also to make room for the docs build script.

TODO:

  • Switch to JSON Schema instead of own schema format for rule options

@jkillian jkillian changed the title Initial rule metadata typings and two examples Metadata for each rule Jun 14, 2016
@alexeagle
Copy link
Contributor

cc @ScottSWu

@adidahiya adidahiya self-assigned this Jun 15, 2016
@adidahiya adidahiya added this to the TSLint v3.x milestone Jun 15, 2016
rationale?: string;
}

export type RuleType = "functionality" | "maintainability" | "style" | "typescript";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we use string literal union types anywhere else, and this might break things for 1.7 consumers. I feel okay with that at this point because 1.8 has been out for awhile, but we could use a different tool instead of string literal union types if we need to

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this seems fine

@jkillian
Copy link
Contributor Author

Ready for review!

for (const key of Object.keys(metadata)) {
yamlData[key] = (<any> metadata)[key];
}
yamlData.optionsJSON = JSON.stringify(metadata.options, undefined, " ");
Copy link
Contributor

@adidahiya adidahiya Jun 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: the last arg could be the number literal 2; I think that's slightly more standard (?)

(here and above, L65)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, much easier than guessing how many spaces are in a string

@@ -99,6 +111,12 @@ module.exports = function (grunt) {
"mochaTest",
"run:testRules",
].concat(checkBinTest));
grunt.registerTask("docs", [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be run as part of the CI build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it can run when a tag is created for a non-dev release. People will still be able to do this manually though if they update other parts of the docs site that aren't generated via this task.

Can we automatically push to our repo from CircleCI?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be run as part of our verification step on every commit -- we want to make sure the docs TS code doesn't get broken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand what you're getting at: we want to make sure that docs.ts builds and passes the linter. However, we don't want the part of the task to run that actually updates the docs site, because the docs site would advertise unreleased TSLint rules and options.

For simplicity for now, I'll adjust things so that the build part of the current docs task is run on every build, including CircleCI builds. The actual updating of the files in the tslint-gh-pages, that is, the execution of buildDocs.js, will still have to be done manually for the time being

@adidahiya
Copy link
Contributor

mostly minor comments; 👎 for not running the new task as part of CI build

Jason Killian added 2 commits June 16, 2016 13:24
@adidahiya
Copy link
Contributor

lgtm 👍

@jkillian
Copy link
Contributor Author

Sweet, let's merge this

@jkillian jkillian merged commit 8184ad6 into master Jun 16, 2016
@adidahiya adidahiya deleted the master-rule-metadata branch June 16, 2016 18:47
ScottSWu pushed a commit to ScottSWu/tslint that referenced this pull request Jun 16, 2016
* Adds metadata for each rule
* Adds a gulp docs command that runs a script which reads the metadata from each rule and outputs file into the Jekyll docs site
* Removes docs/sample.tslint.json because it's redundant documentation and also to make room for the docs build script.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants