Skip to content

Commit

Permalink
Update for new Deno
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Else committed Apr 3, 2021
1 parent fe551fa commit a1aeef1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
6 changes: 3 additions & 3 deletions deps.ts
@@ -1,8 +1,8 @@
// to update use `udd deps.ts --test="deno test --allow-run ./mod_test.ts"`

export { green, bold } from "https://deno.land/std@0.75.0/fmt/colors.ts";
export { fromFileUrl } from "https://deno.land/std@0.75.0/path/mod.ts";
export { green, bold } from "https://deno.land/std@0.92.0/fmt/colors.ts";
export { fromFileUrl } from "https://deno.land/std@0.92.0/path/mod.ts";
export {
assert,
assertEquals,
} from "https://deno.land/std@0.75.0/testing/asserts.ts";
} from "https://deno.land/std@0.92.0/testing/asserts.ts";
20 changes: 9 additions & 11 deletions mod.ts
@@ -1,16 +1,14 @@
#!/usr/bin/env -S deno run --allow-run --allow-write

/**
* @file Creates a .eslintrc.json config file for typescript-eslint with rules
* @author David Else <david@elsewebdevelopment.com>
* @copyright 2020 David Else
* @license gpl-3.0
* @version 0.9
* tested with deno 1.5.0
* tested with deno 1.8.3
*/

import { assert, fromFileUrl } from "./deps.ts";
import { rulesToAdd, checkedByTypeScript, userRulesToRemove } from "./rules.ts";
import { checkedByTypeScript, rulesToAdd, userRulesToRemove } from "./rules.ts";
import { outputToConsole } from "./view.ts";

export interface EslintRules {
Expand Down Expand Up @@ -42,7 +40,7 @@ const subprocess = Deno.run({
assert(subprocess.stdout);
const commandOutput = await Deno.readAll(subprocess.stdout);
const entireEslintConfig: EslintConfig = JSON.parse(
new TextDecoder().decode(commandOutput)
new TextDecoder().decode(commandOutput),
);

/**
Expand All @@ -60,7 +58,7 @@ export function rulesToRemove(key: string, val: string | number[]): boolean {
!userRulesToRemove.includes(key)
);
}

/**
* Filters a set of ESLint rules and returns an array with the new list and the removed rules
*
Expand All @@ -71,7 +69,7 @@ export function ruleFilter(
esLintRules: EslintRules,
rulesToRemoveCallback: {
(key: string, val: string | number[]): boolean;
}
},
): [EslintRules, string[]] {
const removedRules: string[] = [];
return [
Expand All @@ -84,15 +82,15 @@ export function ruleFilter(
}
removedRules.push(key);
return false;
})
}),
),
removedRules,
];
}

const [filteredEsLintRules, removedRuleNames] = ruleFilter(
entireEslintConfig.rules,
rulesToRemove
rulesToRemove,
);

/**
Expand Down Expand Up @@ -122,7 +120,7 @@ const eslintrcJson = {
if (import.meta.main) {
Deno.writeTextFileSync(
".eslintrc.json",
JSON.stringify(eslintrcJson, null, 2)
JSON.stringify(eslintrcJson, null, 2),
);
outputToConsole(removedRuleNames, Object.keys(rulesToAdd));
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,4 +21,4 @@
"eslint-plugin-import": "2.22.0",
"typescript": "^4.0.2"
}
}
}
17 changes: 7 additions & 10 deletions tsconfig.json
@@ -1,7 +1,6 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
Expand All @@ -23,7 +22,6 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
Expand All @@ -33,13 +31,11 @@
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
Expand All @@ -51,21 +47,22 @@
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["./**/*"],
"exclude": ["node_modules"]
"include": [
"./**/*"
],
"exclude": [
"node_modules"
]
}

0 comments on commit a1aeef1

Please sign in to comment.