Skip to content

Commit 381f10b

Browse files
committed
prettier and lint
1 parent 9f34ffd commit 381f10b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2912
-1754
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: LLVM
2+
ColumnLimit: 120

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
FROM mcr.microsoft.com/devcontainers/javascript-node:22
22

33
RUN apt-get update
4-
RUN apt-get install -y openjdk-17-jdk gdb
4+
RUN apt-get install -y openjdk-17-jdk gdb clang-format

.github/workflows/master.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ jobs:
1919
node-version: ${{ matrix.nodeVersion }}
2020
- name: npm ci
2121
run: npm ci
22+
- name: npm run format-cpp
23+
run: npm run format-cpp
24+
- name: npm run format
25+
run: npm run format
26+
- name: npm run lint
27+
run: npm run lint
2228
- name: Unit test
2329
run: npm test

.github/workflows/pull-requests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ jobs:
2020
node-version: ${{ matrix.nodeVersion }}
2121
- name: npm ci
2222
run: npm ci
23+
- name: npm run format-cpp
24+
run: npm run format-cpp
25+
- name: npm run format
26+
run: npm run format
27+
- name: npm run lint
28+
run: npm run lint
2329
- name: Unit test
2430
run: npm test

.prettierignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**/*.cpp
2+
**/*.h
3+
**/*.ppt
4+
**/*.jar
5+
**/*.class
6+
**/*.java
7+
**/*.sh
8+
**/*.html
9+
**/*.json
10+
**/*.png
11+
**/*.md
12+
**/*.rule
13+
**/*.rules
14+
**/*.gyp
15+
**/*.yml
16+
**/Dockerfile
17+
.clang-format
18+
.prettierrc
19+
.prettierignore
20+
.npmignore
21+
.gitignore
22+
.gitattributes
23+
LICENSE

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"parser": "typescript",
3+
"semi": true,
4+
"singleQuote": false,
5+
"tabWidth": 2,
6+
"trailingComma": "es5",
7+
"useTabs": false,
8+
"printWidth": 120,
9+
"endOfLine": "lf"
10+
}

eslint.config.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import { defineConfig } from "eslint/config";
4+
5+
export default defineConfig([
6+
{
7+
files: ["**/*.{js,mjs,cjs}"],
8+
plugins: { js },
9+
extends: ["js/recommended"],
10+
languageOptions: { globals: globals.node },
11+
rules: {
12+
"no-var": ["error"],
13+
curly: ["error"],
14+
"no-unused-vars": [
15+
"warn",
16+
{
17+
varsIgnorePattern: "^_",
18+
argsIgnorePattern: "^_",
19+
caughtErrorsIgnorePattern: "^_",
20+
destructuredArrayIgnorePattern: "^_",
21+
},
22+
],
23+
},
24+
},
25+
]);

examples/lucene/example.js

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,74 @@
11
#!/usr/bin/env node
22

3-
var java = require("../../");
3+
const java = require("../../");
44
java.classpath.push("./lucene-lib/lucene-core-7.4.0.jar");
55
java.classpath.push("./lucene-lib/lucene-analyzers-common-7.4.0.jar");
66
java.classpath.push("./lucene-lib/lucene-queryparser-7.4.0.jar");
77

8+
const idx = java.newInstanceSync("org.apache.lucene.store.RAMDirectory");
9+
const analyzer = java.newInstanceSync("org.apache.lucene.analysis.standard.StandardAnalyzer");
10+
const writerConfig = java.newInstanceSync("org.apache.lucene.index.IndexWriterConfig", analyzer);
11+
const writer = java.newInstanceSync("org.apache.lucene.index.IndexWriter", idx, writerConfig);
12+
const queryParser = java.newInstanceSync("org.apache.lucene.queryparser.classic.QueryParser", "content", analyzer);
813

