Skip to content

Commit

Permalink
New: add rules to import plugin #11, fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed May 8, 2021
1 parent 4ad74d1 commit 11007d5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/plugins/import.js
Expand Up @@ -5,8 +5,10 @@ module.exports = {
'plugin:import/recommended'
],
'rules' : {
'import/no-commonjs' : 0,

'import/no-commonjs' : [ 2, {
'allowPrimitiveModules' : true,
'allowConditionalRequire' : false
} ],
'import/imports-first' : 2,
'import/order' : [ 2, { 'groups': [ 'builtin', 'external', 'internal', 'parent', 'sibling', 'index' ] } ],
'import/newline-after-import' : 2
Expand Down
8 changes: 7 additions & 1 deletion tests/entry.js
Expand Up @@ -8,6 +8,12 @@ const entry = process.env.ENTRY && path.resolve(process.env.ENTRY)

export default require(entry);

export function _load(relPath) {
function _load(relPath) {
return require(path.join(entry, relPath));
}

_load.resolve = function (relPath) {
return require.resolve(path.join(entry, relPath));
};

export { _load };
29 changes: 29 additions & 0 deletions tests/package/plugins.test.js
@@ -0,0 +1,29 @@
import { assert } from 'chai';
import entry, { _load } from '../entry';

const PLUGINS = [ 'import' ];

PLUGINS.forEach(name => {
suite.only(`Plugins: ${name}`);

test('Present in default incredible configuration', function () {
const extendedPath = entry.extends.find(p => p.includes(name));

assert.exists(extendedPath);
assert.equal(extendedPath, _load.resolve(`plugins/${name}.js`));
});

test('Load actual plugin', function () {
const plugin = _load(`plugins/${name}.js`);

assert.exists(plugin);
assert.deepEqual(plugin.plugins, [ name ]);
});

test('Extends recommended configuration', function () {
const plugin = _load(`plugins/${name}.js`);

assert.exists(plugin);
assert.includeMembers(plugin.extends, [ `plugin:${name}/recommended` ]);
});
});

0 comments on commit 11007d5

Please sign in to comment.