How to use @textlint/feature-flag - 4 common examples

To help you get started, we’ve selected a few @textlint/feature-flag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github textlint / textlint / packages / textlint / bin / textlint.js View on Github external
#!/usr/bin/env node
"use strict";
const getStdin = require("get-stdin");
const logSymbols = require("log-symbols");
const useStdIn = process.argv.indexOf("--stdin") > -1;
const isDebug = process.argv.indexOf("--debug") > -1;
if (isDebug) {
    const debug = require("debug");
    debug.enable("textlint*");
}
// must do this initialization *before* other requires in order to work
const cli = require("../lib/textlint/src/cli").cli;
const { coreFlags } = require("@textlint/feature-flag");
// it is for --experimental logger
// update state
coreFlags.runningCLI = !module.parent;

/**
 * show error message for user
 * @param {Error} error
 */
function showError(error) {
    console.error(logSymbols.error, "Error");
    console.error(`${error.message}\n`);
    console.error(logSymbols.error, "Stack trace");
    console.error(error.stack);
}

// Always start as promise
Promise.resolve()
    .then(function() {
        if (useStdIn) {
github textlint / textlint / packages / @textlint / kernel / src / core / source-location.ts View on Github external
if (typeof padding === "number") {
            _backwardCompatibleIndexValue = padding;
            throwIfTesting(`${errorPrefix} This is un-document way:
report(node, new RuleError("message", index);

Please use { index }: 

report(node, new RuleError("message", {
    index: paddingLineColumn
});
`);
        }
        // when running from textlint-tester, assert
        if (padding.line === undefined && padding.column !== undefined) {
            // FIXME: Backward compatible <= textlint.5.5
            throwIfTesting(`${errorPrefix} Have to use a sets with "line" and "column".
See FAQ: https://github.com/textlint/textlint/blob/master/docs/faq/line-column-or-index.md            

report(node, new RuleError("message", {
    line: paddingLineNumber,
    column: paddingLineColumn
});

OR use "index" property insteadof only "column".

report(node, new RuleError("message", {
    index: paddingLineColumn
});
`);
        }

        // When either one of {column, line} or {index} is not used, throw error
github textlint / textlint / packages / textlint-tester / src / textlint-tester.ts View on Github external
constructor() {
        if (typeof coreFlags === "object") {
            coreFlags.runningTester = true;
        }
    }
github textlint / textlint / packages / textlint / src / textlint-core.ts View on Github external
addProcessor(Processor: TextlintPluginProcessorConstructor) {
        throwIfTesting(
            "Use setupPlugins insteadof addProcessor method.`addProcessor` will be removed in the future." +
                "For more details, See https://github.com/textlint/textlint/issues/293"
        );
        this.textlintKernelDescriptor = this.textlintKernelDescriptor.shallowMerge({
            plugins: [
                {
                    pluginId: "`${Processor.name}@deprecated`",
                    plugin: { Processor }
                }
            ].concat(this.defaultPlugins)
        });
    }

@textlint/feature-flag

textlint internal feature flag manager.

MIT
Latest version published 21 days ago

Package Health Score

89 / 100
Full package analysis