9-
var idx = java.newInstanceSync("org.apache.lucene.store.RAMDirectory");
10-
var analyzer = java.newInstanceSync("org.apache.lucene.analysis.standard.StandardAnalyzer");
11-
var writerConfig = java.newInstanceSync("org.apache.lucene.index.IndexWriterConfig", analyzer);
12-
var writer = java.newInstanceSync("org.apache.lucene.index.IndexWriter", idx, writerConfig);
13-
var queryParser = java.newInstanceSync("org.apache.lucene.queryparser.classic.QueryParser", "content", analyzer);
14-
15-
writer.addDocumentSync(createDocument("Theodore Roosevelt",
16-
"It behooves every man to remember that the work of the " +
17-
"critic, is of altogether secondary importance, and that, " +
18-
"in the end, progress is accomplished by the man who does " +
19-
"things."));
20-
writer.addDocumentSync(createDocument("Friedrich Hayek",
21-
"The case for individual freedom rests largely on the " +
22-
"recognition of the inevitable and universal ignorance " +
23-
"of all of us concerning a great many of the factors on " +
24-
"which the achievements of our ends and welfare depend."));
25-
writer.addDocumentSync(createDocument("Ayn Rand",
26-
"There is nothing to take a man's freedom away from " +
27-
"him, save other men. To be free, a man must be free " +
28-
"of his brothers."));
29-
writer.addDocumentSync(createDocument("Mohandas Gandhi",
30-
"Freedom is not worth having if it does not connote " +
31-
"freedom to err."));
14+
writer.addDocumentSync(
15+
createDocument(
16+
"Theodore Roosevelt",
17+
"It behooves every man to remember that the work of the " +
18+
"critic, is of altogether secondary importance, and that, " +
19+
"in the end, progress is accomplished by the man who does " +
20+
"things."
21+
)
22+
);
23+
writer.addDocumentSync(
24+
createDocument(
25+
"Friedrich Hayek",
26+
"The case for individual freedom rests largely on the " +
27+
"recognition of the inevitable and universal ignorance " +
28+
"of all of us concerning a great many of the factors on " +
29+
"which the achievements of our ends and welfare depend."
30+
)
31+
);
32+
writer.addDocumentSync(
33+
createDocument(
34+
"Ayn Rand",
35+
"There is nothing to take a man's freedom away from " +
36+
"him, save other men. To be free, a man must be free " +
37+
"of his brothers."
38+
)
39+
);
40+
writer.addDocumentSync(
41+
createDocument("Mohandas Gandhi", "Freedom is not worth having if it does not connote " + "freedom to err.")
42+
);
3243

3344
writer.closeSync();
3445

35-
var searcher = java.newInstanceSync("org.apache.lucene.search.IndexSearcher", java.callStaticMethodSync("org.apache.lucene.index.DirectoryReader", "open", idx));
46+
const searcher = java.newInstanceSync(
47+
"org.apache.lucene.search.IndexSearcher",
48+
java.callStaticMethodSync("org.apache.lucene.index.DirectoryReader", "open", idx)
49+
);
3650

3751
search(searcher, "freedom");
3852
search(searcher, "free");
3953
search(searcher, "progress or achievements");
4054

4155
function createDocument(title, content) {
42-
var fieldStoreYes = java.callStaticMethodSync("org.apache.lucene.document.Field$Store", "valueOf", "YES");
43-
var doc = java.newInstanceSync("org.apache.lucene.document.Document");
56+
const fieldStoreYes = java.callStaticMethodSync("org.apache.lucene.document.Field$Store", "valueOf", "YES");
57+
const doc = java.newInstanceSync("org.apache.lucene.document.Document");
4458
doc.addSync(java.newInstanceSync("org.apache.lucene.document.TextField", "title", title, fieldStoreYes));
4559
doc.addSync(java.newInstanceSync("org.apache.lucene.document.TextField", "content", content, fieldStoreYes));
4660
return doc;
4761
}
4862

4963
function search(searcher, queryString) {
50-
var query = queryParser.parseSync(queryString);
51-
var topDocs = searcher.searchSync(query, 10);
52-
53-
console.log("Found " + topDocs.totalHits + " hits for query \"" + queryString + "\".");
54-
var scoreDocs = topDocs.scoreDocs;
55-
for(var i=0; i<topDocs.scoreDocs.length; i++) {
56-
var docId = scoreDocs[i].doc;
57-
var doc = searcher.docSync(docId);
64+
const query = queryParser.parseSync(queryString);
65+
const topDocs = searcher.searchSync(query, 10);
66+
67+
console.log("Found " + topDocs.totalHits + ' hits for query "' + queryString + '".');
68+
const scoreDocs = topDocs.scoreDocs;
69+
for (let i = 0; i < topDocs.scoreDocs.length; i++) {
70+
const docId = scoreDocs[i].doc;
71+
const doc = searcher.docSync(docId);
5872
console.log(" " + (i + 1) + ". " + doc.getSync("title"));
5973
}
6074
}

examples/mixJavaAndNode/runMyClass.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env node
22

3-
var java = require("../../");
3+
const java = require("../../");
44
java.classpath.push("./src");
55

6-
var MyClass = java.import("com.nearinfinity.nodeJava.MyClass");
6+
const MyClass = java.import("com.nearinfinity.nodeJava.MyClass");
77

8-
var result = MyClass.addNumbersSync(1, 2);
8+
const result = MyClass.addNumbersSync(1, 2);
99
console.log(result);
10-
11-

findJavaHome.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
require('find-java-home')(function(err, home){
1+
require("find-java-home")(function (err, home) {
22
if (err || !home) {
3-
if (!err) err = Error('Unable to determine Java home location');
3+
if (!err) {
4+
err = Error("Unable to determine Java home location");
5+
}
46
process.exit(1);
57
}
68
process.stdout.write(home);

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
module.exports = require("./lib/nodeJavaBridge");

0 commit comments

Comments
 (0)