diff --git a/.eslintrc.yml b/.eslintrc.yml index cff713b..158246f 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,7 +2,9 @@ env: es6: true node: true mocha: true -extends: 'eslint:recommended' +extends: + - 'eslint:recommended' + - 'prettier' parserOptions: ecmaVersion: 13 sourceType: script @@ -11,7 +13,7 @@ rules: - error - 4 linebreak-style: - - warn + - error - unix quotes: - error @@ -31,16 +33,16 @@ rules: dot-notation: error no-tabs: error no-trailing-spaces: error - # no-use-before-define: error + no-use-before-define: error no-useless-call: error no-with: error operator-linebreak: error require-jsdoc: - error - require: - ClassDeclaration: true - MethodDefinition: true - FunctionDeclaration: true + ClassDeclaration: true + MethodDefinition: true + FunctionDeclaration: true valid-jsdoc: - error - requireReturn: false diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b332714 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +coverage +out +doc +node_modules +dist +packages +**/*.min.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..03409a9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "printWidth": 100, + "tabWidth": 4, + "trailingComma": "none", + "semi": true +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..da2fca2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/package.json b/package.json index 0ad6484..688e103 100644 --- a/package.json +++ b/package.json @@ -1,158 +1,163 @@ { - "name": "@accordproject/concerto-codegen", - "version": "3.31.3", - "description": "Code Generation for the Concerto Modeling Language", - "homepage": "https://github.com/accordproject/concerto", - "engines": { - "node": ">=18", - "npm": ">=6" - }, - "main": "index.js", - "browser": "umd/concerto-codegen.js", - "typings": "types/index.d.ts", - "scripts": { - "coverage": "node ./scripts/coverage.js \"packages/concerto-*\" && nyc report -t coverage --cwd . --report-dir coverage --reporter=lcov && cat ./coverage/lcov.info", - "prepublishOnly": "npm run webpack", - "pretest": "npm run lint", - "lint": "eslint . && npm run lint:lockfile && npm run lint:deps", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "postlicchk": "npm run doc", - "doc": "jsdoc --pedantic --recurse -c jsdoc.json", - "test": "nyc mocha --recursive -t 10000", - "test:updateSnapshots": "nyc mocha --updateSnapshot --recursive -t 10000", - "test:watch": "nyc mocha --watch --recursive -t 10000", - "mocha": "mocha --recursive -t 10000", - "nyc": "nyc mocha --recursive -t 10000", - "build": "npm run build:types", - "postbuild": "npm run webpack", - "webpack": "webpack --config webpack.config.js --mode production", - "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --esModuleInterop --outDir types", - "lint:deps": "syncpack lint", - "lint:deps:fix": "syncpack fix", - "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https" - }, - "mocha": { - "require": "mocha-expect-snapshot" - }, - "repository": { - "type": "git", - "url": "https://github.com/accordproject/concerto-codegen.git", - "directory": "packages/concerto-codegen" - }, - "keywords": [ - "concerto", - "codegen", - "modeling" + "name": "@accordproject/concerto-codegen", + "version": "3.31.3", + "description": "Code Generation for the Concerto Modeling Language", + "homepage": "https://github.com/accordproject/concerto", + "engines": { + "node": ">=18", + "npm": ">=6" + }, + "main": "index.js", + "browser": "umd/concerto-codegen.js", + "typings": "types/index.d.ts", + "scripts": { + "coverage": "node ./scripts/coverage.js \"packages/concerto-*\" && nyc report -t coverage --cwd . --report-dir coverage --reporter=lcov && cat ./coverage/lcov.info", + "prepublishOnly": "npm run webpack", + "format": "prettier --write .", + "format:check": "prettier --check .", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "postlicchk": "npm run doc", + "doc": "jsdoc --pedantic --recurse -c jsdoc.json", + "test": "nyc mocha --recursive -t 10000", + "test:updateSnapshots": "nyc mocha --updateSnapshot --recursive -t 10000", + "test:watch": "nyc mocha --watch --recursive -t 10000", + "mocha": "mocha --recursive -t 10000", + "nyc": "nyc mocha --recursive -t 10000", + "build": "npm run build:types", + "postbuild": "npm run webpack", + "webpack": "webpack --config webpack.config.js --mode production", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --esModuleInterop --outDir types", + "lint:deps": "syncpack lint", + "lint:deps:fix": "syncpack fix", + "lint:lockfile": "lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https", + "preinstall": "npm run lint:lockfile && npm run lint:deps" + }, + "mocha": { + "require": "mocha-expect-snapshot" + }, + "repository": { + "type": "git", + "url": "https://github.com/accordproject/concerto-codegen.git", + "directory": "packages/concerto-codegen" + }, + "keywords": [ + "concerto", + "codegen", + "modeling" + ], + "author": "accordproject.org", + "license": "Apache-2.0", + "devDependencies": { + "@accordproject/concerto-cto": "3.25.7", + "@babel/preset-env": "7.16.11", + "@types/webgl-ext": "0.0.37", + "babel-loader": "8.2.3", + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-things": "0.2.0", + "eslint": "8.2.0", + "eslint-config-prettier": "10.1.8", + "expect": "30.2.0", + "jsdoc": "4.0.3", + "json-schema-to-ts": "3.1.1", + "license-check-and-add": "2.3.6", + "lockfile-lint": "4.14.1", + "mocha": "11.3.0", + "mocha-expect-snapshot": "8.0.0", + "moxios": "0.4.0", + "node-polyfill-webpack-plugin": "4.1.0", + "nunjucks": "3.2.4", + "nyc": "15.1.0", + "openapi-typescript": "7.13.0", + "prettier": "3.8.0", + "sinon": "12.0.0", + "sinon-chai": "3.7.0", + "syncpack": "14.0.0-alpha.32", + "tmp-promise": "3.0.2", + "ts-json-schema-generator": "2.3.0", + "typescript": "5.7.2", + "webpack": "5.105.0", + "webpack-cli": "4.9.1" + }, + "dependencies": { + "@accordproject/concerto-core": "3.25.0", + "@accordproject/concerto-util": "3.25.0", + "@accordproject/concerto-vocabulary": "3.25.0", + "@openapi-contrib/openapi-schema-to-json-schema": "4.0.0", + "ajv": "8.18.0", + "ajv-formats": "3.0.1", + "camelcase": "6.3.0", + "debug": "4.3.4", + "get-value": "3.0.1", + "json-schema-migrate": "2.0.0", + "pluralize": "8.0.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "HEADER", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "api.txt", + "composer-logs", + "coverage", + "index.d.ts", + "./system", + "./introspect/parser.js", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" ], - "author": "accordproject.org", - "license": "Apache-2.0", - "devDependencies": { - "@accordproject/concerto-cto": "3.25.7", - "@babel/preset-env": "7.16.11", - "@types/webgl-ext": "0.0.37", - "babel-loader": "8.2.3", - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-things": "0.2.0", - "eslint": "8.2.0", - "expect": "30.2.0", - "jsdoc": "4.0.3", - "json-schema-to-ts": "3.1.1", - "license-check-and-add": "2.3.6", - "lockfile-lint": "4.14.1", - "mocha": "11.3.0", - "mocha-expect-snapshot": "8.0.0", - "moxios": "0.4.0", - "node-polyfill-webpack-plugin": "4.1.0", - "nunjucks": "3.2.4", - "nyc": "15.1.0", - "openapi-typescript": "7.13.0", - "sinon": "12.0.0", - "sinon-chai": "3.7.0", - "syncpack": "14.0.0-alpha.32", - "tmp-promise": "3.0.2", - "ts-json-schema-generator": "2.3.0", - "typescript": "5.7.2", - "webpack": "5.105.0", - "webpack-cli": "4.9.1" - }, - "dependencies": { - "@accordproject/concerto-core": "3.25.0", - "@accordproject/concerto-util": "3.25.0", - "@accordproject/concerto-vocabulary": "3.25.0", - "@openapi-contrib/openapi-schema-to-json-schema": "4.0.0", - "ajv": "8.18.0", - "ajv-formats": "3.0.1", - "camelcase": "6.3.0", - "debug": "4.3.4", - "get-value": "3.0.1", - "json-schema-migrate": "2.0.0", - "pluralize": "8.0.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "HEADER", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "api.txt", - "composer-logs", - "coverage", - "index.d.ts", - "./system", - "./introspect/parser.js", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" - ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz" - ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " - } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "./HEADER.md" - } + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "lib/codegen/codegen.js" - ], - "all": true, - "check-coverage": true, - "statements": 98, - "branches": 96, - "functions": 98, - "lines": 98 + }, + "md": { + "file": "./HEADER.md" + } } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "lib/codegen/codegen.js" + ], + "all": true, + "check-coverage": true, + "statements": 98, + "branches": 96, + "functions": 98, + "lines": 98 + } }