Skip to content

Commit ac39427

Browse files
committed
chore(developer): add eslint devDependency for kmc
Adds eslint, effectively disabled, to infrastructure for all of kmc. Note that eslintNoNodeImports.js will be used in the next commit, for verifying #8644.
1 parent 9d75e02 commit ac39427

18 files changed

+2371
-70
lines changed

.eslintrc.cjs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
// TODO: we need to move to the following, but this gets us started with infrastructure without breaking our build
9+
// extends: [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"],
10+
extends: ["plugin:@typescript-eslint/eslint-recommended"],
11+
parser: "@typescript-eslint/parser",
12+
parserOptions: {
13+
ecmaVersion: "latest",
14+
sourceType: "module",
15+
},
16+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
// Prevents use of Node's standard imports so we can make sure we can also run
3+
// on web. Comes from eslint docs but not sure how reliable it is:
4+
// https://eslint.org/docs/latest/rules/no-restricted-imports
5+
// TODO: Consider moving to
6+
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md
7+
// which uses https://npmjs.com/package/is-core-module
8+
rules: {
9+
"no-restricted-imports": ["error",
10+
"assert","buffer","child_process","cluster","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","smalloc","stream","string_decoder","sys","timers","tls","tracing","tty","url","util","vm","zlib"
11+
],
12+
},
13+
};

developer/src/.eslintrc.cjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
ignorePatterns: ["**/build/**/*", "**/coverage/**/*"],
3+
rules: {},
4+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
parserOptions: {
3+
project: ["./tsconfig.json", "./test/tsconfig.json"],
4+
},
5+
ignorePatterns: ["test/fixtures/**/*"],
6+
overrides: [
7+
{
8+
files:"src/**/*.ts",
9+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
10+
}
11+
],
12+
rules: {
13+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
14+
},
15+
};

developer/src/kmc-keyboard/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
],
1717
"scripts": {
1818
"build": "tsc -b",
19-
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
19+
"lint": "eslint .",
20+
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
2021
"prepublishOnly": "npm run build"
2122
},
2223
"author": "Marc Durdin <[email protected]> (https://github.com/mcdurdin)",

developer/src/kmc-kmn/.eslintrc.cjs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
parserOptions: {
3+
project: ["./tsconfig.json", "./test/tsconfig.json"],
4+
},
5+
overrides: [
6+
{
7+
files:"src/**/*.ts",
8+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
9+
}
10+
],
11+
rules: {
12+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
13+
},
14+
};

developer/src/kmc-kmn/build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fi
6464

6565
if builder_start_action test; then
6666
tsc --build test/
67+
npm run lint
6768
c8 --reporter=lcov --reporter=text mocha "${builder_extra_params[@]}"
6869
builder_finish_action success test
6970
fi

developer/src/kmc-kmn/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"scripts": {
1919
"build": "tsc -b",
20-
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
20+
"lint": "eslint .",
21+
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
2122
"prepublishOnly": "npm run build"
2223
},
2324
"author": "Marc Durdin <[email protected]> (https://github.com/mcdurdin)",
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
parserOptions: {
3+
project: ["./tsconfig.json", "./test/tsconfig.json"],
4+
},
5+
overrides: [
6+
{
7+
files:"src/**/*.ts",
8+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
9+
}
10+
],
11+
rules: {
12+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
13+
},
14+
};

developer/src/kmc-model-info/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"scripts": {
1919
"build": "tsc -b",
20-
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
20+
"lint": "eslint .",
21+
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
2122
"prepublishOnly": "npm run build"
2223
},
2324
"author": "Marc Durdin <[email protected]> (https://github.com/mcdurdin)",

developer/src/kmc-model/.eslintrc.cjs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
parserOptions: {
3+
project: ["./tsconfig.json", "./test/tsconfig.json"],
4+
},
5+
ignorePatterns: [
6+
"test/fixtures/**/*",
7+
"tools/*" /* TODO: linting on tools */,
8+
],
9+
overrides: [
10+
{
11+
files: "src/**/*.ts",
12+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
13+
},
14+
],
15+
rules: {
16+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
17+
"no-var": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
18+
},
19+
};

developer/src/kmc-model/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"scripts": {
1919
"build": "tsc -b && npm run build-cjs",
2020
"build-cjs": "esbuild build/src/lexical-model-compiler.js --bundle --platform=node --external:../../node_modules/* > build/cjs-src/lexical-model-compiler.cjs",
21-
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
21+
"lint": "eslint .",
22+
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
2223
"prepublishOnly": "npm run build"
2324
},
2425
"author": "Marc Durdin <[email protected]> (https://github.com/mcdurdin)",
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
parserOptions: {
3+
project: ["./tsconfig.json", "./test/tsconfig.json"],
4+
},
5+
ignorePatterns: ["test/fixtures/**/*"],
6+
overrides: [
7+
{
8+
files:"src/**/*.ts",
9+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
10+
}
11+
],
12+
rules: {
13+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
14+
},
15+
};

developer/src/kmc-package/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
],
1717
"scripts": {
1818
"build": "tsc -b",
19-
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
19+
"lint": "eslint .",
20+
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
2021
"coverage": "npm test",
2122
"prepublishOnly": "npm run build"
2223
},

developer/src/kmc/.eslintrc.cjs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
3+
parserOptions: {
4+
project: ["./tsconfig.json", "./test/tsconfig.json"],
5+
},
6+
rules: {
7+
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
8+
},
9+
};

developer/src/kmc/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"bundle-kmlmc": "esbuild build/src/kmlmc.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmc.cjs",
1717
"bundle-kmlmi": "esbuild build/src/kmlmi.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmi.cjs",
1818
"bundle-kmlmp": "esbuild build/src/kmlmp.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmp.cjs",
19-
"test": "cd test && tsc -b && cd .. && mocha",
19+
"test": "eslint . && cd test && tsc -b && cd .. && mocha",
2020
"prepublishOnly": "npm run build"
2121
},
2222
"type": "module",

0 commit comments

Comments
 (0)