Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.DS_Store
.idea
.vscode
node_modules
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
Forum One JavaScript Coding Style
Forum One JavaScript Tools
================================

Our coding conventions are minor modifications of [Airbnb's legacy ES5 configuration](https://github.com/airbnb/javascript/tree/es5-deprecated/es5), with customizations for specific environments.

Usage
-----

1. First, you'll need ESLint. Here's a [quick start guide](http://eslint.org/docs/user-guide/getting-started).
2. For bonus points, get your [editor integrated](http://eslint.org/docs/user-guide/integrations).
3. Since we're extending another config, you'll need to read the installation instructions for [`airbnb-base/legacy`](https://www.npmjs.com/package/eslint-config-airbnb-base#eslint-config-airbnb-baselegacy).
4. Run `npm install eslint-config-forumone-es5`.
5. Add `extends: 'forumone-es5'` to your ESLint configuration file.

Modules
-------

### eslint-config-forumone-es5

Forum One's base ES5 ESLint configuration.
Forum One's base JavaScript ESLint configuration.
6 changes: 6 additions & 0 deletions packages/eslint-config-forumone-es5/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 3.0.0
**Breaking Changes**: Basically everything. Requires ESLint 9 and switches to
eslint:recommended as the base config. You probably aren't using version 2, but
if you are, this amounts to a new start.
16 changes: 13 additions & 3 deletions packages/eslint-config-forumone-es5/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
Forum One JavaScript Coding Style (ES5 Edition)
----------------------------------------------
Forum One JavaScript Coding Style
================================

See [forumone/javascript](https://github.com/forumone/javascript) on GitHub for a longer intro.
Our JavaScript code style conventions are based on:
- [ESLint's Recommended Config](https://eslint.org/docs/latest/rules/)
- [TypeScript ESLint](https://typescript-eslint.io/)
- [Prettier](https://prettier.io/docs/related-projects#eslint-integrations)
- [Prettier Plugin: Organize Imports](https://github.com/simonhaenisch/prettier-plugin-organize-imports)
with customizations for specific environments and team practices.

Usage
-----
1. Run `npm install eslint-config-forumone-es5`.
2. Add `extends: 'forumone-es5'` to your ESLint configuration file.
157 changes: 93 additions & 64 deletions packages/eslint-config-forumone-es5/index.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,94 @@
/* eslint-env node, commonjs */

exports.ecmaFeatures = {
impliedStrict: true,
};

// Our ES5 projects are exclusively browser-focused
exports.env = {
browser: true,
node: false,
commonjs: false,
};

exports.extends = 'airbnb-base/legacy';

exports.rules = {
// Overrides of airbnb-base/legacy

// IE8 is dead, we can require trailing commas safely
'comma-dangle': ['error', 'always-multiline'],

// block-scoped-var and no-use-before-define cover the use cases here
// no need to manually hoist as well
'vars-on-top': ['off'],

// Style guidance left to the programmer
'no-else-return': ['off'],
'func-names': ['off'],

// Function hoisting is always safe
'no-use-before-define': ['error', {
functions: false,
}],

// Allow conditionals in loops (but only if you promise that you know what you're doing)
'no-cond-assign': ['error', 'except-parens'],

// Unconditionally require curly braces
curly: ['error', 'all'],

// Additional rules

// Don't leak globals
'no-implicit-globals': 'error',

// Disallow superfluous parentheses, unless you need to disambiguate precedence
'no-extra-parens': ['error', 'all', {
conditionalAssign: false,
nestedBinaryExpressions: false,
}],

// Eventually, this will be an error (and also require parameter descriptions)
'valid-jsdoc': ['warn', {
requireReturn: false,
requireParamDescription: false,
requireReturnDescription: false,

prefer: {
arg: 'param',
argument: 'param',

returns: 'return',
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import prettier from "eslint-config-prettier";
import prettierPlugin from "eslint-plugin-prettier";
import globals from "globals";

/**
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile}
*/
const config = tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
prettier,
{
languageOptions: {
ecmaVersion: "latest",
globals: {
...globals.node,
...globals.browser,
},
sourceType: "module",
},
plugins: {
"@typescript-eslint": tseslint.plugin,
prettier: prettierPlugin,
},
rules: {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
ignoreRestSiblings: true,
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-interface": [
"error",
{
allowSingleExtends: true,
},
],
"@typescript-eslint/no-use-before-define": "error",
eqeqeq: "error",
"no-console": [
"error",
{
allow: ["warn", "error"],
},
],
"no-duplicate-imports": "error",
"no-lonely-if": "error",
"no-param-reassign": [
// Allow modifying props, esp. for DOM Nodes
"error",
{
props: false,
},
],
"no-shadow": "error",
"no-useless-assignment": "error",
"no-var": "error",
"object-shorthand": ["error", "always"],
"prefer-const": "error",
"prefer-destructuring": [
"error",
{
array: false,
object: true,
},
],
"prefer-spread": "error",
"prettier/prettier": "error",
},
},
// TypeScript-specific additions
{
files: ["*.ts", "*.tsx"],
extends: [tseslint.configs.recommendedTypeChecked],
languageOptions: {
parserOptions: {
projectService: true,
},
},
rules: {
"@typescript-eslint/explicit-module-boundary-types": ["error"],
},
}],
};
},
);
export default config;
Loading