How to use the eslint/lib/rules/no-unused-vars.create function in eslint

To help you get started, we’ve selected a few eslint 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 bryanrsmith / eslint-plugin-no-unused-vars-rest / src / rules / no-unused-vars.js View on Github external
// ESLint freezes context, so can't monkey patch directly
			proxyContext = Object.create(context);
			proxyContext.report = function report(...args) {
				const node = args.length === 1 ? args[0].node : args[0];

				if (isDestructuredVarWithRestProperty(node)) {
					// ignore reports for nodes passing the test
					return;
				}

				context.report(...args);
			};
		}

		// create the core rule with the patched context
		return noUnusedVars.create(proxyContext);
	},
};
github liferay / liferay-frontend-source-formatter / lib / lint_js_rules / no_unused_vars.js View on Github external
lintRules['Program:exit'] = node => {
				noUnused(mockContext)['Program:exit'](node);

				collectedReport.forEach(
					(item, index) => {
						var declaration = item.node;
						var name = declaration.name;

						var namespacedVar = STUB_RE.test(name);

						var namespacedFn = false;

						if (namespacedVar) {
							var parentType = declaration.parent.type;

							if (parentType === 'FunctionDeclaration' ||
								(parentType === 'VariableDeclarator' && declaration.parent.init && declaration.parent.init.type === 'FunctionExpression')
							) {
github typescript-eslint / typescript-eslint / packages / eslint-plugin / src / rules / no-unused-vars.ts View on Github external
create(context) {
    const rules = baseRule.create(context);

    /**
     * Mark heritage clause as used
     * @param node The node currently being traversed
     */
    function markHeritageAsUsed(node: TSESTree.Expression): void {
      switch (node.type) {
        case AST_NODE_TYPES.Identifier:
          context.markVariableAsUsed(node.name);
          break;
        case AST_NODE_TYPES.MemberExpression:
          markHeritageAsUsed(node.object);
          break;
        case AST_NODE_TYPES.CallExpression:
          markHeritageAsUsed(node.callee);
          break;