Skip to content

Commit

Permalink
fix: provide es and cjs files
Browse files Browse the repository at this point in the history
  • Loading branch information
nimec01 committed Sep 21, 2024
1 parent 6e49917 commit 85a1446
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 11 deletions.
9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

74 changes: 74 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

Check failure on line 1 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Do not use "use strict" directive

var eslint = require('@eslint/js');

Check failure on line 3 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected var, use let or const instead

Check failure on line 3 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Do not use "require"
var globals = require('globals');

Check failure on line 4 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected var, use let or const instead

Check failure on line 4 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Do not use "require"
var noSecrets = require('eslint-plugin-no-secrets');

Check failure on line 5 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected var, use let or const instead

Check failure on line 5 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Do not use "require"
var cspell = require('@cspell/eslint-plugin');

Check failure on line 6 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected var, use let or const instead

Check failure on line 6 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Do not use "require"
var prettierConfigRecommended = require('eslint-plugin-prettier/recommended');

Check failure on line 7 in dist/index.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected var, use let or const instead
var unicorn = require('eslint-plugin-unicorn');
var importX = require('eslint-plugin-import-x');
var sonarjs = require('eslint-plugin-sonarjs');

var baseConfig = [
eslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.builtin,
...globals.nodeBuiltin,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
},
/**
* Plugins
*/
// no-secrets
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: {
'no-secrets': noSecrets,
},
rules: {
'no-secrets/no-secrets': 'error',
},
},
// cspell
{
plugins: {
'@cspell': cspell,
},
rules: {
'@cspell/spellchecker': 'error',
},
},
// unicorn
unicorn.configs['flat/all'],
// sonarjs
sonarjs.configs.recommended,
// import-x
importX.flatConfigs.recommended,
// prettier
prettierConfigRecommended,
/**
* Rules
*/
{
rules: {
'no-console': 'error',
},
},
];

var index = {
configs: {
base: baseConfig,
},
};

module.exports = index;
72 changes: 72 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import eslint from '@eslint/js';
import globals from 'globals';
import noSecrets from 'eslint-plugin-no-secrets';
import cspell from '@cspell/eslint-plugin';
import prettierConfigRecommended from 'eslint-plugin-prettier/recommended';
import unicorn from 'eslint-plugin-unicorn';
import importX from 'eslint-plugin-import-x';
import sonarjs from 'eslint-plugin-sonarjs';

var baseConfig = [
eslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.builtin,
...globals.nodeBuiltin,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
},
/**
* Plugins
*/
// no-secrets
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: {
'no-secrets': noSecrets,
},
rules: {
'no-secrets/no-secrets': 'error',
},
},
// cspell
{
plugins: {
'@cspell': cspell,
},
rules: {
'@cspell/spellchecker': 'error',
},
},
// unicorn
unicorn.configs['flat/all'],
// sonarjs
sonarjs.configs.recommended,
// import-x
importX.flatConfigs.recommended,
// prettier
prettierConfigRecommended,
/**
* Rules
*/
{
rules: {
'no-console': 'error',
},
},
];

var index = {
configs: {
base: baseConfig,
},
};

export { index as default };
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
"publishConfig": {
"access": "public"
},
"main": "./src/index.js",
"files": [
"dist",
"README-v1.md",
"CHANGELOG.md"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"build": "rollup -c"
},
"dependencies": {
"@cspell/eslint-plugin": "^8.14.4",
Expand All @@ -44,6 +51,7 @@
"conventional-changelog-conventionalcommits": "^8.0.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"rollup": "^3.29.5",
"semantic-release": "^24.1.1"
},
"prettier": "@nimec/prettier-config",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @type {import("rollup").RollupOptions} */
export default {
input: './src/index.js',
output: [
{
file: './dist/index.js',
format: 'cjs',
},
{
file: './dist/index.mjs',
format: 'es',
},
],
external: [
'@eslint/js',
'globals',
'eslint-plugin-no-secrets',
'eslint-plugin-unicorn',
'eslint-plugin-sonarjs',
'eslint-plugin-import-x',
'@cspell/eslint-plugin',
'eslint-plugin-prettier/recommended',
],
};

0 comments on commit 85a1446

Please sign in to comment.