Skip to content

Commit

Permalink
Merge branch 'main' into build/exports-order
Browse files Browse the repository at this point in the history
  • Loading branch information
smaye81 authored Dec 4, 2023
2 parents 55cad98 + b331196 commit eba5b4b
Show file tree
Hide file tree
Showing 286 changed files with 3,581 additions and 1,040 deletions.
117 changes: 57 additions & 60 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

const {readdirSync, existsSync} = require("fs");
const {join} = require("path");
const { readdirSync, existsSync } = require("fs");
const { join } = require("path");

module.exports = {
env: {
Expand All @@ -27,79 +27,76 @@ module.exports = {
"packages/*/.tmp/**",
"node_modules/**",
],
plugins: ["@typescript-eslint", "node", "import"],
plugins: ["@typescript-eslint", "n", "import"],
// Rules and settings that do not require a non-default parser
extends: [
"eslint:recommended",
],
extends: ["eslint:recommended"],
rules: {
"no-console": "error",
"import/no-duplicates": "off",
},
settings: {},
overrides: [
...readdirSync("packages", {withFileTypes: true})
.filter(entry => entry.isDirectory())
.map(entry => join("packages", entry.name))
.filter(dir => existsSync(join(dir, "tsconfig.json")))
.map(dir => {
return {
files: [join(dir, "src/**/*.ts")],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: dir,
},
settings: {
"import/resolver": {
"typescript": {
"project": "packages/*/tsconfig.json",
}
}
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
],
rules: {
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/array-type": "off", // we use complex typings, where Array is actually more readable than T[]
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-base-to-string": "error",
"import/no-cycle": "error",
"import/no-duplicates": "off",
...readdirSync("packages", { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => join("packages", entry.name))
.filter((dir) => existsSync(join(dir, "tsconfig.json")))
.map((dir) => {
return {
files: [join(dir, "src/**/*.ts")],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: dir,
},
settings: {
"import/resolver": {
typescript: {
project: "packages/*/tsconfig.json",
},
},
};
}),
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript",
],
rules: {
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/array-type": "off", // we use complex typings, where Array is actually more readable than T[]
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare":
"error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-base-to-string": "error",
"import/no-cycle": "error",
"import/no-duplicates": "off",
},
};
}),
// For scripts and configurations, use Node.js rules
{
files: ["**/*.{js,mjs,cjs}"],
parserOptions: {
ecmaVersion: 13, // ES2022 - https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
},
extends: ["eslint:recommended", "plugin:node/recommended"],
extends: ["eslint:recommended", "plugin:n/recommended"],
rules: {
"node/shebang": "off", // this plugin only determines shebang necessary for files that are in a package.json "bin" field
"node/exports-style": ["error", "module.exports"],
"node/file-extension-in-import": ["error", "always"],
"node/prefer-global/buffer": ["error", "always"],
"node/prefer-global/console": ["error", "always"],
"node/prefer-global/process": ["error", "always"],
"node/prefer-global/url-search-params": ["error", "always"],
"node/prefer-global/url": ["error", "always"],
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error",
"no-process-exit": "off",
"node/no-unsupported-features/node-builtins": ["error", {
"version": ">=16.0.0",
"ignores": []
}]
"n/shebang": "off", // this rule reports _any_ shebang outside of an npm binary as an error
"n/prefer-global/process": "off",
"n/no-process-exit": "off",
"n/exports-style": ["error", "module.exports"],
"n/file-extension-in-import": ["error", "always"],
"n/prefer-global/buffer": ["error", "always"],
"n/prefer-global/console": ["error", "always"],
"n/prefer-global/url-search-params": ["error", "always"],
"n/prefer-global/url": ["error", "always"],
"n/prefer-promises/dns": "error",
"n/prefer-promises/fs": "error",
"n/no-unsupported-features/node-builtins": "error",
"n/no-unsupported-features/es-syntax": "error",
},
},
],
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ on:
jobs:
ci:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: checkout
uses: actions/checkout@v4
- name: Cache
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/node_modules
/packages/*/bin
/packages/*/.tmp
/packages/*/dist
/packages/*/src/gen
/packages/protobuf/src/google
Expand Down
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ help: ## Describe useful make targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}'

.PHONY: all
all: build test format lint bench bootstrapwkt ## build, test, format, lint, bench, and bootstrapwkt (default)
all: build test format lint bench bootstrap ## build, test, format, lint, bench, and bootstrap (default)

.PHONY: ci
ci: build test-protobuf test-protoplugin test-conformance format lint bench bootstrapwkt #
ci: build test-protobuf test-protoplugin test-protoplugin-example test-conformance format lint bench bootstrap #
$(MAKE) checkdiff

.PHONY: clean
Expand Down Expand Up @@ -144,7 +144,7 @@ lint: node_modules $(BUILD)/protobuf $(BUILD)/protobuf-test $(BUILD)/protobuf-co

.PHONY: format
format: node_modules ## Format all files, adding license headers
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css,mjs}' --log-level error
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css,mjs,cjs}' --log-level error
npx license-header --ignore packages/protobuf/src/google/varint.ts

.PHONY: bench
Expand All @@ -155,11 +155,10 @@ bench: node_modules $(GEN)/protobuf-bench $(BUILD)/protobuf ## Benchmark code si
perf: $(BUILD)/protobuf-test
npm run -w packages/protobuf-test perf

.PHONY: bootstrapwkt
bootstrapwkt: $(BUILD)/upstream-protobuf $(BUILD)/protoc-gen-es node_modules ## Generate the well-known types in @bufbuild/protobuf
npm run -w packages/protobuf bootstrap
@# If the generated code differs, use it, and run tests again
npm run -w packages/protobuf bootstrap-diff || $(MAKE) build test format lint
.PHONY: bootstrap
bootstrap: $(BUILD)/upstream-protobuf $(BUILD)/protoc-gen-es node_modules ## Bootstrap well-known types and edition features-set defaults in @bufbuild/protobuf from upstream protobuf
npm run -w packages/protobuf bootstrap:wkt
npm run -w packages/protobuf bootstrap:featureset-defaults

.PHONY: setversion
setversion: ## Set a new version in for the project, i.e. make setversion SET_VERSION=1.2.3
Expand Down
Loading

0 comments on commit eba5b4b

Please sign in to comment.