@putout/operator-declare
putout operator adds ability to declare referenced variables that wan not defined
Last updated 3 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @putout/operator-declare 
SYNC missed versions from official npm registry.

@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"]
        }]
    }
}

If you want to override type to avoid detecting, set it to esm|commonjs:

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

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

Current Tags

  • 9.1.0                                ...           latest (6 months ago)

49 Versions

  • 9.1.0                                ...           6 months ago
  • 9.0.2                                ...           a year ago
  • 9.0.1                                ...           a year ago
  • 9.0.0                                ...           a year ago
  • 8.0.2                                ...           a year ago
  • 8.0.1                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 7.1.0                                ...           a year ago
  • 7.0.4                                ...           a year ago
  • 7.0.3                                ...           a year ago
  • 7.0.2                                ...           a year ago
  • 7.0.1                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.0.3                                ...           a year ago
  • 5.0.2                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.6.5                                ...           2 years ago
  • 4.6.4                                ...           2 years ago
  • 4.6.3                                ...           2 years ago
  • 4.6.2                                ...           2 years ago
  • 4.6.1                                ...           2 years ago
  • 4.6.0                                ...           3 years ago
  • 4.5.1                                ...           3 years ago
  • 4.5.0                                ...           3 years ago
  • 4.4.0                                ...           3 years ago
  • 4.3.0                                ...           3 years ago
  • 4.2.0                                ...           3 years ago
  • 4.1.0                                ...           3 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.2.0                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.5.0                                ...           3 years ago
  • 2.4.0                                ...           3 years ago
  • 2.3.0                                ...           3 years ago
  • 2.2.0                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 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
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (11)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE