diff --git a/.editorconfig b/.editorconfig index 8c93bb5..34aa146 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,16 @@ root = true [*] +charset = utf-8 end_of_line = lf insert_final_newline = true +trim_trailing_whitespace = true -[*.js] +[*.{js,mjs,cjs,ts}] indent_style = space indent_size = 2 +max_line_length = 140 +quote_type = single [*.py] indent_style = space diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 4d0ed34..0000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "printWidth": 140, - "trailingComma": "all" -} diff --git a/eslint.config.mjs b/eslint.config.mjs index cfb90b1..fa46639 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -3,10 +3,10 @@ import ts from 'typescript-eslint'; import jsoncParser from 'jsonc-eslint-parser'; -import prettierPlugin from 'eslint-plugin-prettier'; import importPlugin from 'eslint-plugin-import'; -import prettierConfig from 'eslint-config-prettier'; +/* includes the plugin and enables the rules */ +import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended'; import globals from 'globals'; @@ -40,16 +40,24 @@ export default ts.config( js.configs.recommended, ...ts.configs.strictTypeChecked, ...airbnbCompat, - prettierConfig, + prettierRecommendedConfig, { /* all JS/TS files */ files: ['**/*.{js,mjs,cjs,ts}'], + linterOptions: { + /* disable for now */ + // reportUnusedDisableDirectives: 'warn', + }, plugins: { - prettier: prettierPlugin, import: importPlugin, }, rules: { - 'prettier/prettier': ['error'], + 'prettier/prettier': [ + 'error', + { + trailingComma: 'all', + }, + ], /* allow names that start with _ to be unused */ '@typescript-eslint/no-unused-vars': [ 'error', @@ -57,8 +65,8 @@ export default ts.config( args: 'all', argsIgnorePattern: '^_', caughtErrors: 'all', - caughtErrorsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_', + /* varsIgnorePattern affects catch as well */ varsIgnorePattern: '^_', }, ], @@ -115,7 +123,7 @@ export default ts.config( }, }, { - files: ['services/**/*.{js,ts}', 'tools/*.js', 'eslint.config.{js,cjs,mjs}', 'webpack.config.js'], + files: ['services/**/*.{js,ts}', 'tools/*.js', 'eslint.config.{js,mjs,cjs}', 'webpack.config.js'], /* all of these use node */ languageOptions: { globals: { @@ -140,13 +148,18 @@ export default ts.config( }, { files: ['tools/*.js'], + languageOptions: { + /* these scripts run during build, so they can use recent Node.js */ + ecmaVersion: 'latest', + sourceType: 'script', + }, rules: { /* not sure how to tell it these aren't modules */ '@typescript-eslint/no-var-requires': 'off', }, }, { - files: ['*.config.{js,cjs,mjs}'], + files: ['*.config.{js,mjs,cjs}'], rules: { /* obviously we need dev dependencies */ 'import/no-extraneous-dependencies': [ @@ -159,7 +172,7 @@ export default ts.config( }, }, { - files: ['eslint.config.{js,cjs,mjs}'], + files: ['eslint.config.{js,mjs,cjs}'], rules: { /* necessary for flat config */ 'import/no-default-export': 'off', @@ -171,4 +184,11 @@ export default ts.config( '@typescript-eslint/no-var-requires': 'off', }, }, + { + files: ['babel.config.json', 'tsconfig.json'], + rules: { + /* has various issues (e.g., forcing arrays/objects onto a single line) */ + 'prettier/prettier': 'off', + }, + }, ); diff --git a/services/webos-service-remote/execbus.js b/services/webos-service-remote/execbus.js index ff4ae54..6f518c3 100644 --- a/services/webos-service-remote/execbus.js +++ b/services/webos-service-remote/execbus.js @@ -1,4 +1,4 @@ -/* eslint-disable max-classes-per-file, no-underscore-dangle */ +/* eslint-disable max-classes-per-file */ import { EventEmitter } from 'events'; import { spawn } from 'child_process'; import { asyncExecFile } from '../adapter'; @@ -50,7 +50,6 @@ export default class Handle { stdout += data.toString(); let searchPos = 0; let breakPos = 0; - // eslint-disable-next-line no-cond-assign while ((breakPos = stdout.indexOf('\n', searchPos)) > 0) { const line = stdout.substring(searchPos, breakPos).trim(); request.emit('response', Message.constructBody(line, true)); diff --git a/services/webos-service-remote/message.js b/services/webos-service-remote/message.js index 0b93f9e..0a7e8c4 100644 --- a/services/webos-service-remote/message.js +++ b/services/webos-service-remote/message.js @@ -24,7 +24,6 @@ export default class Message { } //* respond to a message, with a JSON-compatible object - // eslint-disable-next-line no-unused-vars respond() { throw new Error('Not implemented'); }