standard-tsx 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +3 -0
- package/package.json +1 -1
- package/src/eslint.config.js +16 -6
package/HISTORY.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
## 0.0.5
|
|
2
|
+
* [Update .gitignore handling (#12)](https://github.com/extremeheat/standard-tsx/commit/29b2286623bf5145ec6c8b3d112136f9d0b7ccac) (thanks @extremeheat)
|
|
3
|
+
|
|
1
4
|
## 0.0.4
|
|
2
5
|
* [Fix tsconfig lookup (#9)](https://github.com/extremeheat/standard-tsx/commit/4f28fc3798d52a35d86126c29a7e5d3d341b1578) (thanks @extremeheat)
|
|
3
6
|
* [Fix .gitignore handling in eslint.config.js](https://github.com/extremeheat/standard-tsx/commit/a8d88a03742b02b7138d9b653026eb33a74ce829) (thanks @extremeheat)
|
package/package.json
CHANGED
package/src/eslint.config.js
CHANGED
|
@@ -14,8 +14,14 @@ const reactPlugin = require('eslint-plugin-react')
|
|
|
14
14
|
const reactHooksPlugin = require('eslint-plugin-react-hooks')
|
|
15
15
|
const glob = require('glob')
|
|
16
16
|
|
|
17
|
-
// Find all .gitignore files in the project
|
|
17
|
+
// Find all .gitignore files in the project (upto 2 levels up for monorepo support)
|
|
18
18
|
const gitignoreFiles = glob.sync('**/.gitignore', { cwd: process.cwd() })
|
|
19
|
+
if (gitignoreFiles.length === 0) {
|
|
20
|
+
gitignoreFiles.push(...glob.sync('**/.gitignore', { cwd: path.join(process.cwd(), '..') }).map(file => path.join('..', file)))
|
|
21
|
+
if (gitignoreFiles.length === 0) {
|
|
22
|
+
gitignoreFiles.push(...glob.sync('**/.gitignore', { cwd: path.join(process.cwd(), '../..') }).map(file => path.join('..', '..', file)))
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
|
|
20
26
|
// Sort by directory depth (root to leaves) to match Git's override behavior
|
|
21
27
|
const sortedGitignoreFiles = gitignoreFiles.sort((a, b) => {
|
|
@@ -31,11 +37,15 @@ for (const file of sortedGitignoreFiles) {
|
|
|
31
37
|
const content = fs.readFileSync(file, 'utf8')
|
|
32
38
|
const lines = content.split('\n').map(line => line.trim()).filter(line => line && !line.startsWith('#'))
|
|
33
39
|
for (const line of lines) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
let rule = path.join(dir, line).replaceAll('\\', '/')
|
|
41
|
+
if (rule.startsWith('..//')) continue // a rule intended for a parent directory
|
|
42
|
+
// rules that don't start with slash apply to all directories
|
|
43
|
+
rule = rule.replaceAll('../', '')
|
|
44
|
+
// mimic .gitignore behavior as ESlint is a bit different and doesn't recursively apply rules
|
|
45
|
+
if (!rule.startsWith('/') || !rule.startsWith('./') || !rule.startsWith('*')) rule = '**/' + rule
|
|
46
|
+
// Restore ordering of ! to front after above transformation
|
|
47
|
+
if (line.startsWith('!')) rule = '!' + rule.replaceAll('!', '')
|
|
48
|
+
ignorePatterns.push(rule)
|
|
39
49
|
}
|
|
40
50
|
}
|
|
41
51
|
|