style9 icon indicating copy to clipboard operation
style9 copied to clipboard

feat: support `require('style9')`

Open SukkaW opened this issue 2 years ago • 6 comments

Previously, style9 only supports import xxx from 'style9'. The PR adds support for const xxx = require('style9').

The unit test case is added in __tests__/code/import.js.

SukkaW avatar Feb 05 '23 15:02 SukkaW

Seems that CI failed due to test coverage. Let me see what I can do.


Update

The test coverage reaches 100% and the CI is passed.

SukkaW avatar Feb 05 '23 16:02 SukkaW

The mutation testing report(available at the action run page) shows that more tests are needed for negative situations, i.e. code that shouldn't be processed.

Examples of situations that may need to be tested:

const style9 = require(style9);
let style9 = require('style9');
var style9 = require('style9');
const { create } = require('style9');
const style9 = foo.require('style9');
const create = require('style9').create;
const style9 = globalThis.require('style9');
require('style9')();
require('style9').create();
foo(require('style9'));
const style9 = require('style9', foo);

johanholmerin avatar Feb 06 '23 17:02 johanholmerin

const style9 = require(style9);
let style9 = require('style9');
var style9 = require('style9');
const { create } = require('style9');
const style9 = foo.require('style9');
const create = require('style9').create;
const style9 = globalThis.require('style9');
require('style9')();
require('style9').create();
foo(require('style9'));
const style9 = require('style9', foo);

Sure, I will add the cases.


Added in johanholmerin/style9@80e3f9c (#89)

SukkaW avatar Feb 06 '23 19:02 SukkaW

The mutation tests are still lacking some coverage. The cases above were only examples, they may not be exactly what is required. Check the test report and you should be able to see what's needed.

johanholmerin avatar Feb 07 '23 09:02 johanholmerin

@SukkaW Is this PR still active?

johanholmerin avatar Mar 01 '23 09:03 johanholmerin

I have been a bit busy recently. I will draft the PR for now.

SukkaW avatar Mar 07 '23 04:03 SukkaW