Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Use EditorConfig **DRAFT** #26

Draft
wants to merge 3 commits into
base: main-forked
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
max_line_length = 80

[*.{json,md,yml}]
indent_style = space
indent_size = 2

[*.{ts,js}]
indent_style = space
indent_size = 4
26 changes: 13 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint-check-only
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint-check-only
82 changes: 41 additions & 41 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,56 @@ jobs:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run test
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run test
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run lint
docs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build:doc
- run: git diff-files --ignore-all-space --name-only --exit-code
- uses: actions/checkout@v2
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build:doc
- run: git diff-files --ignore-all-space --name-only --exit-code
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package-lock.json
doc/
dist/
coverage/
16 changes: 0 additions & 16 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
module.exports = {
printWidth: 80,
semi: false,
trailingComma: "all",
tabWidth: 4,
overrides: [
{
files: ["*.json"],
options: {
tabWidth: 2,
},
},
{
files: "*.md",
options: {
tabWidth: 2,
},
},
],
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Within the project root directory:
npm install
```

### Format Code Files

```shell
npm run formatcode
```

### Run Linter

```shell
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build": "tsc --build",
"build:doc": "rimraf doc && typedoc src/index.ts",
"build:release": "rimraf dist && rollup -c",
"formatcode": "prettier --write .",
"lint": "tsc && eslint --fix 'src/**'",
"lint-check-only": "tsc && eslint 'src/**'",
"test": "jest --coverage",
Expand Down
107 changes: 53 additions & 54 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,61 @@
import path from "path";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { terser } from "rollup-plugin-terser";
import license from "rollup-plugin-license";
import sizes from "rollup-plugin-sizes";
import path from "path"
import resolve from "@rollup/plugin-node-resolve"
import typescript from "@rollup/plugin-typescript"
import { terser } from "rollup-plugin-terser"
import license from "rollup-plugin-license"
import sizes from "rollup-plugin-sizes"

const __dirname = path.resolve();
const extensions = [".ts", ".js"];
const __dirname = path.resolve()
const extensions = [".ts", ".js"]
const commonPlugins = [
terser({
output: {
comments: false
}
output: {
comments: false,
},
}),
license({
banner: {
content: {
file: "LICENSE_TEMPLATE"
}
}
banner: {
content: {
file: "LICENSE_TEMPLATE",
},
},
}),
sizes()
];
sizes(),
]

export default [
{
input: "./src/index.ts",
plugins: [
resolve({ extensions }),
typescript({
target: "es5",
composite: false
}),
...commonPlugins
],
output: {
dir: path.resolve(__dirname, "dist"),
format: "umd",
name: "openinsights"
}
},
{
input: "./src/index.ts",
plugins: [
resolve({ extensions }),
typescript({
declaration: true,
composite: false,
declarationDir: path.resolve(__dirname, "dist", "esm", "types"),
outDir: path.resolve(__dirname, "dist", "esm"),
rootDir: path.resolve(__dirname, "src")
}),
...commonPlugins
],
output: {
dir: path.resolve(__dirname, "dist", "esm"),
format: "es"
}
}
];

{
input: "./src/index.ts",
plugins: [
resolve({ extensions }),
typescript({
target: "es5",
composite: false,
}),
...commonPlugins,
],
output: {
dir: path.resolve(__dirname, "dist"),
format: "umd",
name: "openinsights",
},
},
{
input: "./src/index.ts",
plugins: [
resolve({ extensions }),
typescript({
declaration: true,
composite: false,
declarationDir: path.resolve(__dirname, "dist", "esm", "types"),
outDir: path.resolve(__dirname, "dist", "esm"),
rootDir: path.resolve(__dirname, "src"),
}),
...commonPlugins,
],
output: {
dir: path.resolve(__dirname, "dist", "esm"),
format: "es",
},
},
]
2 changes: 1 addition & 1 deletion setupJest.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('jest-fetch-mock').enableMocks()
require("jest-fetch-mock").enableMocks()
38 changes: 17 additions & 21 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"composite": true,
"rootDir": "src",
"outDir": "dist",
"lib": ["DOM", "ES2015", "ES2020"],
"module": "es6",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "dist/types",
"declarationMap": true
},
"include": ["src/**/*"],
"exclude": [
"dist",
"**/*.test.ts",
"src/testUtil"
]
"compilerOptions": {
"target": "es5",
"composite": true,
"rootDir": "src",
"outDir": "dist",
"lib": ["DOM", "ES2015", "ES2020"],
"module": "es6",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "dist/types",
"declarationMap": true
},
"include": ["src/**/*"],
"exclude": ["dist", "**/*.test.ts", "src/testUtil"]
}