Skip to content

Commit

Permalink
Merge pull request #435 from markw65/tsconfig
Browse files Browse the repository at this point in the history
Setup tsconfig to detect use of library functions from es6 or later
  • Loading branch information
hildjj authored Dec 9, 2023
2 parents df33c16 + 0aad9b8 commit 55e8b6e
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Released: TBD

### Minor Changes

- [#435](https://github.com/peggyjs/peggy/pull/435) Setup tsconfig to detect use of library functions from es6 or later
- [#438](https://github.com/peggyjs/peggy/pull/438) Make test build deterministic
- [#436](https://github.com/peggyjs/peggy/pull/436) Get rid of tsd
- [#430](https://github.com/peggyjs/peggy/pull/430) Make generate-js.js ts clean
Expand Down
5 changes: 5 additions & 0 deletions benchmark/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig-base.json",
"include": ["**/*.js"],
"exclude": ["./vendor"],
}
7 changes: 7 additions & 0 deletions bin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig-base.json",
"include": ["**/*.js"],
"compilerOptions": {
"outDir": "../build/ts-cli"
},
}
2 changes: 1 addition & 1 deletion docs/js/benchmark-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/test-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/vendor/peggy/peggy.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
"**/*.test-d.ts",
],
"transform": {
"^.+\\.ts$": "ts-jest",
"^.+\\.ts$": ["ts-jest", { "tsconfig":"test/tsconfig.json" }],
},
"testTimeout": 20000,
};
3 changes: 3 additions & 0 deletions lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"env": {
"commonjs": true
},
"parserOptions": {
"project": ["lib/tsconfig.json"]
}
}
7 changes: 7 additions & 0 deletions lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig-base.json",
"include": ["**/*.ts", "**/*.js"],
"compilerOptions": {
"types": [],
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"examples": "node bin/peggy.js -c docs/js/options.js docs/js/examples.peggy",
"set_version": "node ./tools/set_version",
"lint": "eslint . --ext js,ts,mjs",
"ts": "tsc --build tsconfig.json test/tsconfig.json",
"ts": "tsc --build tsconfig.json",
"docs": "cd docs && npm run build",
"test": "jest",
"test:web": "cd web-test && npm test",
Expand Down
2 changes: 1 addition & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"mocha": true
},
"parserOptions": {
"project": "test/tsconfig.json"
"project": ["test/tsconfig.json", "test/tsconfig-cli.json"]
}
}
12 changes: 12 additions & 0 deletions test/tsconfig-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig-base.json",
"include": ["./cli/**/*", "./types/**/*"],
"exclude": ["./cli/fixtures/bad.js"],
"compilerOptions": {
"outDir": "../build/ts-cli"
},
"references": [
{ "path": "../bin" },
{ "path": "../lib" }
]
}
44 changes: 7 additions & 37 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
{
"compilerOptions": {
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": false, /* Report errors in .js files. */
"declaration": false, /* Generates corresponding '.d.ts' file. */
"declarationMap": false, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./build/ts/", /* Redirect output structure to the directory. */
"removeComments": true, /* Do not emit comments to output. */
"rootDirs": ["./", "../bin"], /* Specify the root directories of input files. Use to control the output directory structure with --outDir. */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"strict": true, /* Enable all strict type-checking options. */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"noEmit": true

/* over time we will enable these */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */

// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
},
"include": ["**/*.ts"]
"extends": "../tsconfig-base.json",
"include": ["**/*.ts", "**/*.js"],
"exclude": ["./cli/**/*", "./types/**/*"],
"references": [
{ "path": "../lib" },
{ "path": "./tsconfig-cli.json" }
]
}
39 changes: 39 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"compilerOptions": {
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": false, /* Report errors in .js files. */
"composite": true,
"declaration": true, /* Generates corresponding '.d.ts' file. */
"declarationDir": "./build/tsd",
"declarationMap": false, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./build/ts/", /* Redirect output structure to the directory. */
"removeComments": true, /* Do not emit comments to output. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"strict": true, /* Enable all strict type-checking options. */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"lib": ["ES2015"], /* Specify library files to be included in the compilation. */

/* over time we will enable these */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */

// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
},
}
43 changes: 7 additions & 36 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
{
"compilerOptions": {
"allowJs": true, /* Allow javascript files to be compiled. */
"checkJs": false, /* Report errors in .js files. */
"declaration": false, /* Generates corresponding '.d.ts' file. */
"declarationMap": false, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./build/ts/", /* Redirect output structure to the directory. */
"removeComments": true, /* Do not emit comments to output. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"sourceMap": true, /* Generates corresponding '.map' file. */
"strict": true, /* Enable all strict type-checking options. */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
// "lib": [], /* Specify library files to be included in the compilation. */

/* over time we will enable these */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */

// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
},
"include": ["./lib/**/*.js", "./test/**/*.spec.js", "./benchmark/*.js"]
"files": [],
"include": [],
"references": [
{ "path":"./benchmark/tsconfig.json" },
{ "path":"./lib/tsconfig.json" },
{ "path":"./test/tsconfig.json" }
]
}

0 comments on commit 55e8b6e

Please sign in to comment.