Skip to content

Commit

Permalink
Specify type assertion for JSON import (bldrs-ai#194)
Browse files Browse the repository at this point in the history
* Specify type assertion for JSON import

* bldrs/Share#194: Ensure all project JS files are checked by linter

* bldrs/Share#194: Add ESLint plugin (and configuration) for import assertions

* bldrs/Share#194: Fix lint errors in version generation logic
  • Loading branch information
oogali authored and OlegMoshkovich committed May 19, 2022
1 parent f0b8024 commit f50784b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ module.exports = {
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
plugins: [
'@babel/syntax-import-assertions'
],
},
ecmaFeatures: {
jsx: true,
},
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"copy-web-asm": "cp node_modules/web-ifc/*.wasm public/static/js",
"build": "yarn copy-web-asm && yarn clean && yarn new-version && node config/build.js",
"serve": "yarn build && node config/serve.js",
"lint": "yarn eslint `find src -name '*.jsx'` `find src -name '*.js'`",
"lint": "yarn eslint `find src -name '*.jsx'` `find src -name '*.[m]js'`",
"test": "jest",
"precommit": "yarn lint && yarn test",
"prepare": "husky install"
Expand All @@ -38,6 +38,8 @@
},
"devDependencies": {
"@alex_neo/jest-expect-message": "^1.0.5",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-syntax-import-assertions": "^7.16.7",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@pablo-mayrgundter/cookies.js": "^1.0.0",
Expand Down
14 changes: 8 additions & 6 deletions src/utils/version.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { execSync} from 'child_process';
import PkgInfo from '../../package.json';
import {execSync} from 'child_process'
import PkgInfo from '../../package.json' assert {type: "json"}

// https://stackoverflow.com/questions/24663175/how-can-i-inject-a-build-number-with-webpack
const __versionString__ = execSync('git rev-list HEAD --count').toString().trim();
const __versionString__ = execSync('git rev-list HEAD --count').toString().trim()
const version = PkgInfo.version.toString().replace(/-.*/, '')
PkgInfo.version = `${version}-r${__versionString__}`;
const PkgInfoStr = JSON.stringify(PkgInfo, null, ' ');
console.log(PkgInfoStr);

PkgInfo.version = `${version}-r${__versionString__}`
const PkgInfoStr = JSON.stringify(PkgInfo, null, ' ')

console.log(PkgInfoStr)
31 changes: 30 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
json5 "^2.1.2"
semver "^6.3.0"

"@babel/eslint-parser@^7.17.0":
version "7.17.0"
resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz#eabb24ad9f0afa80e5849f8240d0e5facc2d90d6"
integrity sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==
dependencies:
eslint-scope "^5.1.1"
eslint-visitor-keys "^2.1.0"
semver "^6.3.0"

"@babel/generator@^7.17.3", "@babel/generator@^7.7.2":
version "7.17.3"
resolved "https://registry.npmjs.org/@babel/generator/-/generator-7.17.3.tgz"
Expand Down Expand Up @@ -463,6 +472,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"

"@babel/plugin-syntax-import-assertions@^7.16.7":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.16.7.tgz#78288980e36f1614a4024d45937f4c8ca7185ac3"
integrity sha512-DoM/wsaMaDXpM2fa+QkZeqqfYs340WTY+boLRiZ7ckqt3PAFt1CdGmMXVniFCcN8RuStim2Z4Co3bIKdWjTXIQ==
dependencies:
"@babel/helper-plugin-utils" "^7.16.7"

"@babel/plugin-syntax-import-meta@^7.8.3":
version "7.10.4"
resolved "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz"
Expand Down Expand Up @@ -3167,6 +3183,14 @@ eslint-plugin-react@^7.28.0:
semver "^6.3.0"
string.prototype.matchall "^4.0.6"

eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==
dependencies:
esrecurse "^4.3.0"
estraverse "^4.1.1"

eslint-scope@^7.1.1:
version "7.1.1"
resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz"
Expand All @@ -3182,7 +3206,7 @@ eslint-utils@^3.0.0:
dependencies:
eslint-visitor-keys "^2.0.0"

eslint-visitor-keys@^2.0.0:
eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz"
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
Expand Down Expand Up @@ -3261,6 +3285,11 @@ esrecurse@^4.3.0:
dependencies:
estraverse "^5.2.0"

estraverse@^4.1.1:
version "4.3.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==

estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0:
version "5.3.0"
resolved "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz"
Expand Down

0 comments on commit f50784b

Please sign in to comment.