Reconfigure tsconfig and eslint

This commit is contained in:
Nick Alteen 2023-08-23 13:57:44 -04:00
parent 497bed758e
commit bd79503369
12 changed files with 195 additions and 521 deletions

View File

@ -1,2 +1,3 @@
dist/
node_modules/
coverage/

View File

@ -2,7 +2,6 @@ env:
node: true
es6: true
jest: true
jest/globals: true
globals:
Atomics: readonly
@ -12,6 +11,8 @@ ignorePatterns:
- '!.*'
- '**/node_modules/.*'
- '**/dist/.*'
- '**/coverage/.*'
- '*.json'
parser: '@typescript-eslint/parser'
@ -19,18 +20,28 @@ parserOptions:
ecmaVersion: 2023
sourceType: module
project:
- './.github/linters/tsconfig.json'
- './tsconfig.json'
plugins:
- jest
- '@typescript-eslint'
extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended
rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off',
@ -66,34 +77,7 @@ rules:
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
}
extends:
- eslint:recommended
- plugin:github/recommended
- plugin:jest/recommended
overrides:
- files:
- '*.json'
extends:
- plugin:jsonc/recommended-with-json
parser: jsonc-eslint-parser
parserOptions:
jsonSyntax: JSON
- files:
- '*.jsonc'
extends:
- plugin:jsonc/recommended-with-jsonc
parser: jsonc-eslint-parser
parserOptions:
jsonSyntax: JSONC
- files:
- '*.json5'
extends:
- plugin:jsonc/recommended-with-json5
parser: jsonc-eslint-parser
parserOptions:
jsonSyntax: JSON5

9
.github/linters/tsconfig.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
}

View File

@ -38,7 +38,7 @@ jobs:
- name: Test
id: npm-ci-test
run: npm ci-test
run: npm run ci-test
test-action:
name: GitHub Actions Test

View File

@ -40,4 +40,5 @@ jobs:
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_JSCPD: false

1
.gitignore vendored
View File

@ -96,4 +96,3 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
dist/**/*

View File

@ -1,7 +1,4 @@
import { wait } from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import { expect, test } from '@jest/globals'
test('throws invalid number', async () => {
@ -13,16 +10,6 @@ test('wait 500 ms', async () => {
const start = new Date()
await wait(500)
const end = new Date()
var delta = Math.abs(end.getTime() - start.getTime())
const delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
const np = process.execPath
const ip = path.join(__dirname, '..', 'dist', 'index.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}
console.log(cp.execFileSync(np, [ip], options).toString())
})

622
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -23,8 +23,8 @@
"ci-test": "jest",
"format:write": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'",
"lint": "eslint -c ./.github/linters/.eslintrc.yml src/**/*.ts",
"package": "ncc build --source-map --license licenses.txt",
"lint": "eslint -c ./.github/linters/.eslintrc.yml",
"package": "ncc build src/index.ts --source-map --license licenses.txt",
"test": "(jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg",
"all": "npm run format:write && npm run lint && npm run test && npm run package"
},

View File

@ -25,4 +25,5 @@ async function run(): Promise<void> {
}
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
run()

View File

@ -1,13 +1,17 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"target": "ES2022",
"module": "nodenext",
"rootDir": "./src",
"moduleResolution": "nodenext",
"baseUrl": "./",
"sourceMap": true,
"outDir": "./dist",
"rootDirs": ["src", "__tests__"],
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true
"skipLibCheck": true
},
"exclude": ["node_modules"]
"exclude": ["./dist", "./node_modules", "./__tests__", "./coverage"]
}