Comparing version 11.8.3 to 11.9.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [11.9.0](https://github.com/textlint/textlint/compare/textlint@11.8.3...textlint@11.9.0) (2021-03-21) | ||
### Features | ||
* **textlint:** Add .textlintignore support ([#748](https://github.com/textlint/textlint/issues/748)) ([637e9a5](https://github.com/textlint/textlint/commit/637e9a5ccc5cc82a40cc9f36636d78273bc74b90)) | ||
<a name="11.8.3"></a> | ||
@@ -8,0 +19,0 @@ ## [11.8.3](https://github.com/textlint/textlint/compare/textlint@11.8.2...textlint@11.8.3) (2021-03-19) |
@@ -34,2 +34,3 @@ export interface ConfigStatics { | ||
cwd?: string; | ||
ignoreFile?: string | undefined; | ||
} | ||
@@ -60,2 +61,3 @@ export declare class Config { | ||
cacheLocation: string; | ||
ignoreFile: string | undefined; | ||
/** | ||
@@ -62,0 +64,0 @@ * @return {string} rc config filename |
@@ -77,3 +77,5 @@ // LICENSE : MIT | ||
// --cache-location: cache file path | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache") | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache"), | ||
// --ignore-path: ".textlintignore" file path | ||
ignoreFile: path.resolve(process.cwd(), ".textlintignore") | ||
}); | ||
@@ -172,2 +174,6 @@ // Priority: CLI > Code options > config file | ||
this._assertCacheLocation(this.cacheLocation); | ||
/** | ||
* @type {string} | ||
*/ | ||
this.ignoreFile = options.ignoreFile !== undefined ? options.ignoreFile : defaultOptions.ignoreFile; | ||
} | ||
@@ -217,2 +223,7 @@ Object.defineProperty(Config, "CONFIG_FILE_NAME", { | ||
options.rulesBaseDirectory = cliOptions.rulesBaseDirectory || defaultOptions.rulesBaseDirectory; | ||
// --ignore-path="path/to/file" | ||
options.ignoreFile = | ||
cliOptions.ignorePath !== undefined | ||
? path.resolve(process.cwd(), cliOptions.ignorePath) | ||
: defaultOptions.ignoreFile; | ||
return this.initWithAutoLoading(options); | ||
@@ -219,0 +230,0 @@ }; |
@@ -206,3 +206,3 @@ // LICENSE : MIT | ||
}); | ||
var targetFiles = find_util_1.findFiles(patterns); | ||
var targetFiles = find_util_1.findFiles(patterns, { ignoreFilePath: this.config.ignoreFile }); | ||
// Maybe, unAvailableFilePath should be warning. | ||
@@ -209,0 +209,0 @@ // But, The user can use glob pattern like `src/**/*` as arguments. |
@@ -35,2 +35,9 @@ // LICENSE : MIT | ||
{ | ||
option: "ignore-path", | ||
type: "path::String", | ||
description: "Specify path to a file containing patterns that describes files to ignore.", | ||
default: ".textlintignore", | ||
example: "--ignore-path /path/to/.textlintignore" | ||
}, | ||
{ | ||
option: "init", | ||
@@ -37,0 +44,0 @@ type: "Boolean", |
@@ -39,3 +39,3 @@ "use strict"; | ||
}); | ||
var targetFiles = find_util_1.findFiles(patterns); | ||
var targetFiles = find_util_1.findFiles(patterns, { ignoreFilePath: options.config.ignoreFile }); | ||
var concurrency = options.concurrency !== undefined ? options.concurrency : os_1.default.cpus().length; | ||
@@ -42,0 +42,0 @@ var chunkSize = Math.min(MAX_CHUNK_SIZE, Math.ceil(targetFiles.length / concurrency)); |
@@ -0,1 +1,5 @@ | ||
export declare type FindFilesOptions = { | ||
cwd?: string; | ||
ignoreFilePath?: string; | ||
}; | ||
/** | ||
@@ -13,8 +17,6 @@ * filter files by config | ||
* @param {string[]} patterns | ||
* @param {{cwd?: string }} options | ||
* @param {FindFilesOptions} options | ||
* @returns {string[]} file path list | ||
*/ | ||
export declare function findFiles(patterns: string[], options?: { | ||
cwd?: string; | ||
}): string[]; | ||
export declare function findFiles(patterns: string[], options?: FindFilesOptions): string[]; | ||
/** | ||
@@ -21,0 +23,0 @@ * @param {string[]} files |
@@ -9,2 +9,10 @@ // LICENSE : MIT | ||
var fs = require("fs"); | ||
var debug = require("debug")("textlint:find-util"); | ||
var DEFAULT_IGNORE_PATTERNS = Object.freeze(["**/.git/**", "**/node_modules/**"]); | ||
var mapGitIgnorePatternTo = function (base) { return function (ignore) { | ||
if (ignore.startsWith("!")) { | ||
return "!" + path.posix.join(base, ignore.slice(1)); | ||
} | ||
return path.posix.join(base, ignore); | ||
}; }; | ||
var isFile = function (filePath) { | ||
@@ -35,3 +43,3 @@ try { | ||
* @param {string[]} patterns | ||
* @param {{cwd?: string }} options | ||
* @param {FindFilesOptions} options | ||
* @returns {string[]} file path list | ||
@@ -42,2 +50,20 @@ */ | ||
var cwd = options.cwd || process.cwd(); | ||
var ignoredPatterns = []; | ||
ignoredPatterns.push.apply(ignoredPatterns, DEFAULT_IGNORE_PATTERNS); | ||
if (options.ignoreFilePath) { | ||
var baseDir = path.resolve(cwd, path.dirname(options.ignoreFilePath)); | ||
var normalizeIgnoreFilePath = path.resolve(cwd, options.ignoreFilePath); | ||
debug("findFiles ignore baseDir: %s, normalizeIgnoreFilePath: %s", baseDir, normalizeIgnoreFilePath); | ||
if (fs.existsSync(normalizeIgnoreFilePath)) { | ||
var ignored = fs | ||
.readFileSync(normalizeIgnoreFilePath, "utf-8") | ||
.split(/\r?\n/) | ||
.filter(function (line) { return !/^\s*$/.test(line) && !/^\s*#/.test(line); }) | ||
.map(mapGitIgnorePatternTo(baseDir)); | ||
debug("ignored: %o", ignored); | ||
ignoredPatterns.push.apply(ignoredPatterns, ignored); | ||
} | ||
} | ||
debug("search patterns: %o", patterns); | ||
debug("search ignore patterns: %o", ignoredPatterns); | ||
var files = []; | ||
@@ -56,3 +82,6 @@ var addFile = function (filePath) { | ||
glob.sync(pattern, { | ||
nodir: true | ||
cwd: cwd, | ||
absolute: true, | ||
nodir: true, | ||
ignore: ignoredPatterns | ||
}).forEach(function (filePath) { | ||
@@ -59,0 +88,0 @@ // workaround for windows |
@@ -34,2 +34,3 @@ export interface ConfigStatics { | ||
cwd?: string; | ||
ignoreFile?: string | undefined; | ||
} | ||
@@ -60,2 +61,3 @@ export declare class Config { | ||
cacheLocation: string; | ||
ignoreFile: string | undefined; | ||
/** | ||
@@ -62,0 +64,0 @@ * @return {string} rc config filename |
@@ -72,3 +72,5 @@ // LICENSE : MIT | ||
// --cache-location: cache file path | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache") | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache"), | ||
// --ignore-path: ".textlintignore" file path | ||
ignoreFile: path.resolve(process.cwd(), ".textlintignore") | ||
}); | ||
@@ -167,2 +169,6 @@ // Priority: CLI > Code options > config file | ||
this._assertCacheLocation(this.cacheLocation); | ||
/** | ||
* @type {string} | ||
*/ | ||
this.ignoreFile = options.ignoreFile !== undefined ? options.ignoreFile : defaultOptions.ignoreFile; | ||
} | ||
@@ -212,2 +218,7 @@ Object.defineProperty(Config, "CONFIG_FILE_NAME", { | ||
options.rulesBaseDirectory = cliOptions.rulesBaseDirectory || defaultOptions.rulesBaseDirectory; | ||
// --ignore-path="path/to/file" | ||
options.ignoreFile = | ||
cliOptions.ignorePath !== undefined | ||
? path.resolve(process.cwd(), cliOptions.ignorePath) | ||
: defaultOptions.ignoreFile; | ||
return this.initWithAutoLoading(options); | ||
@@ -214,0 +225,0 @@ }; |
@@ -204,3 +204,3 @@ // LICENSE : MIT | ||
}); | ||
var targetFiles = findFiles(patterns); | ||
var targetFiles = findFiles(patterns, { ignoreFilePath: this.config.ignoreFile }); | ||
// Maybe, unAvailableFilePath should be warning. | ||
@@ -207,0 +207,0 @@ // But, The user can use glob pattern like `src/**/*` as arguments. |
@@ -33,2 +33,9 @@ // LICENSE : MIT | ||
{ | ||
option: "ignore-path", | ||
type: "path::String", | ||
description: "Specify path to a file containing patterns that describes files to ignore.", | ||
default: ".textlintignore", | ||
example: "--ignore-path /path/to/.textlintignore" | ||
}, | ||
{ | ||
option: "init", | ||
@@ -35,0 +42,0 @@ type: "Boolean", |
@@ -33,3 +33,3 @@ import os from "os"; | ||
}); | ||
var targetFiles = findFiles(patterns); | ||
var targetFiles = findFiles(patterns, { ignoreFilePath: options.config.ignoreFile }); | ||
var concurrency = options.concurrency !== undefined ? options.concurrency : os.cpus().length; | ||
@@ -36,0 +36,0 @@ var chunkSize = Math.min(MAX_CHUNK_SIZE, Math.ceil(targetFiles.length / concurrency)); |
@@ -0,1 +1,5 @@ | ||
export declare type FindFilesOptions = { | ||
cwd?: string; | ||
ignoreFilePath?: string; | ||
}; | ||
/** | ||
@@ -13,8 +17,6 @@ * filter files by config | ||
* @param {string[]} patterns | ||
* @param {{cwd?: string }} options | ||
* @param {FindFilesOptions} options | ||
* @returns {string[]} file path list | ||
*/ | ||
export declare function findFiles(patterns: string[], options?: { | ||
cwd?: string; | ||
}): string[]; | ||
export declare function findFiles(patterns: string[], options?: FindFilesOptions): string[]; | ||
/** | ||
@@ -21,0 +23,0 @@ * @param {string[]} files |
@@ -7,2 +7,10 @@ // LICENSE : MIT | ||
var fs = require("fs"); | ||
var debug = require("debug")("textlint:find-util"); | ||
var DEFAULT_IGNORE_PATTERNS = Object.freeze(["**/.git/**", "**/node_modules/**"]); | ||
var mapGitIgnorePatternTo = function (base) { return function (ignore) { | ||
if (ignore.startsWith("!")) { | ||
return "!" + path.posix.join(base, ignore.slice(1)); | ||
} | ||
return path.posix.join(base, ignore); | ||
}; }; | ||
var isFile = function (filePath) { | ||
@@ -32,3 +40,3 @@ try { | ||
* @param {string[]} patterns | ||
* @param {{cwd?: string }} options | ||
* @param {FindFilesOptions} options | ||
* @returns {string[]} file path list | ||
@@ -39,2 +47,20 @@ */ | ||
var cwd = options.cwd || process.cwd(); | ||
var ignoredPatterns = []; | ||
ignoredPatterns.push.apply(ignoredPatterns, DEFAULT_IGNORE_PATTERNS); | ||
if (options.ignoreFilePath) { | ||
var baseDir = path.resolve(cwd, path.dirname(options.ignoreFilePath)); | ||
var normalizeIgnoreFilePath = path.resolve(cwd, options.ignoreFilePath); | ||
debug("findFiles ignore baseDir: %s, normalizeIgnoreFilePath: %s", baseDir, normalizeIgnoreFilePath); | ||
if (fs.existsSync(normalizeIgnoreFilePath)) { | ||
var ignored = fs | ||
.readFileSync(normalizeIgnoreFilePath, "utf-8") | ||
.split(/\r?\n/) | ||
.filter(function (line) { return !/^\s*$/.test(line) && !/^\s*#/.test(line); }) | ||
.map(mapGitIgnorePatternTo(baseDir)); | ||
debug("ignored: %o", ignored); | ||
ignoredPatterns.push.apply(ignoredPatterns, ignored); | ||
} | ||
} | ||
debug("search patterns: %o", patterns); | ||
debug("search ignore patterns: %o", ignoredPatterns); | ||
var files = []; | ||
@@ -53,3 +79,6 @@ var addFile = function (filePath) { | ||
glob.sync(pattern, { | ||
nodir: true | ||
cwd: cwd, | ||
absolute: true, | ||
nodir: true, | ||
ignore: ignoredPatterns | ||
}).forEach(function (filePath) { | ||
@@ -56,0 +85,0 @@ // workaround for windows |
{ | ||
"name": "textlint", | ||
"version": "11.8.3", | ||
"version": "11.9.0", | ||
"description": "The pluggable linting tool for text and markdown.", | ||
@@ -49,12 +49,12 @@ "keywords": [ | ||
"@textlint/ast-node-types": "^4.4.2", | ||
"@textlint/ast-traverse": "^2.3.3", | ||
"@textlint/feature-flag": "^3.3.3", | ||
"@textlint/fixer-formatter": "^3.3.3", | ||
"@textlint/kernel": "^3.4.3", | ||
"@textlint/linter-formatter": "^3.3.3", | ||
"@textlint/module-interop": "^1.2.3", | ||
"@textlint/textlint-plugin-markdown": "^5.3.3", | ||
"@textlint/textlint-plugin-text": "^4.3.3", | ||
"@textlint/types": "^1.5.3", | ||
"@textlint/utils": "^1.2.3", | ||
"@textlint/ast-traverse": "^2.3.4", | ||
"@textlint/feature-flag": "^3.3.4", | ||
"@textlint/fixer-formatter": "^3.3.4", | ||
"@textlint/kernel": "^3.4.4", | ||
"@textlint/linter-formatter": "^3.3.4", | ||
"@textlint/module-interop": "^1.2.4", | ||
"@textlint/textlint-plugin-markdown": "^5.3.4", | ||
"@textlint/textlint-plugin-text": "^4.3.4", | ||
"@textlint/types": "^1.5.4", | ||
"@textlint/utils": "^1.2.4", | ||
"debug": "^4.3.1", | ||
@@ -80,4 +80,4 @@ "deep-equal": "^1.1.1", | ||
"devDependencies": { | ||
"@types/mocha": "^8.2.1", | ||
"@types/node": "^14.14.34", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^14.14.35", | ||
"clone": "^2.1.2", | ||
@@ -107,3 +107,3 @@ "cpx": "^1.5.0", | ||
}, | ||
"gitHead": "5c40c1429736a0ed86bea07a39cb0eba31be11d4" | ||
"gitHead": "07c0497b387f09e41088b7f113555aa5e5451add" | ||
} |
@@ -81,3 +81,5 @@ // LICENSE : MIT | ||
// --cache-location: cache file path | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache") | ||
cacheLocation: path.resolve(process.cwd(), ".textlintcache"), | ||
// --ignore-path: ".textlintignore" file path | ||
ignoreFile: path.resolve(process.cwd(), ".textlintignore") | ||
}); | ||
@@ -135,2 +137,4 @@ | ||
cwd?: string; | ||
// ".textlintignore" file path | ||
ignoreFile?: string | undefined; | ||
} | ||
@@ -157,2 +161,3 @@ | ||
cacheLocation: string; | ||
ignoreFile: string | undefined; | ||
@@ -199,2 +204,7 @@ /** | ||
options.rulesBaseDirectory = cliOptions.rulesBaseDirectory || defaultOptions.rulesBaseDirectory; | ||
// --ignore-path="path/to/file" | ||
options.ignoreFile = | ||
cliOptions.ignorePath !== undefined | ||
? path.resolve(process.cwd(), cliOptions.ignorePath) | ||
: defaultOptions.ignoreFile; | ||
return this.initWithAutoLoading(options); | ||
@@ -417,2 +427,6 @@ } | ||
this._assertCacheLocation(this.cacheLocation); | ||
/** | ||
* @type {string} | ||
*/ | ||
this.ignoreFile = options.ignoreFile !== undefined ? options.ignoreFile : defaultOptions.ignoreFile; | ||
} | ||
@@ -419,0 +433,0 @@ |
@@ -233,3 +233,3 @@ // LICENSE : MIT | ||
}); | ||
const targetFiles = findFiles(patterns); | ||
const targetFiles = findFiles(patterns, { ignoreFilePath: this.config.ignoreFile }); | ||
// Maybe, unAvailableFilePath should be warning. | ||
@@ -236,0 +236,0 @@ // But, The user can use glob pattern like `src/**/*` as arguments. |
@@ -36,2 +36,9 @@ // LICENSE : MIT | ||
{ | ||
option: "ignore-path", | ||
type: "path::String", | ||
description: "Specify path to a file containing patterns that describes files to ignore.", | ||
default: ".textlintignore", | ||
example: "--ignore-path /path/to/.textlintignore" | ||
}, | ||
{ | ||
option: "init", | ||
@@ -38,0 +45,0 @@ type: "Boolean", |
@@ -47,3 +47,3 @@ import os from "os"; | ||
}); | ||
const targetFiles = findFiles(patterns); | ||
const targetFiles = findFiles(patterns, { ignoreFilePath: options.config.ignoreFile }); | ||
const concurrency = options.concurrency !== undefined ? options.concurrency : os.cpus().length; | ||
@@ -50,0 +50,0 @@ const chunkSize = Math.min(MAX_CHUNK_SIZE, Math.ceil(targetFiles.length / concurrency)); |
@@ -7,2 +7,14 @@ // LICENSE : MIT | ||
const fs = require("fs"); | ||
const debug = require("debug")("textlint:find-util"); | ||
const DEFAULT_IGNORE_PATTERNS = Object.freeze(["**/.git/**", "**/node_modules/**"]); | ||
export type FindFilesOptions = { | ||
cwd?: string; | ||
ignoreFilePath?: string; | ||
}; | ||
const mapGitIgnorePatternTo = (base: string) => (ignore: string) => { | ||
if (ignore.startsWith("!")) { | ||
return "!" + path.posix.join(base, ignore.slice(1)); | ||
} | ||
return path.posix.join(base, ignore); | ||
}; | ||
const isFile = (filePath: string) => { | ||
@@ -33,7 +45,25 @@ try { | ||
* @param {string[]} patterns | ||
* @param {{cwd?: string }} options | ||
* @param {FindFilesOptions} options | ||
* @returns {string[]} file path list | ||
*/ | ||
export function findFiles(patterns: string[], options: { cwd?: string } = {}): string[] { | ||
export function findFiles(patterns: string[], options: FindFilesOptions = {}): string[] { | ||
const cwd = options.cwd || process.cwd(); | ||
const ignoredPatterns: string[] = []; | ||
ignoredPatterns.push(...DEFAULT_IGNORE_PATTERNS); | ||
if (options.ignoreFilePath) { | ||
const baseDir = path.resolve(cwd, path.dirname(options.ignoreFilePath)); | ||
const normalizeIgnoreFilePath = path.resolve(cwd, options.ignoreFilePath); | ||
debug("findFiles ignore baseDir: %s, normalizeIgnoreFilePath: %s", baseDir, normalizeIgnoreFilePath); | ||
if (fs.existsSync(normalizeIgnoreFilePath)) { | ||
const ignored = fs | ||
.readFileSync(normalizeIgnoreFilePath, "utf-8") | ||
.split(/\r?\n/) | ||
.filter((line: string) => !/^\s*$/.test(line) && !/^\s*#/.test(line)) | ||
.map(mapGitIgnorePatternTo(baseDir)); | ||
debug("ignored: %o", ignored); | ||
ignoredPatterns.push(...ignored); | ||
} | ||
} | ||
debug("search patterns: %o", patterns); | ||
debug("search ignore patterns: %o", ignoredPatterns); | ||
const files: string[] = []; | ||
@@ -51,3 +81,6 @@ const addFile = (filePath: string) => { | ||
glob.sync(pattern, { | ||
nodir: true | ||
cwd, | ||
absolute: true, | ||
nodir: true, | ||
ignore: ignoredPatterns | ||
}).forEach((filePath: string) => { | ||
@@ -54,0 +87,0 @@ // workaround for windows |
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
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
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
597784
11159
+ Addedhas-proto@1.1.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedis-bigint@1.1.0(transitive)
+ Addedis-boolean-object@1.2.0(transitive)
+ Addedis-number-object@1.1.0(transitive)
+ Addedis-string@1.1.0(transitive)
+ Addedis-symbol@1.1.0(transitive)
+ Addedwhich-boxed-primitive@1.1.0(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedis-bigint@1.0.4(transitive)
- Removedis-boolean-object@1.1.2(transitive)
- Removedis-number-object@1.0.7(transitive)
- Removedis-string@1.0.7(transitive)
- Removedis-symbol@1.0.4(transitive)
- Removedwhich-boxed-primitive@1.0.2(transitive)
Updated@textlint/kernel@^3.4.4
Updated@textlint/types@^1.5.4
Updated@textlint/utils@^1.2.4