From 0cc5a6e3bdb4ce3787da1a536e86a61222458858 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Thu, 9 Jun 2022 16:54:21 -0500 Subject: [PATCH] feat: importable config --- .vscode/settings.json | 3 +++ package.json | 6 +++++- src/index.ts | 29 ++++++++++++----------------- src/rules/README.md | 14 +++++++++++++- tsconfig.json | 6 ++++-- 5 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..72446f43 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/package.json b/package.json index b8af86ea..f2e780d6 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,13 @@ "engines": { "node": ">=14.16.0" }, + "main": "dist/index.js", "type": "commonjs", "files": [ - "dist/**" + "dist", + "package.json", + "README.md", + "LICENSE.txt" ], "dependencies": { "@typescript-eslint/utils": "^5.27.0" diff --git a/src/index.ts b/src/index.ts index 5d6c1f58..7ae9e9a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,27 +12,22 @@ import { flagCrossReferences } from './rules/flagCrossReferences'; export = { configs: { recommended: { - plugins: ['@salesforce/sf-plugin'], + plugins: ['sf-plugin'], rules: { - '@salesforce/sf-plugin/no-duplicate-short-characters': 'error', - '@salesforce/sf-plugin/flag-case': 'error', - '@salesforce/sf-plugin/no-hardcoded-messages': 'warn', - '@salesforce/sf-plugin/flag-cross-references': 'error', + 'sf-plugin/no-duplicate-short-characters': 'error', + 'sf-plugin/flag-case': 'error', + 'sf-plugin/no-hardcoded-messages': 'warn', + 'sf-plugin/flag-cross-references': 'error', }, }, }, rules: { - 'no-duplicate-short-characters': { - create: noDuplicateShortCharacters, - }, - 'flag-case': { - create: flagCasing, - }, - 'no-hardcoded-messages': { - create: extractMessage, - }, - 'flag-cross-references': { - create: flagCrossReferences, - }, + 'no-duplicate-short-characters': noDuplicateShortCharacters, + + 'flag-case': flagCasing, + + 'no-hardcoded-messages': extractMessage, + + 'flag-cross-references': flagCrossReferences, }, }; diff --git a/src/rules/README.md b/src/rules/README.md index 8592c124..1e589455 100644 --- a/src/rules/README.md +++ b/src/rules/README.md @@ -2,6 +2,18 @@ Helpful eslint rules for sf plugins. +## Consume + +`yarn add --dev eslint-plugin-sf-plugin` + +in your `.eslintrc`, add `"plugin:sf-plugin/recommended"` to your`extends` property. example: + +```js +module.exports = { + extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', "plugin:sf-plugin/recommended"], +} +``` + ## Developing Use and choose `@typescript/eslint-parser` from the `` dropdown. This'll give you the AST as the parser sees it. @@ -15,7 +27,7 @@ useful posts * -be sure to import/export your rule with index.ts +be sure to import/export your rule with index.ts and add it the configs sections ## Testing diff --git a/tsconfig.json b/tsconfig.json index 6c73cf4f..6180ac31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,13 @@ { "compilerOptions": { "outDir": "./dist", - "rootDir": "src", - "target": "esnext", + "rootDir": "./src", + "target": "es2019", "moduleResolution": "node", "esModuleInterop": true, "module": "commonjs", + "declaration": false, + "declarationMap": false, }, "include": ["src/**/*.ts", "src/index.js"] }