Skip to content

Commit

Permalink
Merge pull request #18 from atom-community/import
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Feb 7, 2021
2 parents cc4ffc2 + b2ff0ec commit fe3caed
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The list of used plugins and dependencies:
"@typescript-eslint/parser": "^4.14.2",
"babel-eslint": "^10.1.0",
"eslint-plugin-coffee": "^0.1.13",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.2",
Expand Down
42 changes: 38 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@ const pluginNodeRules = {
"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",
}

const pluginImportExtraRules = {
"import/no-absolute-path": "error",
"import/no-useless-path-segments": "error",
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": "error",
"import/no-unassigned-import": "warn",
"import/no-mutable-exports": "warn",
"import/no-anonymous-default-export": "error",
"import/no-amd": "error",
//// might be too restrictive:
// "import/no-commonjs": "warn",
// "import/no-dynamic-require": "warn", // prevent abusing dynamic require
//// don't work properly:
// "import/unambiguous": "error",
// "import/no-unused-modules": ["warn", {"missingExports": true}],
}

module.exports = {
// JS Files
root: true,
Expand All @@ -30,24 +46,26 @@ module.exports = {
ecmaVersion: 2021,
sourceType: "module",
},
plugins: ["node", "only-warn"],
extends: ["eslint:recommended", "plugin:optimize-regex/all", "prettier"],
plugins: ["node", "import", "only-warn"],
extends: ["eslint:recommended", "plugin:optimize-regex/all", "plugin:import/recommended", "prettier"],
ignorePatterns: ["node_modules/"],
rules: {
...pluginNodeRules,
...pluginImportExtraRules,
},
overrides: [
{
// Bundled node version with atom has an old ESLint
// TypeScript files
files: ["**/*.ts", "**/*.tsx"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "node", "only-warn"],
plugins: ["@typescript-eslint", "node", "import", "only-warn"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:optimize-regex/all",
"plugin:import/recommended",
"prettier",
"prettier/@typescript-eslint",
],
Expand All @@ -60,6 +78,7 @@ module.exports = {
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
...pluginNodeRules,
...pluginImportExtraRules,
},
},
{
Expand All @@ -84,6 +103,7 @@ module.exports = {
extends: ["plugin:coffee/eslint-recommended", "plugin:optimize-regex/all", "plugin:coffee/prettier"],
rules: {
...pluginNodeRules,
...pluginImportExtraRules,
},
},
{
Expand All @@ -93,4 +113,18 @@ module.exports = {
extends: ["plugin:yaml/recommended"],
},
],
settings: {
"import/core-modules": ["atom", "electron"],
// support TypeScript and Coffee importing
"import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx", ".coffee"],
"import/external-module-folders": ["node_modules", "node_modules/@types"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
},
"import/resolver": {
node: {
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx", ".coffee"],
},
},
},
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@typescript-eslint/parser": "^4.14.2",
"babel-eslint": "^10.1.0",
"eslint-plugin-coffee": "^0.1.13",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.2",
Expand Down
86 changes: 69 additions & 17 deletions pnpm-lock.yaml

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

0 comments on commit fe3caed

Please sign in to comment.