How to use the regexpp.RegExpParser function in regexpp

To help you get started, we’ve selected a few regexpp 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 makuga01 / dnsFookup / FE / node_modules / eslint / lib / rules / no-regex-spaces.js View on Github external
*/

"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const astUtils = require("./utils/ast-utils");
const regexpp = require("regexpp");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

const regExpParser = new regexpp.RegExpParser();
const DOUBLE_SPACE = / {2}/u;

/**
 * Check if node is a string
 * @param {ASTNode} node node to evaluate
 * @returns {boolean} True if its a string
 * @private
 */
function isString(node) {
    return node && node.type === "Literal" && typeof node.value === "string";
}

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
github eslint / eslint / lib / rules / prefer-named-capture-group.js View on Github external
// Requirements
//------------------------------------------------------------------------------

const {
    CALL,
    CONSTRUCT,
    ReferenceTracker,
    getStringIfConstant
} = require("eslint-utils");
const regexpp = require("regexpp");

//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------

const parser = new regexpp.RegExpParser();

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------

module.exports = {
    meta: {
        type: "suggestion",

        docs: {
            description: "enforce using named capture group in regular expression",
            category: "Best Practices",
            recommended: false,
            url: "https://eslint.org/docs/rules/prefer-named-capture-group"
        },
github graalvm / graaljs / tools / node_modules / eslint / lib / rules / no-misleading-character-class.js View on Github external
create(context) {
        const parser = new RegExpParser();

        /**
         * Verify a given regular expression.
         * @param {Node} node The node to report.
         * @param {string} pattern The regular expression pattern to verify.
         * @param {string} flags The flags of the regular expression.
         * @returns {void}
         */
        function verify(node, pattern, flags) {
            const patternNode = parser.parsePattern(
                pattern,
                0,
                pattern.length,
                flags.includes("u")
            );
            const has = {
github sikidamjanovic / cowrite / node_modules / @typescript-eslint / eslint-plugin / dist / rules / prefer-string-starts-ends-with.js View on Github external
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const eslint_utils_1 = require("eslint-utils");
const regexpp_1 = require("regexpp");
const util_1 = require("../util");
const EQ_OPERATORS = /^[=!]=/;
const regexpp = new regexpp_1.RegExpParser();
exports.default = util_1.createRule({
    name: 'prefer-string-starts-ends-with',
    defaultOptions: [],
    meta: {
        type: 'suggestion',
        docs: {
            description: 'Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings',
            category: 'Best Practices',
            recommended: 'error',
            requiresTypeChecking: true,
        },
        messages: {
            preferStartsWith: "Use 'String#startsWith' method instead.",
            preferEndsWith: "Use the 'String#endsWith' method instead.",
        },
        schema: [],
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / prefer-string-starts-ends-with.ts View on Github external
import { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';
import {
  isNotClosingParenToken,
  getPropertyName,
  getStaticValue,
} from 'eslint-utils';
import { RegExpParser, AST as RegExpAST } from 'regexpp';
import { createRule, getParserServices, getTypeName } from '../util';

const EQ_OPERATORS = /^[=!]=/;
const regexpp = new RegExpParser();

export default createRule({
  name: 'prefer-string-starts-ends-with',
  defaultOptions: [],

  meta: {
    type: 'suggestion',
    docs: {
      description:
        'Enforce the use of `String#startsWith` and `String#endsWith` instead of other equivalent methods of checking substrings',
      category: 'Best Practices',
      recommended: 'error',
      requiresTypeChecking: true,
    },
    messages: {
      preferStartsWith: "Use 'String#startsWith' method instead.",
github eslint / eslint / lib / rules / no-misleading-character-class.js View on Github external
create(context) {
        const parser = new RegExpParser();

        /**
         * Verify a given regular expression.
         * @param {Node} node The node to report.
         * @param {string} pattern The regular expression pattern to verify.
         * @param {string} flags The flags of the regular expression.
         * @returns {void}
         */
        function verify(node, pattern, flags) {
            const has = {
                surrogatePairWithoutUFlag: false,
                combiningClass: false,
                variationSelector: false,
                emojiModifier: false,
                regionalIndicatorSymbol: false,
                zwj: false

regexpp

Regular expression parser for ECMAScript.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis