New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(types): move type definition for rule to @textlint/types #562

Merged
merged 17 commits into from Dec 30, 2018

Conversation

Projects
None yet
1 participant
@azu
Copy link
Member

azu commented Dec 29, 2018

This is big refactoring for typing.
But, This PR will not break backword-compatibility.

Move types

Move following types to @textlint/types from @textlint/kernel.
Also, @textlint/kernel export these types for back-compatible reason.

  • TextlintResult
  • TextlintFixResult
  • TextlintMessageFixCommand
  • TextlintMessage
  • TextlintRuleReporter,
  • TextlintRuleModule
  • TextlintRuleOptions
  • TextlintRuleSeverityLevel,
  • TextlintFilterRuleReporter,
  • TextlintFilterRuleOptions,
  • TextlintPluginCreator
  • TextlintPluginOptions
  • TextlintPluginProcessor
  • TextlintPluginProcessorConstructor

Move files

Move following codes to @textlint/types from @textlint/kernel.
Also, @textlint/types export it.

  • TextlintSourceCode
  • TextlintSourceCodeArgs
  • TextlintSourceCodeRange
  • TextlintSourceCodeLocation

Add types

@textlint/types and @textlint/kernel export these new types.

  • TextlintRuleSeverityLevel
  • TextlintMessageFixCommand
  • AnyTxtNode
    • @textlint/ast-node-types

Realted refactoring

  • @textlint/linter-formatter: use @textlint/types instead of @textlint/kernel
  • @textlint/fixer-formatter: use @textlint/types instead of @textlint/kernel

fix #561

/**
* Any TxtNode types
*/
export type AnyTxtNode = TxtNode | TxtTextNode | TxtParentNode;

This comment has been minimized.

@azu

azu Dec 29, 2018

Member

AnyTxtNode is new type.
It is conventinal type.

ruleId: filterRuleDescriptor.id,
severityLevel: getSeverity(filterRuleDescriptor.normalizedOptions),

This comment has been minimized.

@azu

azu Dec 29, 2018

Member

TextlintFilterRuleContext(aka. RuleContext) receive only severityLevel.
Currently, rule option is not needed.

Show resolved Hide resolved packages/@textlint/linter-formatter/test/formatters/checkstyle.js Outdated
* `RuleReporterFixCommand` is intermediate object between Rule report and Kernel.
* `IntermediateFixCommand` has also `isAbsolute` flag value.
*/
export interface TextlintRuleContextFixCommand {

This comment has been minimized.

@azu

azu Dec 29, 2018

Member

We need to note about the difference of TextlintRuleContextFixCommand and TextlintCommand.

@azu

This comment has been minimized.

Copy link
Member

azu commented Dec 29, 2018

I want to add TextlintFilterRuleReporterHandler that define rule event handler.
This naming come from Proxy API. It is similar syntax.

@azu azu force-pushed the @textlint/types branch from 8e5da21 to ef96a80 Dec 30, 2018

@@ -85,8 +69,8 @@ export default class RuleContext implements BaseRuleContext {
return this._ruleId;
}

get severity() {
return this._severity;
get severityLevel() {

This comment has been minimized.

@azu

azu Dec 30, 2018

Member

It should be severity

@azu azu merged commit 3b2ed27 into master Dec 30, 2018

5 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@azu azu deleted the @textlint/types branch Dec 30, 2018

@azu azu referenced this pull request Jan 1, 2019

Merged

Release @textlint/types@1.1.0 #565

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment