Rollup and ESLint

This commit is contained in:
AtHeartEngineer
2023-02-10 07:31:10 +00:00
parent 25b1d6598d
commit 8de6c9f447
9 changed files with 6959 additions and 6185 deletions

View File

@@ -1,9 +1,34 @@
module.exports = {
extends: ['airbnb-typescript/base',],
extends: ['airbnb-typescript/base', "plugin:@typescript-eslint/recommended", "plugin:import/recommended", "plugin:import/typescript"],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
parserOptions: {
project: './tsconfig.json',
},
rules: {
semi: ["warn", "never"],
"import/extensions": ["warn", "never"],
"@typescript-eslint/semi": ["warn", "never"],
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
typescript: {
alwaysTryTypes: true,
},
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
"import/extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
};

View File

@@ -1,4 +0,0 @@
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]],
};

View File

@@ -6,7 +6,7 @@ const config: Config.InitialOptions = {
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "tsconfig.test.json" }]
},
"silent": true,
"detectOpenHandles": true,

12981
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,9 @@
"description": "decentralized p2p chat library",
"scripts": {
"test": "jest",
"build": "tsc -p tsconfig.json"
"test:debug": "jest --silent=false",
"build": "rollup --config rollup.config.mjs",
"lint": "eslint --ext .ts,.tsx,.js,.jsx src/ -c .eslintrc.js"
},
"repository": {
"type": "git",
@@ -16,21 +18,23 @@
"url": "https://github.com/kayleegeorge/zk-chat/issues"
},
"homepage": "https://github.com/kayleegeorge/zk-chat#readme",
"main": "./dist/index.node.js",
"types": "dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.node.js"
},
"directories": {
"lib": "./lib",
"dist": "./dist",
"src": "./src",
"test": "./tests"
},
"main": "./lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib/",
"dist/",
"src/",
"tests/"
"LICENSE",
"README.md"
],
"exports": {
"import": "./lib/index.js"
},
"dependencies": {
"@ethersproject/providers": "^5.7.2",
"@metamask/detect-provider": "^2.0.0",
@@ -44,31 +48,36 @@
"@zk-kit/protocols": "^1.11.1",
"crypto-js": "^4.1.1",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"js-waku": "^0.30.0",
"rlnjs": "github:Rate-Limiting-Nullifier/rlnjs"
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomicfoundation/hardhat-toolbox": "^1.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@types/chai": "^4.3.4",
"@types/jest": "^29.2.3",
"@types/node": "^18.11.19",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"@webpack-cli/generators": "^3.0.1",
"@typescript-eslint/parser": "^5.51.0",
"eslint": "^8.33.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"ethers": "^5.7.2",
"hardhat": "^2.12.4",
"jest": "^29.3.1",
"prettier": "^2.8.1",
"rollup": "^3.14.0",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-visualizer": "^5.9.0",
"ts-jest": "^29.0.3",
"ts-loader": "^9.4.1",
"tslib": "^2.5.0",
"typescript": "^4.9.5"
},
"esModuleInterop": true
}
}
}

36
rollup.config.mjs Normal file
View File

@@ -0,0 +1,36 @@
import typescript from 'rollup-plugin-typescript2';
import cleaner from 'rollup-plugin-cleaner';
import { visualizer } from "rollup-plugin-visualizer";
import * as fs from "fs"
const pkg = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
const banner = `/**
* @module ${pkg.name}
* @version ${pkg.version}
* @file ${pkg.description}
* @copyright Ethereum Foundation 2022
* @license ${pkg.license}
* @see [Github]{@link ${pkg.homepage}}
*/`
export default {
input: 'src/index.ts',
output: [
{ file: pkg.exports.require, format: "cjs", banner, exports: "auto" },
{ file: pkg.exports.import, format: "es", banner }
],
plugins: [
cleaner({
targets: [
'./dist/'
]
}),
typescript({tsconfig: 'tsconfig.build.json'}),
visualizer({
emitFile: true,
filename: "stats.html",
template: "sunburst"
}),
]
};

8
tsconfig.build.json Normal file
View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"rootDir": "./src",
"outDir": "./dist",
"files": [
"src/index.ts",
]
}

View File

@@ -1,28 +1,21 @@
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib/",
"target": "ES6",
"module": "esnext",
"noUnusedLocals": false,
"target": "ES5",
"module": "ES6",
"moduleResolution": "node",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": false,
"noImplicitAny": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noEmitOnError": true,
"forceConsistentCasingInFileNames": true,
"inlineSourceMap": true,
"inlineSources": true,
"sourceMap": true,
"esModuleInterop": true,
"declaration": true,
"moduleResolution": "Node",
"typeRoots": [
"node_modules/@types",
"src/types",
],
},
"include": [
"src",
],
"exclude": [
"node_modules",
]
"declarationDir": "./dist/types",
"strict": true
}
}

12
tsconfig.test.json Normal file
View File

@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitAny": false,
"noImplicitReturns": false,
"noEmitOnError": false,
"include": [
"tests"
],
"exclude": []
}