Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint config #6

Merged
merged 50 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f4868ab
Add init version of package.json
mediamonks-thijs May 29, 2020
62c6c4c
add .gitignore file
mediamonks-thijs May 29, 2020
55b8f80
basic implementation of shareable Eslint configuration
mediamonks-thijs Jun 5, 2020
2e09323
Change module name to @mediamonks/eslint-config
mediamonks-thijs Jun 5, 2020
2342c3a
add Eslint configuration
mediamonks-thijs Jun 5, 2020
09f82b7
Update README.md with information about the Eslint extension
mediamonks-thijs Jun 5, 2020
c32cb35
Merge branch 'master' into feature/eslint-config
mediamonks-thijs Jun 5, 2020
543ff5c
Update README.md
Jun 5, 2020
9269c03
Update index.js
Jun 5, 2020
df577b2
Update index.js
Jun 5, 2020
f084efc
Add .vscode to the .gitignore so Visual Studio files won't be added t…
mediamonks-thijs Jun 8, 2020
463b085
Merge remote-tracking branch 'origin/feature/eslint-config' into feat…
mediamonks-thijs Jun 8, 2020
630ceab
Move TypeScript related options (parser and parserOptions) to TypeScr…
mediamonks-thijs Jun 8, 2020
745aa84
Move all React and TypeScript related settings from the main configur…
mediamonks-thijs Jun 8, 2020
de683a6
add configuration for @typescript-eslint/naming-convention linting rule
mediamonks-thijs Jun 8, 2020
9c18dc4
remove 'prettier' from plugins list
mediamonks-thijs Jun 8, 2020
1c7bb85
remove default value from .prettierrc
mediamonks-thijs Jun 8, 2020
bad2b4e
only disable react/prop-types for tsx files, not jsx
mediamonks-thijs Jun 8, 2020
354a713
Extend Airbnb eslint-config
mediamonks-thijs Jun 8, 2020
2672e9b
disable react/jsx-wrap-multilines linting rule
mediamonks-thijs Jun 8, 2020
b1a4ee6
fix formatting
mediamonks-thijs Jun 8, 2020
6573877
Add babel plugin for eslint
mediamonks-thijs Jun 9, 2020
75aa4b5
turn off no-plusplus rule
mediamonks-thijs Jun 9, 2020
80c6b26
add react-hooks linting rules
mediamonks-thijs Jun 9, 2020
659f09c
Update version to 1.1.0
mediamonks-thijs Jun 9, 2020
c02f717
add missing dependencies in install script
mediamonks-thijs Jun 9, 2020
835e4eb
update version to 1.1.1
mediamonks-thijs Jun 9, 2020
dbe5598
move react version settings to reactSettings
mediamonks-thijs Jun 18, 2020
5daef83
set parserOptions for default configurations
mediamonks-thijs Jun 18, 2020
ef389b0
move ecmaFeatures.jsx parserOptions to reactSettings
mediamonks-thijs Jun 18, 2020
e1db7e7
Update installation documentation to use npx
mediamonks-thijs Jun 18, 2020
e96da77
Update index.js
Jun 18, 2020
04f64fd
upgrade dependency @typescript-eslint/parser to >= 3.2
mediamonks-thijs Jun 18, 2020
b23ebf0
Merge remote-tracking branch 'origin/feature/eslint-config' into feat…
mediamonks-thijs Jun 18, 2020
e5f47f1
Update index.js
Jun 18, 2020
b03efd3
add peer dependency for TypeScript
mediamonks-thijs Jun 18, 2020
632c724
Merge remote-tracking branch 'origin/feature/eslint-config' into feat…
mediamonks-thijs Jun 18, 2020
bf2f849
disable single quotes for scss and css files
mediamonks-thijs Jun 18, 2020
7edc2e0
add eslint-plugin-airbnb as peer dependency
mediamonks-thijs Jun 18, 2020
b33b17a
add prettier as peer dependency
mediamonks-thijs Jun 18, 2020
3a3a9f9
add 'prettier/react' in the extends list for the reactSettings
mediamonks-thijs Jun 22, 2020
bfd4be5
add eslint-plugin-vue
mediamonks-thijs Jun 22, 2020
d058d52
Revert "add eslint-plugin-vue"
mediamonks-thijs Jun 22, 2020
9ec26af
Add section about Prettier configuration in the README.md
mediamonks-thijs Jun 22, 2020
637c7e0
Add exception for @typescript-eslint/naming-convention for React func…
mediamonks-thijs Jun 22, 2020
edf1d75
Upgrade version to 1.1.2
mediamonks-thijs Jun 22, 2020
7d8a2ec
Fix wrong peer dependency
mediamonks-thijs Jul 13, 2020
adefa66
move eslint-config related files into the 'eslint-config' directory t…
mediamonks-thijs Nov 12, 2020
11277e5
Merge branch 'main' into feature/eslint-config
mediamonks-thijs Nov 12, 2020
b434c54
Update README.md of the Eslint Config to link to the Coding Standards
mediamonks-thijs Nov 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
.idea
.vscode
node_modules
14 changes: 14 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 100,
"singleQuote": true,
ThijsTyZ marked this conversation as resolved.
Show resolved Hide resolved
"trailingComma": "all",
"proseWrap": "always",
"overrides": [
{
"files": ["*.scss", "*.css"],
"options": {
"singleQuote": false
}
}
]
}
20 changes: 20 additions & 0 deletions eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# MediaMonks - Eslint Configuration

