diff --git a/README.md b/README.md index 20292c0e56a..64ad94193e1 100644 --- a/README.md +++ b/README.md @@ -216,26 +216,21 @@ tslint accepts the following command-line options: #### Library ```js -import { Linter } from "tslint"; +import { Linter, Configuration } from "tslint"; import * as fs from "fs"; -const fileName = "Specify file name"; -const configuration = { - rules: { - "variable-name": true, - "quotemark": [true, "double"] - } -}; +const fileName = "Specify input file name"; +const configurationFilename = "Specify configuration file name"; const options = { formatter: "json", - configuration: configuration, rulesDirectory: "customRules/", formattersDirectory: "customFormatters/" }; const fileContents = fs.readFileSync(fileName, "utf8"); -const linter = new Linter(fileName, fileContents, options); -const result = linter.lint(); +const linter = new Linter(options); +const configLoad = Configuration.findConfiguration(configurationFilename, filename); +const result = linter.lint(fileName, fileContents, configLoad.results); ``` #### Type Checking @@ -315,10 +310,10 @@ TSLint ships with a set of core rules that can be configured. However, users are Let us take the example of how to write a new rule to forbid all import statements (you know, *for science*). Let us name the rule file `noImportsRule.ts`. Rules are referenced in `tslint.json` with their kebab-cased identifer, so `"no-imports": true` would configure the rule. -__Important conventions__: +__Important conventions__: * Rule identifiers are always kebab-cased. * Rule files are always camel-cased (`camelCasedRule.ts`). -* Rule files *must* contain the suffix `Rule`. +* Rule files *must* contain the suffix `Rule`. * The exported class must always be named `Rule` and extend from `Lint.Rules.AbstractRule`. Now, let us first write the rule in TypeScript: