@putout/operator-match-files 2.1.0 → 2.2.0

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/README.md CHANGED
@@ -48,6 +48,21 @@ And you want to help users avoid updating `.putout.json` config with:
48
48
  }
49
49
  ```
50
50
 
51
+ If you want to pass options use:
52
+
53
+ ```json
54
+ {
55
+ "match": {
56
+ "tsconfig.json": {
57
+ "nextjs/update-tsconfig": ["on", {
58
+ "ignore": []
59
+ }]
60
+ }
61
+ },
62
+ "plugins": ["nextjs"]
63
+ }
64
+ ```
65
+
51
66
  Instead of this, [`redlint`](https://github.com/putoutjs/redlint) can be used, it will generate `.filesystem.json` which can be processed by 🐊**Putout**.
52
67
 
53
68
  ## License
@@ -3,6 +3,7 @@
3
3
  const {parse, print} = require('@putout/engine-parser');
4
4
  const {transform} = require('putout/transform');
5
5
  const {findPlaces} = require('putout/find-places');
6
+ const ignores = require('putout/ignores');
6
7
 
7
8
  const {toJS, fromJS} = require('@putout/operator-json');
8
9
 
@@ -10,6 +11,7 @@ const {
10
11
  readFileContent,
11
12
  findFile,
12
13
  writeFileContent,
14
+ getFilename,
13
15
  } = require('@putout/operator-filesystem');
14
16
 
15
17
  const isObject = (a) => a && typeof a === 'object';
@@ -37,13 +39,19 @@ function fix(path, {filename, matchedJS, matchedAST, plugins}) {
37
39
  writeFileContent(path, matchedJSON);
38
40
  }
39
41
 
40
- const createScan = (files) => (path, {push, progress}) => {
42
+ const createScan = (files) => (path, {push, progress, options}) => {
41
43
  const allFiles = [];
44
+ const cwd = getFilename(path);
42
45
 
43
46
  for (const [filename, plugin] of entries(files)) {
44
47
  const files = findFile(path, filename);
45
48
 
46
49
  for (const file of files) {
50
+ const filename = getFilename(file);
51
+
52
+ if (ignores(cwd, filename, options))
53
+ continue;
54
+
47
55
  allFiles.push({
48
56
  plugin,
49
57
  file,
@@ -98,6 +106,14 @@ function magicParse(name, content) {
98
106
  return [js, ast];
99
107
  }
100
108
 
109
+ if (/\.(c|m)?ts(x)?$/.test(name)) {
110
+ const ast = parse(content, {
111
+ isTS: true,
112
+ });
113
+
114
+ return [content, ast];
115
+ }
116
+
101
117
  return [content, parse(content)];
102
118
  }
103
119
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/operator-match-files",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout operator adds ability to match files to plugins",