How to use the eslint-plugin-react.rules function in eslint-plugin-react

To help you get started, we’ve selected a few eslint-plugin-react 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 DianaSuvorova / eslint-plugin-react-redux / lib / rules / no-unused-prop-types.js View on Github external
'use strict';

const filterReports = require('../filterReports');
const isReactReduxConnect = require('../isReactReduxConnect');

const noUnusedPropTypesReact = require('eslint-plugin-react').rules['no-unused-prop-types'];

const belongsToReduxReact = (node, objectName, destrArg) => {
  const checkProp = (secondArgument) => {
    const secondArgumentName = secondArgument && secondArgument.type === 'Identifier' && secondArgument.name;
    return (secondArgumentName === objectName // ownProps.myProp
      || destrArg === secondArgument // {myProp} in fn argument
      || (destrArg && destrArg.parent.type === 'VariableDeclarator' && destrArg.parent.init.name === secondArgumentName) // const {myProp} = ownProps;
    );
  };
  let isReactRedux = false;
  if (node.type === 'VariableDeclaration') {
    node.declarations.forEach((decl) => {
      const name = decl.id && decl.id.name;
      if (name === 'mapStateToProps' || name === 'mapDispatchToProps') {
        const secondArgument = decl.init.params && decl.init.params[1];
        if (checkProp(secondArgument)) {
github liferay / liferay-frontend-source-formatter / lib / lint_js.js View on Github external
var _ = require('lodash');
var eslint = require('eslint');
var glob = require('glob');
var path = require('path');

var SourceCodeFixer = require('eslint/lib/util/source-code-fixer');

var ruleUtils = require('./rule_utils');

var ESLINT_CONFIG = require('./config/eslint');

var customRules = {};

var reactRules = require('eslint-plugin-react').rules;

_.defaults(customRules, reactRules);

var loadPlugin = (pluginName, configPath) => {
	var rules;

	if (pluginName !== 'react') {
		if (pluginName.indexOf('eslint-plugin-') === -1) {
			pluginName = `eslint-plugin-${pluginName}`;
		}

		var baseName = pluginName.replace('eslint-plugin-', '');

		if (pluginName.indexOf('/') !== -1) {
			baseName = path.basename(baseName);

eslint-plugin-react

React specific linting rules for ESLint

MIT
Latest version published 24 days ago

Package Health Score

95 / 100
Full package analysis

Popular eslint-plugin-react functions