Skip to content

Commit

Permalink
Merge pull request #233 from eemeli/ts-more
Browse files Browse the repository at this point in the history
Refactor rest of src/ as TypeScript
  • Loading branch information
eemeli committed Feb 27, 2021
2 parents b0ecfac + 26f19b7 commit a51a079
Show file tree
Hide file tree
Showing 102 changed files with 3,468 additions and 2,769 deletions.
26 changes: 15 additions & 11 deletions .eslintrc.yaml
@@ -1,34 +1,38 @@
root: true
parser: babel-eslint
parser: "@typescript-eslint/parser"
env:
node: true

plugins:
- "@typescript-eslint"

extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
- prettier

rules:
array-callback-return: error
camelcase: error
consistent-return: error
eqeqeq: [error, always, 'null': ignore]
consistent-return: 0
eqeqeq: [error, always, "null": ignore]
no-constant-condition: [error, checkLoops: false]
no-control-regex: 0
no-fallthrough: [error, commentPattern: fallthrough]
no-implicit-globals: error
no-template-curly-in-string: warn
no-unused-labels: 0
no-var: error
prefer-const: [warn, destructuring: all]
"@typescript-eslint/ban-ts-comment": off
"@typescript-eslint/explicit-module-boundary-types": off
"@typescript-eslint/no-explicit-any": off
"@typescript-eslint/no-namespace": off
"@typescript-eslint/no-unused-vars": off
"@typescript-eslint/no-unused-vars-experimental": warn

overrides:
- files: src/**/*.js
env:
es6: true
node: false
- files:
- tests/**/*.js
- files: [tests/**]
env:
es6: true
jest: true
rules:
camelcase: 0
25 changes: 17 additions & 8 deletions babel.config.js
@@ -1,13 +1,22 @@
module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-nullish-coalescing-operator',
['babel-plugin-trace', { strip: true }]
overrides: [
{
test: /\.js$/,
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-nullish-coalescing-operator'
]
},
{
test: /\.ts$/,
plugins: [
['@babel/plugin-transform-typescript', { allowDeclareFields: true }],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-nullish-coalescing-operator'
]
}
]
}

if (process.env.NODE_ENV === 'test')
module.exports.presets = [
['@babel/env', { targets: { node: 'current' } }],
'@babel/preset-typescript'
]
module.exports.presets = [['@babel/env', { targets: { node: 'current' } }]]
6 changes: 5 additions & 1 deletion docs/04_documents.md
Expand Up @@ -63,7 +63,11 @@ The `contents` of a parsed document will always consist of `Scalar`, `Map`, `Seq

#### `new YAML.Document(value, replacer?, options = {})`

Creates a new document. If `value` is defined, the document `contents` are initialised with that value, wrapped recursively in appropriate [content nodes](#content-nodes). If `value` is `undefined`, the document's `contents` and `schema` are initialised as `null`. If defined, a `replacer` may filter or modify the initial document contents, following the same algorithm as the [JSON implementation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter). See [Options](#options) for more information on the last argument.
Creates a new document.
If `value` is defined, the document `contents` are initialised with that value, wrapped recursively in appropriate [content nodes](#content-nodes).
If `value` is `undefined`, the document's `contents` is initialised as `null`.
If defined, a `replacer` may filter or modify the initial document contents, following the same algorithm as the [JSON implementation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter).
See [Options](#options) for more information on the last argument.

| Member | Type | Description |
| ------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand Down
1 change: 0 additions & 1 deletion index.d.ts
@@ -1,2 +1 @@
export * from './dist/index'
export { AST } from './dist/ast/index'
8 changes: 4 additions & 4 deletions jest.config.js
Expand Up @@ -21,10 +21,10 @@ switch (process.env.npm_lifecycle_event) {
default:
process.env.TRACE_LEVEL = 'log'
moduleNameMapper = {
'^\\./dist$': '<rootDir>/src/index.js',
'^\\./dist/types(\\.js)?$': '<rootDir>/src/types.js',
'^\\./dist$': '<rootDir>/src/index.ts',
'^\\./dist/types(\\.js)?$': '<rootDir>/src/types.ts',
'^\\./dist/(.+)$': '<rootDir>/src/$1',
'^\\.\\./dist/test-events.js$': '<rootDir>/src/test-events.js'
'^\\.\\./dist/test-events.js$': '<rootDir>/src/test-events.ts'
}
}

Expand All @@ -33,7 +33,7 @@ module.exports = {
moduleNameMapper,
resolver: 'jest-ts-webcompat-resolver',
testEnvironment: 'node',
testMatch: ['**/tests/**/*.{js,ts}', '!**/tests/typings.ts'],
testMatch: ['**/tests/**/*.{js,ts}'],
testPathIgnorePatterns,
transform: { '/(src|tests)/.*\\.(js|ts)$': 'babel-jest' }
}

0 comments on commit a51a079

Please sign in to comment.