@putout/operator-match-files v9.0.1
@putout/operator-match-files 
πPutout operator adds ability to match files to plugins.
Install
npm i putout @putout/operator-match-filesAPI
If you want to create πPutout plugin that will match files according to your needs just:
const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');
module.exports = matchFiles({
'tsconfig.json': updateTSConfig,
});This will help in case when update-tsconfig is disabled by default:
const updateTSConfig = require('./update-tsconfig');
module.exports.rules = {
'update-tsconfig': ['off', updateTSConfig],
};And you want to help users avoid updating .putout.json config with:
{
"match": {
"tsconfig.json": {
"nextjs/update-tsconfig": "on"
}
},
"plugins": ["nextjs"]
}If you want to pass options use:
{
"match": {
"tsconfig.json": {
"nextjs/update-tsconfig": ["on", {
"ignore": []
}]
}
},
"plugins": ["nextjs"]
}Instead of this, redlint can be used, it will generate .filesystem.json which can be processed by πPutout.
Rename
If you want to save with other name use ->:
const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');
module.exports = matchFiles({
'tsconfig.json -> hello.json': updateTSConfig,
});Matcher
You can even use file matchers:
{
"rules": {
"filesystem/convert-json-to-js": ["on", {
"filename": "package.json"
}]
}
}Matchers: __filename = __name.__ext
module.exports = matchFiles({
'__name.json -> __name.js': updateTSConfig,
});exclude
If you want to exclude some files, use:
const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');
module.exports = matchFiles({
files: {
'__name.ts -> __name.js': updateTSConfig,
},
exclude: ['*.d.ts'],
});Options
You can also pass options:
module.exports = matchFiles({
'.eslintrc.json -> eslint.config.js': {
rules: {
'eslint/declare': {
type: 'esm',
},
},
plugins: [
['eslint/convert-rc-to-flat', rcToFlat],
['eslint/declare', declare],
],
},
});filename
You can pass default filename, so when no options provided it will be used.
const {operator} = require('putout');
const {matchFiles} = operator;
const updateTSConfig = require('../update-tsconfig');
module.exports = matchFiles({
filename: '*.d.ts',
files: {
'__name.ts -> __name.js': updateTSConfig,
},
});License
MIT
10 months ago
10 months ago
12 months ago
1 year ago
9 months ago
10 months ago
8 months ago
8 months ago
8 months ago
7 months ago
6 months ago
6 months ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago