9.0.2 β€’ Published 5 months ago

@putout/operator-declare v9.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@putout/operator-declare NPM version

🐊Putout operator adds ability to declare variables that has references with no definitions. Most likely you prefer using Declarator plugin type based on current Operator.

Install

npm i putout @putout/operator-declare

API

If you want to create 🐊Putout plugin that will declare variables according to your needs just:

const {operator} = require('putout');
const {declare} = operator;

module.exports = declare({
    fs: `import fs from 'fs/promises'`,
});

Dual packages

When you need different declarations for ESM and CommonJS you can use:

const {operator} = require('putout');
const {declare} = operator;

module.exports = declare({
    fs: {
        esm: `import fs from 'fs/promises'`,
        comomnjs: `const fs = require('fs')`, // drop when not needed
    },
});

Configuration

Plugin supports options, so you can pass it in .putout.json:

{
    "rules": {
        "putout/declare": ["on", {
            "declarations": {
                "fs": "import fs from 'fs/promises'"
            }
        }]
    }
}

If for some reason you don't need some kind of declaration, add dismiss field and it will be ignored:

{
    "rules": {
        "putout/declare": ["on", {
            "declarations": {
                "fs": "import fs from 'fs/promises'"
            },
            "dismiss": ["fs"]
        }]
    }
}

Used in

Evaluate

Can be used with ESLint's putout/evaluate:

{
    "rules": {
        "putout/declare": ["on", {
            "declarations": {
                "superMethod": "import superMethod from '__putout_evaluate: join(`./`, basename(__filename), `.js`)'"
            }
        }]
    }
}

If you have a file index.spec.js:

+ import superMethod from './index.js'
superMethod();

License

MIT

9.0.2

5 months ago

9.0.1

5 months ago

9.0.0

5 months ago

6.1.0

10 months ago

6.0.1

10 months ago

6.0.0

10 months ago

7.0.0

9 months ago

7.0.4

9 months ago

7.0.3

9 months ago

7.0.2

9 months ago

7.1.0

9 months ago

7.0.1

9 months ago

8.0.1

8 months ago

8.0.0

8 months ago

8.0.2

8 months ago

5.0.3

11 months ago

5.0.2

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

4.6.5

1 year ago

4.6.3

2 years ago

4.6.2

2 years ago

4.6.4

2 years ago

4.6.1

2 years ago

4.6.0

2 years ago

4.5.1

2 years ago

4.5.0

2 years ago

4.4.0

2 years ago

4.1.0

2 years ago

4.3.0

2 years ago

4.2.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.5.0

2 years ago

2.4.0

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

2.0.2

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago