1.0.1 • Published 5 years ago
eslint-plugin-convert-filter v1.0.1
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 eslintNext, intall this plugin.
npm install -D eslint-plugin-convert-filterUsage
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>