Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@putout/plugin-filesystem
Advanced tools
Readme
๐Putout plugin helps to lint filesystem.
npm i @putout/plugin-filesystem -D
{
"rules": {
"filesystem/remove-vim-swap-file": "on",
"filesystem/bundle": "off",
"filesystem/read-all-files": ["off", {
"mask": "*"
}],
"filesystem/write-all-files": "off",
"filesystem/rename-file": "off",
"filesystem/remove-files": "off",
"filesystem/rename-spec-to-test": "off",
"filesystem/rename-test-to-spec": "off",
"filesystem/rename-referenced-file": "off",
"filesystem/move-referenced-file": "off",
"filesystem/convert-simple-filesystem-to-filesystem": "off",
"filesystem/replace-cwd": ["off", {
"from": "/home/coderaiser/putout",
"to": "/"
}],
"filesystem/convert-json-to-js": ["off", {
"filename": "package.json"
}],
"filesystem/convert-js-to-json": ["off", {
"filename": "package.js"
}]
}
}
Checkout in ๐Putout Editor.
Update .putout.json
to enable rule:
{
"rules": {
"filesystem/rename-file": ["on", {
"from": "README.md",
"to": "readme.md"
}]
}
}
It will make next modifications to filesystem:
-README.md
+readme.md
For more sophisticated example, use mask
:
{
"rules": {
"filesystem/rename-file": ["on", {
"mask": "*.test.*",
"from": "test",
"to": "spec"
}]
}
}
It will rename 'test' to 'spec' in *.test.*
files:
-index.test.js
+index.spec.js
Checkout in ๐Putout Editor.
-readme.md.swap
Update .putout.json
to enable rule:
{
"rules": {
"filesystem/remove-files": ["on", {
"names": ["coverage"]
}]
}
}
It will make next modifications to filesystem:
/
|-- test/
| `-- hello.spec.js
-|-- coverage/
`-- lib/
`-- hello.js
Checkout in ๐Putout Editor.
-index.spec.js
+index.test.js
Checkout in ๐Putout Editor.
-index.test.js
+index.spec.js
Update .putout.json
to enable rule:
{
"rules": {
"filesystem/rename-referenced-file": ["on", {
"from": "hello.js",
"to": "world.js"
}]
}
}
Checkout in ๐Putout Editor.
Before:
// hello.spec.js
import hello from './hello.js';
// hello.js
export const hello = 'world';
After:
-hello.js
+world.js
// hello.spec.js
import hello from './world.js';
// world.js
export const hello = 'world';
Update .putout.json
to enable rule:
{
"rules": {
"filesystem/move-referenced-file": ["on", {
"name": "hello.js",
"directory": "lib"
}]
}
}
Checkout in ๐Putout Editor.
Before:
/
|-- test/
| `-- hello.spec.js
|-- src/
| `-- hello.js
`-- lib/
// test/hello.spec.js
import hello from '../src/hello.js';
// src/hello.js
export const hello = 'world';
After:
/
|-- test/
| `-- hello.spec.js
|-- src/
`-- lib/
`-- hello.js
-src/hello.js
+lib/hello.js
// test/hello.spec.js
import hello from '../lib/hello.js';
// lib/hello.js
export const hello = 'world';
Checkout in ๐Putout Editor.
__putout_processor_filesystem([
'/',
'/hello.txt',
[
'/world.txt',
'hello world',
],
'/abc/',
]);
__putout_processor_filesystem({
type: 'directory',
filename: '/',
files: [{
type: 'file',
filename: '/hello.txt',
}, {
type: 'file',
filename: '/world.txt',
content: 'hello world',
}, {
type: 'directory',
filename: '/abc',
files: [],
}],
});
Checkout in ๐Putout Editor.
__putout_processor_filesystem({
type: 'directory',
filename: '/',
files: [{
type: 'file',
filename: '/hello.txt',
}, {
type: 'file',
filename: '/world.txt',
content: 'hello world',
}, {
type: 'directory',
filename: '/abc',
files: [],
}],
});
__putout_processor_filesystem([
'/',
'/hello.txt',
[
'/world.txt',
'hello world',
],
'/abc/',
]);
Bundle and minify css
files.
{
"rules": {
"filesystem/bundle": ["on", {
"groups": [
["__:columns/__", [
"name-size-date.css",
"name-size.css"
]],
["main.css", [
"hello.css",
"world.css"
]],
"1:1"
]
}]
}
}
Checkout in ๐Putout Editor.
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- main.css
Just minify styles:
{
"rules": {
"filesystem/bundle": ["on", {
"groups": ["1:1"]
}]
}
}
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- hello.css
| `-- world.css
Create subdirectory:
{
"rules": {
"filesystem/bundle": ["on", {
"groups": [
["__:columns/__", [
"name-size-date.css",
"name-size.css"
]]
]
}]
}
}
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- columns
| `-- hello.css
| `-- world.css
Filter css files by mask:
{
"rules": {
"filesystem/bundle": ["on", {
"mask": "*.good.css",
"groups": ["1:1"]
}]
}
}
Before:
/
|-- css/
| `-- hello.css
| `-- world.good.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- world.good.css
You can even override transform
with your own config
:
putout(filesystem, {
rules: {
'filesystem/bundle': ['on', {
transform: (source: string | string[], config) => string,
}],
},
});
Concreate files:
{
"rules": {
"filesystem/bundle": ["on", {
"groups": ["hello.css"]
}]
}
}
Before:
/
|-- css/
| `-- hello.css
| `-- world.css
After:
/
|-- css/
| `-- hello.css
| `-- world.css
|-- dist/
| `-- hello.css
Checkout in ๐Putout Editor.
When from=/home/coderaiser/putout
and to=/
:
{
"rules": {
"filesystem/replace-cwd": ["on", {
"from": "/home/coderaiser/putout",
"to": "/"
}]
}
}
__putout_processor_filesystem(['/home/coderaiser/putout/', '/home/coderaiser/putout/README.md']);
__putout_processor_filesystem(['/', '/README.md']);
Checkout in ๐Putout Editor.
["/", "/hello.xyz"]
["/", [
"/hello.xyz",
"hello world"
]]
Write all files that was read before to Filesystem.
Checkout in ๐Putout Editor.
["/", [
"/hello.xyz",
"hello world"
]]
Checkout in ๐Putout Editor.
Filesystem:
-["/", "/package.json"]
+["/", "/package.js"]
{
"plugins": []
}
export default {
plugins: [],
};
Checkout in ๐Putout Editor:
Filesystem:
-["/", "/package.js"]
+["/", "/package.json"]
{
"plugins": []
}
export default {
plugins: [],
};
MIT
FAQs
๐Putout plugin operates with filesystem
The npm package @putout/plugin-filesystem receives a total of 1,936 weekly downloads. As such, @putout/plugin-filesystem popularity was classified as popular.
We found that @putout/plugin-filesystem demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.