Skip to content

Commit

Permalink
ESM porting effort (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBaryoPX authored Oct 13, 2024
1 parent 8daa366 commit fecb8a4
Show file tree
Hide file tree
Showing 23 changed files with 446 additions and 546 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

39 changes: 0 additions & 39 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -27,4 +27,4 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm test
- run: npm run test:coverage
6 changes: 2 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx eslint .
npm test
npx eslint .
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Detect different types of JS obfuscation by their AST structure.
## Usage
### Module
```javascript
const fs = require('fs');
const detectObfuscation = require('obfuscation-detector');
import fs from 'node:fs';
import detectObfuscation from 'obfuscation-detector';

const code = fs.readFileSync('obfuscated.js', 'utf-8');
// const all_matching_obfuscation_types = detectObfuscation(code, false);
const most_likely_obfuscation_type = detectObfuscation(code);
// const all_matching_obfuscation_types = detectObfuscation(code, false);
console.log(`Obfuscation type is probably ${most_likely_obfuscation_type}`);
```

Expand Down
2 changes: 1 addition & 1 deletion bin/obfuscation-detector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const fs = require('node:fs');
import fs from 'node:fs';
const detectObfuscation = require(__dirname + '/../src');

if (require.main === module) {
Expand Down
43 changes: 43 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["tests/resources", "**/*tmp*.*", "eslint.config.js", "node_modules/"],
}, ...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
},

ecmaVersion: "latest",
sourceType: "module",
},

rules: {
indent: ["error", "tab", {
SwitchCase: 1,
}],

"linebreak-style": ["error", "unix"],

quotes: ["error", "single", {
allowTemplateLiterals: true,
}],

semi: ["error", "always"],
"no-empty": ["off"],
},
}];
Loading

0 comments on commit fecb8a4

Please sign in to comment.