-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25c1051
commit 9ed6129
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @fileoverview eslint ignore files automatically(cjs projects). | ||
* @author 唯然<[email protected]> | ||
*/ | ||
const process = require("process"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
/** | ||
* @param {object} [opts] | ||
* @param {string} [opts.cwd] | ||
* @param {string} [opts.filename] | ||
* @param {string[]?} [opts.extraIgnores] | ||
* @returns {{ignores: string[]}} the list of ignored files | ||
*/ | ||
module.exports.ignores = function ignores(opts = {}) { | ||
const ignoreFile = path.join( | ||
opts.cwd || process.cwd(), | ||
opts.filename || ".gitignore" | ||
); | ||
const text = fs.readFileSync(ignoreFile, "utf-8"); | ||
const lines = text | ||
.split(/(\r\n|\n)+/) | ||
.map((line) => line.trim()) | ||
.filter((line) => line && !line.startsWith("#")); | ||
|
||
return { | ||
ignores: [...lines, ...(opts.extraIgnores || [])], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* @fileoverview eslint ignore files automatically. | ||
* @fileoverview eslint ignore files automatically(esm projects). | ||
* @author 唯然<[email protected]> | ||
*/ | ||
import process from "process"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,13 @@ | |
"author": "唯然<[email protected]", | ||
"type": "module", | ||
"main": "./lib/index.js", | ||
"exports": "./lib/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./lib/index.js", | ||
"import": "./lib/index.js", | ||
"typings": "./lib/index.d.ts" | ||
} | ||
}, | ||
"typings": "./lib/index.d.ts", | ||
"files": [ | ||
"LICENSE", | ||
|