Skip to content

Commit

Permalink
docs(preset): add import statement example
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jul 20, 2019
1 parent 59a6250 commit 453acb0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/rule-preset.md
Expand Up @@ -81,6 +81,26 @@ module.exports = {
}
};
```

Of course, If you use [Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/)(with [`esModuleInterop` option](https://www.typescriptlang.org/docs/handbook/compiler-options.html)), you can just use `import` statement.
These transpiler wrap `require` function with interop helper function automatically.

```js
import RuleA from "textlint-rule-external-A";
// It will be transpiled to `const RuleA = __importDefault(require("textlint-rule-external-A"))`
import RuleB from "@scope/textlint-rule-extenal-B";
// It will be transpiled to `const RuleB = __importDefault(require("textlint-rule-external-B"))`
module.exports = {
rules: {
ruleA: RuleA,
ruleB: RuleB
},
rulesConfig: {
ruleA: true,
ruleB: true
}
};
```

## Publishing

Expand Down

0 comments on commit 453acb0

Please sign in to comment.