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.
This commit is contained in:
Marc Durdin 2023-04-25 13:44:56 +07:00
parent 9d75e0265a
commit ac39427f60
18 changed files with 2315 additions and 14 deletions

16
.eslintrc.cjs Normal file
View file

@ -0,0 +1,16 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
// TODO: we need to move to the following, but this gets us started with infrastructure without breaking our build
// extends: [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"],
extends: ["plugin:@typescript-eslint/eslint-recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
};

View file

@ -0,0 +1,13 @@
module.exports = {
// Prevents use of Node's standard imports so we can make sure we can also run
// on web. Comes from eslint docs but not sure how reliable it is:
// https://eslint.org/docs/latest/rules/no-restricted-imports
// TODO: Consider moving to
// https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md
// which uses https://npmjs.com/package/is-core-module
rules: {
"no-restricted-imports": ["error",
"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"
],
},
};

View file

@ -0,0 +1,4 @@
module.exports = {
ignorePatterns: ["**/build/**/*", "**/coverage/**/*"],
rules: {},
};

View file

@ -0,0 +1,15 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
ignorePatterns: ["test/fixtures/**/*"],
overrides: [
{
files:"src/**/*.ts",
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
}
],
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -16,7 +16,8 @@
],
"scripts": {
"build": "tsc -b",
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"prepublishOnly": "npm run build"
},
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",

View file

@ -0,0 +1,14 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
overrides: [
{
files:"src/**/*.ts",
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
}
],
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -64,6 +64,7 @@ fi
if builder_start_action test; then
tsc --build test/
npm run lint
c8 --reporter=lcov --reporter=text mocha "${builder_extra_params[@]}"
builder_finish_action success test
fi

View file

@ -17,7 +17,8 @@
],
"scripts": {
"build": "tsc -b",
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"prepublishOnly": "npm run build"
},
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",

View file

@ -0,0 +1,14 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
overrides: [
{
files:"src/**/*.ts",
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
}
],
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -17,7 +17,8 @@
],
"scripts": {
"build": "tsc -b",
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"prepublishOnly": "npm run build"
},
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",

View file

@ -0,0 +1,19 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
ignorePatterns: [
"test/fixtures/**/*",
"tools/*" /* TODO: linting on tools */,
],
overrides: [
{
files: "src/**/*.ts",
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
},
],
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
"no-var": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -18,7 +18,8 @@
"scripts": {
"build": "tsc -b && npm run build-cjs",
"build-cjs": "esbuild build/src/lexical-model-compiler.js --bundle --platform=node --external:../../node_modules/* > build/cjs-src/lexical-model-compiler.cjs",
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"prepublishOnly": "npm run build"
},
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",

View file

@ -0,0 +1,15 @@
module.exports = {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
ignorePatterns: ["test/fixtures/**/*"],
overrides: [
{
files:"src/**/*.ts",
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
}
],
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -16,7 +16,8 @@
],
"scripts": {
"build": "tsc -b",
"test": "cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha",
"coverage": "npm test",
"prepublishOnly": "npm run build"
},

View file

@ -0,0 +1,9 @@
module.exports = {
// extends: ["../../../common/web/eslint/eslintNoNodeImports.js"],
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json"],
},
rules: {
"prefer-const": "off", // TODO: enable this once infrastructure is in place and cleanup the problem cases
},
};

View file

@ -16,7 +16,7 @@
"bundle-kmlmc": "esbuild build/src/kmlmc.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmc.cjs",
"bundle-kmlmi": "esbuild build/src/kmlmi.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmi.cjs",
"bundle-kmlmp": "esbuild build/src/kmlmp.js --bundle --platform=node --target=es2022 > build/cjs-src/kmlmp.cjs",
"test": "cd test && tsc -b && cd .. && mocha",
"test": "eslint . && cd test && tsc -b && cd .. && mocha",
"prepublishOnly": "npm run build"
},
"type": "module",

2184
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,13 @@
"mocha": "^10.0.0",
"mocha-teamcity-reporter": "^4.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"eslint": "^8.39.0",
"eslint-config-standard-with-typescript": "^34.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1"
},
"scripts": {},
"workspaces": [