Merge pull request #3421 from bobrippling/feat/generate-js-ignores

Linting: generate js ignores automatically
pull/3423/head
Rob Pilling 2024-05-18 10:47:11 +01:00 committed by GitHub
commit 597e9639a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 252 additions and 248 deletions

View File

@ -4,23 +4,3 @@ apps/gipy/pkg/gps.js
# Needs to be ignored because it includes broken JS
apps/health/chart.min.js
# Generated from TS files that have already been linted
apps/btadv/app.js
apps/clkinfostopw/clkinfo.js
apps/ctrlpad/main.js
apps/drained/app.js
apps/drained/boot.js
apps/drained/settings.js
apps/folderlaunch/app.js
apps/folderlaunch/configLoad.js
apps/folderlaunch/settings.js
apps/folderlaunch/types.d.js
apps/popconlaunch/boot.js
apps/popconlaunch/settings.js
apps/rep/app.js
apps/rep/settings.js
apps/widChargingStatus/widget.js
apps/widbtstates/widget.js
apps/widhid/wid.js
modules/ble_advert.js

View File

@ -1,4 +1,26 @@
const lintExemptions = require("./lint_exemptions.js");
const lintExemptions = require("./apps/lint_exemptions.js");
const fs = require("fs");
const path = require("path");
function findGeneratedJS(roots) {
function* listFiles(dir, allow) {
for (const f of fs.readdirSync(dir)) {
const filepath = path.join(dir, f);
const stat = fs.statSync(filepath);
if (stat.isDirectory()) {
yield* listFiles(filepath, allow);
} else if(allow(filepath)) {
yield filepath;
}
}
}
return roots.flatMap(root =>
[...listFiles(root, f => f.endsWith(".ts"))]
.map(f => f.replace(/\.ts$/, ".js"))
);
}
module.exports = {
"env": {
@ -213,7 +235,7 @@ module.exports = {
"@typescript-eslint/no-delete-var": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" } ],
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
}
},
@ -222,4 +244,5 @@ module.exports = {
rules: Object.fromEntries(rules.map(rule => [rule, "off"])),
})),
],
ignorePatterns: findGeneratedJS(["apps/", "modules/"]),
}

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ const exemptionsFilePath = "../apps/lint_exemptions.js";
const exemptions = (await import(exemptionsFilePath)).default;
for (const filePath of Object.keys(exemptions)) {
const fileContents = await fs.readFile(`apps/${filePath}`, "utf8");
const fileContents = await fs.readFile(filePath, "utf8");
const currentHash = await hashContents(fileContents);
if (exemptions[filePath].hash !== currentHash) {
delete exemptions[filePath];

View File

@ -1,4 +1,4 @@
declare var exports: any;
declare let exports: any;
type BleAdvert = { [key: string | number]: number[] };
type BangleWithAdvert = (typeof Bangle) & { bleAdvert?: BleAdvert | BleAdvert[]; };
@ -8,8 +8,8 @@ exports.set = (id: string | number, advert: number[], options?: SetAdvertisingOp
const bangle = Bangle as BangleWithAdvert;
if(Array.isArray(bangle.bleAdvert)){
var found = false;
for(var ad of bangle.bleAdvert){
let found = false;
for(let ad of bangle.bleAdvert){
if(ad[id]){
ad[id] = advert;
found = true;
@ -33,12 +33,13 @@ exports.remove = (id: string | number, options?: SetAdvertisingOptions) => {
const bangle = Bangle as BangleWithAdvert;
if(Array.isArray(bangle.bleAdvert)){
var i = 0;
for(var ad of bangle.bleAdvert){
let i = 0;
for(const ad of bangle.bleAdvert){
if(ad[id]){
delete ad[id];
var empty = true;
for(var _ in ad){
let empty = true;
// eslint-disable-next-line no-unused-vars
for(const _ in ad){
empty = false;
break;
}