eslint-plugin-convert-filter

1.0.1 • Public • Published

eslint-plugin-convert-filters

This plugin converts Vue global filter settings into exports

Before conversion

import Vue from 'vue';
import def, { numeric } from '~/utils/Strings';
import dollar, { yen, euro } from '~/utils/Money';

Vue.filter('stringDefaultFilter', def);

Vue.filter('percent', (value: string) => `${value}%`);

Vue.filter(
  'numeric',
  (value: string) => `${numeric(value)}`,
);
Vue.filter('dollar', dollar);
Vue.filter('yen', yen);
Vue.filter('eur', euro);

Vue.filter('func', function(xxx: string) {
  return `xxx${xxx}xxx`;
});

After conversion

import def, { numeric as _numeric } from '~/utils/Strings';
import dollar, { yen, euro } from '~/utils/Money';

export const stringDefaultFilter = def;

export const percent = (value: string) => `${value}%`;

export const numeric = (value: string) => `${_numeric(value)}`;
export { dollar };
export { yen };
export const eur = euro;

export function func(xxx: string) {
  return `xxx${xxx}xxx`;
}

Installation

Install Eslint at first.

npm install -D eslint

Next, intall this plugin.

npm install -D eslint-plugin-convert-filter

Usage

Write settings below in .eslintrc like file (e.g. .eslintrc.convert) or add settings below to your .eslintrc

{
  "plugins": ["convert-filter"],
  "rules": {
    "convert-filter/convert-filter": 1,
    "convert-filter/resolve-callee": 1
  }
}

Add script to your package.json, if you need.

  "scripts": {
    "convert-filter": "eslint -c <file with settings of this plugin> --fix"
  },

Run this plugin

npm run convert-filter -- <vue file where global filters registered>

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-convert-filter

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

6.48 kB

Total Files

6

Last publish

Collaborators

  • yyyymm