This plugin converts Vue global filter settings into exports
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`;
});
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`;
}
Install Eslint
at first.
npm install -D eslint
Next, intall this plugin.
npm install -D eslint-plugin-convert-filter
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>