To make sure your project is following the [MediaMonks - Frontend Coding Standards](https://github.com/mediamonks/frontend-coding-standards) you should install `@mediamonks/eslint-config` and its peer dependencies as an [eslint extension](https://eslint.org/docs/user-guide/configuring#extending-configuration-files):

```
npx install-peerdeps --dev @mediamonks/eslint-config
```

And set `@mediamonks` as `extends` in your `.eslintrc.js` file:

```
module.exports = {
"extends": "@mediamonks"
}
```

This Eslint extension is configured for JavaScript, [TypeScript](http://typescriptlang.org/), [React](https://reactjs.org/), [Vue](https://vuejs.org/) and [Muban](https://mediamonks.github.io/muban/) projects.

#### Prettier
This eslint-configuration uses [Prettier](https://prettier.io/) for the formatting. Please make sure you use the same [Prettier configuration](.prettierrc) to avoid conflicts.
224 changes: 224 additions & 0 deletions eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
const typeScriptSettings = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
'plugin:import/typescript'
],
rules: {
'@typescript-eslint/array-type': ['error', { default: 'generic', readonly: 'generic' }],
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error', { functions: false }],
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/prefer-readonly': 'error',
camelcase: 'off',
},
};

const reactSettings = {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended', 'prettier/react'],
settings: {
react: {
version: 'detect',
},
},
rules: {
'react-hooks/exhaustive-deps': 'error',
'react/button-has-type': 'error',
'react/display-name': 'off',
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
'react/jsx-wrap-multilines': 'off',
'react/no-array-index-key': 'error',
'react/no-this-in-sfc': 'error',
'react/no-unused-prop-types': 'error',
'react/no-unused-state': 'error',
'react/void-dom-elements-no-children': 'error',
},
};

module.exports = {
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
extends: ['airbnb', 'plugin:prettier/recommended'],
plugins: ['import', 'unicorn', 'babel'],
env: {
browser: true,
es6: true,
},
globals: {
require: true,
process: true,
},
rules: {
'babel/no-unused-expressions': 'error',
'default-case': 'error',
'import/extensions': [
'error',
'always',
{ js: 'never', jsx: 'never', ts: 'never', tsx: 'never', hbs: 'never', vue: 'never' },
],
'import/no-unresolved': 'error',
'import/order': ['error', { groups: ['external', 'builtin', ['sibling', 'parent']] }],
'import/prefer-default-export': 'off',
'lines-between-class-members': 'off',
'max-lines': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-extra-boolean-cast': 'off',
'no-plusplus': 'off',
'no-restricted-properties': [
'error',
{ object: 'document', property: 'querySelector' },
{ object: 'document', property: 'querySelectorAll' },
],
'no-undef': 'error',
'no-underscore-dangle': 'error',
'no-unused-expressions': 'off',
'react/static-property-placement': 'off',
'unicorn/catch-error-name': 'error',
'unicorn/custom-error-definition': 'off',
'unicorn/error-message': 'error',
'unicorn/escape-case': 'error',
'unicorn/explicit-length-check': 'error',
'unicorn/new-for-builtins': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/no-array-instanceof': 'error',
'unicorn/no-console-spaces': 'error',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/no-for-loop': 'error',
'unicorn/no-hex-escape': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-process-exit': 'error',
'unicorn/no-unreadable-array-destructuring': 'error',
'unicorn/no-unsafe-regex': 'off',
'unicorn/no-unused-properties': 'error',
'unicorn/no-zero-fractions': 'error',
'unicorn/number-literal-case': 'error',
'unicorn/prefer-exponentiation-operator': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-node-remove': 'error',
'unicorn/prefer-query-selector': 'error',
'unicorn/prefer-starts-ends-with': 'error',
'unicorn/prefer-text-content': 'error',
'unicorn/prefer-type-error': 'error',
'unicorn/prevent-abbreviations': [
'error',
{
replacements: {
ref: false,
refs: false,
prop: false,
props: false,
src: false,
param: false,
params: false,
args: false,
},
},
],
'unicorn/throw-new-error': 'error',
},
overrides: [
{
files: ['*.vue'],
parser: 'vue-eslint-parser',
rules: {
'prettier/prettier': ['off'],
},
},
{
files: ['*.ts'],
...typeScriptSettings,
},
{
files: ['*.tsx'],
...typeScriptSettings,
parserOptions: {
...typeScriptSettings.parserOptions,
...reactSettings.parserOptions,
},
extends: [...typeScriptSettings.extends, ...reactSettings.extends],
rules: {
...typeScriptSettings.rules,
...reactSettings.rules,
'react/prop-types': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'variable',
// Exception for FunctionComponents
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'function',
// Exception for FunctionComponents
format: ['camelCase', 'PascalCase'],
},
{
selector: 'enumMember',
format: ['PascalCase'],
},
],
},
},
{
files: ['*.jsx'],
...reactSettings,
},
],
};
62 changes: 62 additions & 0 deletions eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@mediamonks/eslint-config",
"version": "1.1.3",
"description": "MediaMonks Frontend Coding Standards Eslint Config",
"main": "index.js",
"scripts": {
"prettify": "prettier --write \"index.js\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mediamonks/frontend-coding-standards.git"
},
"keywords": [
"MediaMonks",
"Coding",
"Standards",
"eslint",
"eslintconfig",
"Frontend",
"JavaScript",
"TypeScript",
"React",
"Vue",
"Muban"
],
"author": "MediaMonks",
"license": "MIT",
"bugs": {
"url": "https://github.com/mediamonks/frontend-coding-standards/issues"
},
"homepage": "https://github.com/mediamonks/frontend-coding-standards#readme",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": ">= 3",
"eslint": ">= 6",
"eslint-friendly-formatter": ">= 4",
"eslint-import-resolver-webpack": ">= 0.11.0",
"eslint-plugin-babel": ">= 5",
"eslint-plugin-html": ">= 5",
"eslint-plugin-import": ">= 2",
"eslint-plugin-jsx-a11y": ">= 6",
"eslint-plugin-prettier": ">= 3",
"eslint-plugin-react": ">= 7",
"eslint-plugin-react-hooks": ">= 4",
"eslint-plugin-unicorn": ">= 18",
"prettier": "> 2",
"typescript": ">= 3.3"
},
"dependencies": {
"@typescript-eslint/parser": ">= 3.2",
"babel-eslint": "^10.1.0",
"eslint": "^7.1.0",
"eslint-config-airbnb-base": ">= 13",
"eslint-config-airbnb": ">= 18",
"eslint-config-prettier": ">= 4",
"typescript": "^3.9.5",
"vue-eslint-parser": "^7.1.0"
},
"devDependencies": {
"prettier": "^2.0.5"
}
}