Skip to content

Commit

Permalink
fix(prettier-plugin-jsdoc): move providers load to another fn
Browse files Browse the repository at this point in the history
  • Loading branch information
homer0 committed Oct 29, 2020
1 parent 86e8ba8 commit 36025fa
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 31 deletions.
34 changes: 3 additions & 31 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
const path = require('path');
const { loadProviders, get } = require('./fns/app');
const { get } = require('./fns/app');
const { getPlugin } = require('./fns/getPlugin');
const { loadFns } = require('./loader');

loadProviders(path.join(__dirname, 'fns'), [
'formatAccessTag',
'formatArrays',
'formatDescription',
'formatObjects',
'formatStringLiterals',
'formatTSTypes',
'formatTags',
'formatTagsDescription',
'formatTagsTypes',
'formatTypeAsCode',
'getLanguages',
'getOptions',
'getParsers',
'getPlugin',
'prepareExampleTag',
'prepareTagDescription',
'prepareTagName',
'prepareTags',
'render',
'renderExampleTag',
'renderTagInColumns',
'renderTagInLine',
'replaceTagsSynonyms',
'sortTags',
'splitText',
'trimTagsProperties',
'utils',
]);
loadFns();

module.exports = get(getPlugin)();
38 changes: 38 additions & 0 deletions src/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const { loadProviders } = require('./fns/app');
/**
* Loads and registers the providers of all the plugin functions.
*/
const loadFns = () => {
loadProviders(path.join(__dirname, 'fns'), [
'formatAccessTag',
'formatArrays',
'formatDescription',
'formatObjects',
'formatStringLiterals',
'formatTSTypes',
'formatTags',
'formatTagsDescription',
'formatTagsTypes',
'formatTypeAsCode',
'getLanguages',
'getOptions',
'getParsers',
'getPlugin',
'prepareExampleTag',
'prepareTagDescription',
'prepareTagName',
'prepareTags',
'render',
'renderExampleTag',
'renderTagInColumns',
'renderTagInLine',
'replaceTagsSynonyms',
'sortTags',
'splitText',
'trimTagsProperties',
'utils',
]);
};

module.exports.loadFns = loadFns;
1 change: 1 addition & 0 deletions test/unit/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
jest.unmock('../../src/index');
jest.unmock('../../src/loader');
jest.mock('../../src/fns/app');

const path = require('path');
Expand Down

0 comments on commit 36025fa

Please sign in to comment.