@textlint/kernel
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -6,2 +6,14 @@ # Change Log | ||
<a name="2.0.4"></a> | ||
## [2.0.4](https://github.com/textlint/textlint/compare/@textlint/kernel@2.0.3...@textlint/kernel@2.0.4) (2018-01-12) | ||
### Bug Fixes | ||
* **kernel:** fix return type of `SourceCode#getSource` ([1b55894](https://github.com/textlint/textlint/commit/1b55894)) | ||
* **kernel:** pass the file path to preProcess() that is on FixerProcessor ([#458](https://github.com/textlint/textlint/issues/458)) ([5b947aa](https://github.com/textlint/textlint/commit/5b947aa)) | ||
<a name="2.0.2"></a> | ||
@@ -8,0 +20,0 @@ ## [2.0.2](https://github.com/textlint/textlint/compare/@textlint/kernel@2.0.1...@textlint/kernel@2.0.2) (2017-12-25) |
@@ -69,5 +69,5 @@ import SourceCode from "./source-code"; | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource: (node: TxtNode, beforeCount?: number | undefined, afterCount?: number | undefined) => string | null; | ||
getSource: (node?: TxtNode | undefined, beforeCount?: number | undefined, afterCount?: number | undefined) => string; | ||
/** | ||
@@ -74,0 +74,0 @@ * get config base directory path |
@@ -32,3 +32,3 @@ // LICENSE : MIT | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
@@ -35,0 +35,0 @@ this.getSource = function (node, beforeCount, afterCount) { |
@@ -88,5 +88,5 @@ import { BaseRuleContext } from "./BaseRuleContext"; | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource: (node: TxtNode, beforeCount?: number | undefined, afterCount?: number | undefined) => string | null; | ||
getSource: (node?: TxtNode | undefined, beforeCount?: number | undefined, afterCount?: number | undefined) => string; | ||
/** | ||
@@ -93,0 +93,0 @@ * get config base directory path |
@@ -42,3 +42,3 @@ // LICENSE : MIT | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
@@ -45,0 +45,0 @@ this.getSource = function (node, beforeCount, afterCount) { |
@@ -16,2 +16,8 @@ import { TxtNode } from "@textlint/ast-node-types"; | ||
export declare type SourceCodeRange = [number, number]; | ||
export declare type SourceCodeArgs = { | ||
text: string; | ||
ast: TxtNode; | ||
ext: string; | ||
filePath?: string; | ||
}; | ||
/** | ||
@@ -33,8 +39,3 @@ * This class represent of source code. | ||
*/ | ||
constructor({text, ast, ext, filePath}: { | ||
text: string; | ||
ast: TxtNode; | ||
ext: string; | ||
filePath?: string; | ||
}); | ||
constructor({text, ast, ext, filePath}: SourceCodeArgs); | ||
/** | ||
@@ -54,5 +55,5 @@ * @returns {ASTNodeTypes} | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource(node: TxtNode, beforeCount?: number, afterCount?: number): string | null; | ||
getSource(node?: TxtNode, beforeCount?: number, afterCount?: number): string; | ||
/** | ||
@@ -59,0 +60,0 @@ * @param {SourceCodeLocation} loc - location indicator. |
@@ -67,9 +67,6 @@ "use strict"; | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
SourceCode.prototype.getSource = function (node, beforeCount, afterCount) { | ||
var currentText = this.text; | ||
if (currentText == null) { | ||
return null; | ||
} | ||
if (node) { | ||
@@ -76,0 +73,0 @@ var start = Math.max(node.range[0] - (beforeCount || 0), 0); |
@@ -54,3 +54,3 @@ // LICENSE : MIT | ||
text: sourceText, | ||
ast: preProcess(sourceText), | ||
ast: preProcess(sourceText, sourceCode.filePath), | ||
filePath: resultFilePath, | ||
@@ -57,0 +57,0 @@ ext: sourceCode.ext |
@@ -13,3 +13,3 @@ { | ||
"name": "@textlint/kernel", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "textlint kernel is core logic by pure JavaScript.", | ||
@@ -41,3 +41,3 @@ "main": "lib/kernel/src/index.js", | ||
"cross-env": "^5.0.5", | ||
"markdown-to-ast": "^6.0.1", | ||
"markdown-to-ast": "^6.0.3", | ||
"mocha": "^4.0.1", | ||
@@ -47,9 +47,10 @@ "npm-run-all": "^4.1.1", | ||
"shelljs": "^0.7.7", | ||
"textlint-plugin-markdown": "^4.0.4", | ||
"textlint-plugin-markdown": "^4.0.5", | ||
"ts-node": "^3.3.0", | ||
"typescript": "~2.6.1" | ||
"typescript": "~2.6.1", | ||
"unist-util-select": "^1.5.0" | ||
}, | ||
"dependencies": { | ||
"@textlint/ast-node-types": "^4.0.0", | ||
"@textlint/feature-flag": "^3.0.1", | ||
"@textlint/feature-flag": "^3.0.3", | ||
"@types/bluebird": "^3.5.18", | ||
@@ -61,4 +62,4 @@ "bluebird": "^3.5.1", | ||
"structured-source": "^3.0.2", | ||
"txt-ast-traverse": "^2.0.1" | ||
"txt-ast-traverse": "^2.0.3" | ||
} | ||
} |
@@ -106,5 +106,5 @@ // LICENSE : MIT | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource = (node: TxtNode, beforeCount?: number, afterCount?: number) => { | ||
getSource = (node?: TxtNode, beforeCount?: number, afterCount?: number): string => { | ||
return this._sourceCode.getSource(node, beforeCount, afterCount); | ||
@@ -111,0 +111,0 @@ }; |
@@ -141,5 +141,5 @@ // LICENSE : MIT | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource = (node: TxtNode, beforeCount?: number, afterCount?: number) => { | ||
getSource = (node?: TxtNode, beforeCount?: number, afterCount?: number): string => { | ||
return this._sourceCode.getSource(node, beforeCount, afterCount); | ||
@@ -146,0 +146,0 @@ }; |
@@ -39,2 +39,3 @@ import { TxtNode } from "@textlint/ast-node-types"; | ||
export type SourceCodeRange = [number, number]; | ||
export type SourceCodeArgs = { text: string; ast: TxtNode; ext: string; filePath?: string }; | ||
/** | ||
@@ -58,3 +59,3 @@ * This class represent of source code. | ||
*/ | ||
constructor({ text = "", ast, ext, filePath }: { text: string; ast: TxtNode; ext: string; filePath?: string }) { | ||
constructor({ text = "", ast, ext, filePath }: SourceCodeArgs) { | ||
validate(ast); | ||
@@ -97,9 +98,6 @@ assert(ext || filePath, "should be set either of fileExt or filePath."); | ||
* @param {int=} afterCount The number of characters after the node to retrieve. | ||
* @returns {string|null} The text representing the AST node. | ||
* @returns {string} The text representing the AST node. | ||
*/ | ||
getSource(node: TxtNode, beforeCount?: number, afterCount?: number) { | ||
getSource(node?: TxtNode, beforeCount?: number, afterCount?: number): string { | ||
const currentText = this.text; | ||
if (currentText == null) { | ||
return null; | ||
} | ||
if (node) { | ||
@@ -106,0 +104,0 @@ const start = Math.max(node.range[0] - (beforeCount || 0), 0); |
@@ -79,3 +79,3 @@ // LICENSE : MIT | ||
text: sourceText, | ||
ast: preProcess(sourceText), | ||
ast: preProcess(sourceText, sourceCode.filePath), | ||
filePath: resultFilePath, | ||
@@ -82,0 +82,0 @@ ext: sourceCode.ext |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
272513
13
5957
Updatedtxt-ast-traverse@^2.0.3