From a11a36e50f1e41c6df3c2436c097ab63ca2cd458 Mon Sep 17 00:00:00 2001 From: Rahul-R79 Date: Wed, 21 Jan 2026 21:53:14 +0530 Subject: [PATCH 1/2] feat: setup prettier infrastructure Signed-off-by: Rahul-R79 --- .eslintrc.yml | 77 +++++------ .prettierignore | 7 + .prettierrc | 7 + .vscode/settings.json | 13 ++ package-lock.json | 45 +++++- package.json | 308 +++++++++++++++++++++--------------------- 6 files changed, 256 insertions(+), 201 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 .vscode/settings.json diff --git a/.eslintrc.yml b/.eslintrc.yml index cff713bc..e422765f 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,47 +1,36 @@ env: - es6: true - node: true - mocha: true -extends: 'eslint:recommended' + es6: true + node: true + mocha: true +extends: + - 'eslint:recommended' + - 'prettier' parserOptions: - ecmaVersion: 13 - sourceType: script + ecmaVersion: 13 + sourceType: script rules: - indent: - - error - - 4 - linebreak-style: - - warn - - unix - quotes: - - error - - single - semi: - - error - - always - no-unused-vars: - - error - - args: none - no-console: warn - curly: error - eqeqeq: error - no-throw-literal: error - strict: error - no-var: error - dot-notation: error - no-tabs: error - no-trailing-spaces: 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 - valid-jsdoc: - - error - - requireReturn: false - yoda: error + no-unused-vars: + - error + - args: none + no-console: warn + curly: error + eqeqeq: error + no-throw-literal: error + strict: error + no-var: error + dot-notation: error + no-tabs: error + #HQ: We keep no-tabs because Prettier also enforces spaces. + # no-use-before-define: error + no-useless-call: error + no-with: error + require-jsdoc: + - error + - require: + ClassDeclaration: true + MethodDefinition: true + FunctionDeclaration: true + valid-jsdoc: + - error + - requireReturn: false + yoda: error diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b332714c --- /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 00000000..158b44b6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "printWidth": 100, + "tabWidth": 2, + "trailingComma": "none", + "semi": true +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..da2fca21 --- /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-lock.json b/package-lock.json index 52daff30..14be2636 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "chai-as-promised": "7.1.1", "chai-things": "0.2.0", "eslint": "8.2.0", + "eslint-config-prettier": "10.1.8", "expect": "29.1.0", "jsdoc": "4.0.3", "license-check-and-add": "2.3.6", @@ -41,6 +42,7 @@ "node-polyfill-webpack-plugin": "3.0.0", "nunjucks": "3.2.4", "nyc": "15.1.0", + "prettier": "3.8.0", "sinon": "12.0.0", "sinon-chai": "3.7.0", "syncpack": "14.0.0-alpha.32", @@ -4854,6 +4856,22 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-scope": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", @@ -7674,6 +7692,21 @@ "node": ">= 14.0.0" } }, + "node_modules/openapi-typescript/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "license": "MIT", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/openapi-typescript/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", @@ -8140,14 +8173,16 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.0.tgz", + "integrity": "sha512-yEPsovQfpxYfgWNhCfECjG5AQaO+K3dp6XERmOepyPDVqcJm+bjyCVO3pmU+nAPe0N5dDvekfGezt/EIiRe1TA==", + "dev": true, + "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index d41f7678..42ea623b 100644 --- a/package.json +++ b/package.json @@ -1,157 +1,161 @@ { - "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 .", - "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 --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" + "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 --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.0", + "@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": "29.1.0", + "jsdoc": "4.0.3", + "license-check-and-add": "2.3.6", + "lockfile-lint": "4.14.1", + "mocha": "10.8.2", + "mocha-expect-snapshot": "6.2.0", + "moxios": "0.4.0", + "node-polyfill-webpack-plugin": "3.0.0", + "nunjucks": "3.2.4", + "nyc": "15.1.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.94.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": "5.1.0", + "ajv": "8.17.1", + "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.0", - "@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": "29.1.0", - "jsdoc": "4.0.3", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "mocha-expect-snapshot": "6.2.0", - "moxios": "0.4.0", - "node-polyfill-webpack-plugin": "3.0.0", - "nunjucks": "3.2.4", - "nyc": "15.1.0", - "sinon": "12.0.0", - "sinon-chai": "3.7.0", - "tmp-promise": "3.0.2", - "ts-json-schema-generator": "2.3.0", - "typescript": "5.7.2", - "webpack": "5.94.0", - "webpack-cli": "4.9.1", - "lockfile-lint": "4.14.1", - "syncpack": "14.0.0-alpha.32" - }, - "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": "5.1.0", - "ajv-formats": "3.0.1", - "ajv": "8.17.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 + } } From 9f325c96a1113ca99b3665701e6587e2d1f04ee0 Mon Sep 17 00:00:00 2001 From: Rahul-R79 Date: Tue, 10 Mar 2026 23:36:57 +0530 Subject: [PATCH 2/2] chore: update eslintrc with 4-space indent and prettier extension, set tabWidth to 4 Signed-off-by: Rahul-R79 --- .eslintrc.yml | 77 ++++++++++++++++++++++++++++++--------------------- .prettierrc | 2 +- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index e422765f..158246f4 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,36 +1,49 @@ env: - es6: true - node: true - mocha: true + es6: true + node: true + mocha: true extends: - - 'eslint:recommended' - - 'prettier' + - 'eslint:recommended' + - 'prettier' parserOptions: - ecmaVersion: 13 - sourceType: script + ecmaVersion: 13 + sourceType: script rules: - no-unused-vars: - - error - - args: none - no-console: warn - curly: error - eqeqeq: error - no-throw-literal: error - strict: error - no-var: error - dot-notation: error - no-tabs: error - #HQ: We keep no-tabs because Prettier also enforces spaces. - # no-use-before-define: error - no-useless-call: error - no-with: error - require-jsdoc: - - error - - require: - ClassDeclaration: true - MethodDefinition: true - FunctionDeclaration: true - valid-jsdoc: - - error - - requireReturn: false - yoda: error + indent: + - error + - 4 + linebreak-style: + - error + - unix + quotes: + - error + - single + semi: + - error + - always + no-unused-vars: + - error + - args: none + no-console: warn + curly: error + eqeqeq: error + no-throw-literal: error + strict: error + no-var: error + dot-notation: error + no-tabs: error + no-trailing-spaces: 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 + valid-jsdoc: + - error + - requireReturn: false + yoda: error diff --git a/.prettierrc b/.prettierrc index 158b44b6..03409a90 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,7 +1,7 @@ { "singleQuote": true, "printWidth": 100, - "tabWidth": 2, + "tabWidth": 4, "trailingComma": "none", "semi": true }