Skip to content

Commit

Permalink
feat: add eslint-plugin-node
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Feb 4, 2021
1 parent 311eb9e commit 816f8cf
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
23 changes: 20 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
const pluginNodeRules = {
"node/no-exports-assign": "error",
"node/process-exit-as-throw": "error",
"node/shebang": "error",
"node/no-deprecated-api": "error",
// "node/file-extension-in-import": ["warn", "always"],
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "error",
}

module.exports = {
// JS Files
root: true,
Expand All @@ -20,16 +30,19 @@ module.exports = {
ecmaVersion: 2021,
sourceType: "module",
},
plugins: ["only-warn"],
plugins: ["node", "only-warn"],
extends: ["eslint:recommended", "plugin:optimize-regex/all", "prettier"],
ignorePatterns: ["node_modules/"],
rules: {
...pluginNodeRules,
},
overrides: [
{
// Bundled node version with atom has an old ESLint
// TypeScript files
files: ["**/*.ts", "**/*.tsx"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "only-warn"],
plugins: ["@typescript-eslint", "node", "only-warn"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
Expand All @@ -46,6 +59,7 @@ module.exports = {
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
...pluginNodeRules,
},
},
{
Expand All @@ -66,8 +80,11 @@ module.exports = {
// CoffeeScript and CSON files
files: ["**/*.coffee", "**/*.cson"],
parser: "eslint-plugin-coffee",
plugins: ["coffee", "only-warn"],
plugins: ["coffee", "node", "only-warn"],
extends: ["plugin:coffee/eslint-recommended", "plugin:optimize-regex/all", "plugin:coffee/prettier"],
rules: {
...pluginNodeRules,
},
},
{
// YAML files
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"babel-eslint": "^10.1.0",
"eslint-plugin-coffee": "^0.1.13",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.2",
"eslint-plugin-optimize-regex": "^1.2.0",
"eslint-config-prettier": "^7.2.0",
Expand Down
31 changes: 30 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions spec/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { mkdir, rm } = require("shelljs")
const execa = require('execa');
const { mkdir, rm } = require("shelljs")
const execa = require("execa")
const { resolve, dirname, join } = require("path")
const pkg = require("../package.json")
const { download, extract } = require("gitly");
const { existsSync } = require("fs");
const { download, extract } = require("gitly")
const { existsSync } = require("fs")

const testRepos = [
"atom-community/atom-ide-hyperclick",
Expand All @@ -17,10 +17,10 @@ const testRepos = [
const root = resolve(dirname(__dirname))
const packedPkg = join(root, `${pkg.name}-${pkg.version}.tgz`)
rm("-rf", packedPkg)
await execa.command("pnpm pack", {cwd: root})
await execa.command("pnpm pack", { cwd: root })

for (const testRepo of testRepos) {
console.log(`Testing ${testRepo}`)
console.log(`Testing ${testRepo}`)

const distFolder = resolve(join(__dirname, "fixtures", testRepo))

Expand All @@ -30,9 +30,8 @@ const testRepos = [
await extract(source, distFolder)
}

await execa.command(`pnpm add "${packedPkg}" --ignore-scripts`, {cwd: distFolder, shell: true})
await execa.command("eslint .", {cwd: distFolder, stdout: 'inherit'})
await execa.command(`pnpm add "${packedPkg}" --ignore-scripts`, { cwd: distFolder, shell: true })
await execa.command("eslint .", { cwd: distFolder, stdout: "inherit" })
}
rm("-rf", packedPkg)

})()

0 comments on commit 816f8cf

Please sign in to comment.