-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): add
dg-scripts
eslint and stylelint configuration
- Loading branch information
1 parent
a8fbe0a
commit 2cb283f
Showing
15 changed files
with
658 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: [ | ||
'standard', | ||
'plugin:import/recommended', | ||
'plugin:eslint-comments/recommended', | ||
'plugin:jsonc/recommended-with-jsonc', | ||
'plugin:yml/standard', | ||
], | ||
plugins: ['html', 'unicorn'], | ||
settings: { | ||
'import/resolver': { | ||
node: { extensions: ['.js', '.mjs', '.ts', '.d.ts'] }, | ||
}, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.json', '*.json5'], | ||
parser: 'jsonc-eslint-parser', | ||
rules: { | ||
quotes: ['error', 'double'], | ||
'quote-props': ['error', 'always'], | ||
'comma-dangle': ['error', 'never'], | ||
}, | ||
}, | ||
{ | ||
files: ['*.yaml', '*.yml'], | ||
parser: 'yaml-eslint-parser', | ||
}, | ||
{ | ||
files: ['package.json'], | ||
parser: 'jsonc-eslint-parser', | ||
rules: { | ||
'jsonc/sort-keys': [ | ||
'error', | ||
{ | ||
pathPattern: '^$', | ||
order: [ | ||
'name', | ||
'version', | ||
'description', | ||
'keywords', | ||
'license', | ||
'repository', | ||
'funding', | ||
'author', | ||
'type', | ||
'files', | ||
'exports', | ||
'main', | ||
'module', | ||
'unpkg', | ||
'bin', | ||
'scripts', | ||
'husky', | ||
'lint-staged', | ||
'peerDependencies', | ||
'peerDependenciesMeta', | ||
'dependencies', | ||
'devDependencies', | ||
'eslintConfig', | ||
], | ||
}, | ||
{ | ||
pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$', | ||
order: { type: 'asc' }, | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
files: ['*.d.ts'], | ||
rules: { | ||
'import/no-duplicates': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['*.js'], | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['scripts/**/*.*'], | ||
rules: { | ||
'no-console': 'off', | ||
}, | ||
}, | ||
], | ||
rules: { | ||
// import | ||
'import/order': 'error', | ||
'import/first': 'error', | ||
'import/no-mutable-exports': 'error', | ||
'import/no-unresolved': 'off', | ||
'import/no-absolute-path': 'off', | ||
|
||
// Common | ||
semi: ['error', 'always'], | ||
curly: ['error', 'multi-or-nest', 'consistent'], | ||
quotes: ['error', 'single'], | ||
'quote-props': ['error', 'as-needed'], | ||
'no-unused-vars': 'warn', | ||
'no-param-reassign': 'off', | ||
'array-bracket-spacing': ['error', 'never'], | ||
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }], | ||
'block-spacing': ['error', 'always'], | ||
camelcase: 'off', | ||
'comma-spacing': ['error', { before: false, after: true }], | ||
'comma-style': ['error', 'last'], | ||
'comma-dangle': ['error', 'always-multiline'], | ||
'no-constant-condition': 'warn', | ||
'no-debugger': 'error', | ||
'no-console': ['error', { allow: ['warn', 'error'] }], | ||
'no-cond-assign': ['error', 'always'], | ||
'func-call-spacing': ['off', 'never'], | ||
'key-spacing': ['error', { beforeColon: false, afterColon: true }], | ||
indent: [ | ||
'error', | ||
2, | ||
{ SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }, | ||
], | ||
'no-restricted-syntax': [ | ||
'error', | ||
'DebuggerStatement', | ||
'ForInStatement', | ||
'LabeledStatement', | ||
'WithStatement', | ||
], | ||
'object-curly-spacing': ['error', 'always'], | ||
'no-return-await': 'off', | ||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'always', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
|
||
// es6 | ||
'no-var': 'error', | ||
'prefer-const': [ | ||
'error', | ||
{ | ||
destructuring: 'any', | ||
ignoreReadBeforeAssign: true, | ||
}, | ||
], | ||
'prefer-arrow-callback': [ | ||
'error', | ||
{ | ||
allowNamedFunctions: false, | ||
allowUnboundThis: true, | ||
}, | ||
], | ||
'object-shorthand': [ | ||
'error', | ||
'always', | ||
{ | ||
ignoreConstructors: false, | ||
avoidQuotes: true, | ||
}, | ||
], | ||
'prefer-rest-params': 'error', | ||
'prefer-spread': 'error', | ||
'prefer-template': 'error', | ||
'template-curly-spacing': 'error', | ||
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }], | ||
'generator-star-spacing': 'off', | ||
|
||
// best-practice | ||
'array-callback-return': 'error', | ||
'block-scoped-var': 'error', | ||
'consistent-return': 'off', | ||
complexity: ['off', 11], | ||
eqeqeq: ['error', 'smart'], | ||
'no-alert': 'warn', | ||
'no-case-declarations': 'error', | ||
'no-multi-spaces': 'error', | ||
'no-multi-str': 'error', | ||
'no-with': 'error', | ||
'no-void': 'error', | ||
'no-useless-escape': 'off', | ||
'vars-on-top': 'error', | ||
'require-await': 'off', | ||
'no-return-assign': 'off', | ||
'operator-linebreak': ['error', 'before'], | ||
|
||
// unicorns | ||
// Pass error message when throwing errors | ||
'unicorn/error-message': 'error', | ||
// Uppercase regex escapes | ||
'unicorn/escape-case': 'error', | ||
// Array.isArray instead of instanceof | ||
'unicorn/no-array-instanceof': 'error', | ||
// Prevent deprecated `new Buffer()` | ||
'unicorn/no-new-buffer': 'error', | ||
// Keep regex literals safe! | ||
'unicorn/no-unsafe-regex': 'off', | ||
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error') | ||
'unicorn/number-literal-case': 'error', | ||
// ** instead of Math.pow() | ||
'unicorn/prefer-exponentiation-operator': 'error', | ||
// includes over indexOf when checking for existence | ||
'unicorn/prefer-includes': 'error', | ||
// String methods startsWith/endsWith instead of more complicated stuff | ||
'unicorn/prefer-starts-ends-with': 'error', | ||
// textContent instead of innerText | ||
'unicorn/prefer-text-content': 'error', | ||
// Enforce throwing type error when throwing error while checking typeof | ||
'unicorn/prefer-type-error': 'error', | ||
// Use new when throwing error | ||
'unicorn/throw-new-error': 'error', | ||
|
||
'no-use-before-define': [ | ||
'error', | ||
{ functions: false, classes: false, variables: true }, | ||
], | ||
'eslint-comments/disable-enable-pair': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "@dg-scripts/eslint-config-basic", | ||
"version": "1.2.0", | ||
"description": "ESLint basic configuration used by dg-scripts.", | ||
"keywords": [ | ||
"dg-scripts", | ||
"lint", | ||
"linter", | ||
"standard", | ||
"eslint" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sabertazimi/bod.git", | ||
"directory": "packages/eslint-config-basic" | ||
}, | ||
"author": "sabertazimi <sabertazimi@gmail.com>", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sabertazimi/bod/issues" | ||
}, | ||
"homepage": "https://github.com/sabertazimi/bod", | ||
"scripts": { | ||
"lint": "eslint . --config=index.js" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.32.0 || >=8.0.0" | ||
}, | ||
"dependencies": { | ||
"eslint-config-standard": "^16.0.3", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-html": "^6.2.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-jsonc": "^1.7.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-unicorn": "^36.0.0", | ||
"eslint-plugin-yml": "^0.10.1", | ||
"jsonc-eslint-parser": "^1.4.1", | ||
"yaml-eslint-parser": "^0.4.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.32.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ['bod', 'bod/jest'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "@dg-scripts/eslint-config-react", | ||
"version": "1.2.0", | ||
"description": "ESLint React configuration used by dg-scripts.", | ||
"keywords": [ | ||
"dg-scripts", | ||
"lint", | ||
"linter", | ||
"standard", | ||
"eslint" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sabertazimi/bod.git", | ||
"directory": "packages/eslint-config-react" | ||
}, | ||
"author": "sabertazimi <sabertazimi@gmail.com>", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sabertazimi/bod/issues" | ||
}, | ||
"homepage": "https://github.com/sabertazimi/bod", | ||
"scripts": { | ||
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --config=index.js" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.32.0 || >=8.0.0" | ||
}, | ||
"dependencies": { | ||
"eslint-config-bod": "^5.4.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.32.0", | ||
"react": "^17.0.2" | ||
} | ||
} |
Oops, something went wrong.