How to use the eslint-config-prettier.rules function in eslint-config-prettier

To help you get started, we’ve selected a few eslint-config-prettier 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 AlloyTeam / eslint-config-alloy / scripts / removePrettierRules.ts View on Github external
/* eslint-disable @typescript-eslint/no-require-imports */
/**
 * 批量删除 eslint-config-prettier 中的规则
 */
import fs from 'fs';
import path from 'path';
import rimraf from 'rimraf';

const prettier = require('eslint-config-prettier');
const prettierReact = require('eslint-config-prettier/react');
const prettierVue = require('eslint-config-prettier/vue');
const prettierTypeScript = require('eslint-config-prettier/@typescript-eslint');

const prettierRules = {
    index: prettier.rules,
    react: prettierReact.rules,
    vue: prettierVue.rules,
    typescript: prettierTypeScript.rules
};

const RULE_PREFIX_MAP = {
    index: '',
    react: 'react/',
    vue: 'vue/',
    typescript: '@typescript-eslint/'
};
type RulePrefix = keyof typeof RULE_PREFIX_MAP;
const namespaces: RulePrefix[] = ['index', 'react', 'vue', 'typescript'];

namespaces.forEach((namespace) => {
    fs.readdirSync(path.resolve(__dirname, '../test', namespace))
github AlloyTeam / eslint-config-alloy / scripts / rulesCoverage.ts View on Github external
/* eslint-disable @typescript-eslint/no-require-imports */
import fs from 'fs';
import path from 'path';

import { NAMESPACE_CONFIG, NAMESPACES } from '../config';

/** 可用的规则(去除废弃的和 Prettier 的规则) */
let activeRules: string[] = [];
let deprecatedRules: string[] = [];
const prettierRules = [
    ...Object.keys(require('eslint-config-prettier').rules),
    ...Object.keys(require('eslint-config-prettier/@typescript-eslint').rules),
    ...Object.keys(require('eslint-config-prettier/babel').rules),
    ...Object.keys(require('eslint-config-prettier/flowtype').rules),
    ...Object.keys(require('eslint-config-prettier/react').rules),
    ...Object.keys(require('eslint-config-prettier/standard').rules),
    ...Object.keys(require('eslint-config-prettier/unicorn').rules),
    ...Object.keys(require('eslint-config-prettier/vue').rules)
];

// 填充 deprecatedRules 和 activeRules
Object.values(NAMESPACE_CONFIG).forEach(({ rulePrefix, pluginName }) => {
    const ruleEntries = pluginName
        ? Object.entries(require(pluginName).rules)
        : Array.from(require('eslint/lib/rules').entries());
    ruleEntries.forEach(([ruleName, ruleValue]) => {
        const fullRuleName = rulePrefix + ruleName;
github manovotny / eslint-config-get-off-my-lawn / index.js View on Github external
...config.rules,
            ...reactNative
        };
    } else {
        config.plugins.push('jsx-a11y');
        config.rules = {
            ...config.rules,
            ...jsxA11y
        };
    }
}

if (getUsage('prettier')) {
    config.rules = {
        ...config.rules,
        ...require('eslint-config-prettier').rules,
        ...require('eslint-config-prettier/babel').rules,
        ...require('eslint-config-prettier/react').rules,
        ...require('eslint-config-prettier/unicorn').rules
    };
}

module.exports = config;
github elastic / kibana / packages / eslint-config-kibana / .eslintrc.js View on Github external
from: '@kbn/elastic-idx',
            to: false,
            disallowedMessage: `Don't use idx(), use optional chaining syntax instead https://ela.st/optchain`
          },
          {
            from: 'x-pack',
            toRelative: 'x-pack',
          },
          {
            from: 'react-router',
            to: 'react-router-dom',
          },
        ],
      ],
    },
    require('eslint-config-prettier').rules,
    require('eslint-config-prettier/react').rules
  )
};