Skip to content

Commit

Permalink
Merge branch 'release/0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilgkrishnan committed Dec 26, 2022
2 parents 717416c + cceefde commit 927e463
Show file tree
Hide file tree
Showing 420 changed files with 11,347 additions and 7,954 deletions.
10 changes: 10 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -eu

export PATH="$HOME/.rbenv/bin:$PATH"

eval "$(rbenv init -)"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
3 changes: 3 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- name: ":rspec:"
command: "bundle install && bundle exec rspec --color specs"
5 changes: 5 additions & 0 deletions .buildkite/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Used by the 'Add to Buildkite' button in the readme
name: "Ruby rbenv Example"
steps:
- label: ":pipeline:"
command: "buildkite-agent pipeline upload"
20 changes: 20 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
glob: "app/views/**/*.{html}{+*,}.erb"
exclude:
- "**/vendor/**/*"
- "**/node_modules/**/*"
EnableDefaultLinters: true
linters:
PartialInstanceVariable:
enabled: true
ErbSafety:
enabled: true
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
Style/FrozenStringLiteralComment:
Enabled: false
Layout/TrailingEmptyLines:
Enabled: false
1 change: 1 addition & 0 deletions .eslint-rules/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
13 changes: 13 additions & 0 deletions .eslint-rules/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
// Globals can be disabled with the string "off"
// "writable" to allow the variable to be overwritten or "readonly" to disallow overwriting.
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
// Makes logger function available everywhere. Else eslint will complaint of undef-var.
logger: "readonly",
module: "writable",
// Makes props obtained from Rails backend available everywhere in this project.
globalProps: "readonly",
},
};
49 changes: 49 additions & 0 deletions .eslint-rules/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const fs = require("fs");

const buildPathGroupsBasedOnWebpackAliases = ({
customJSRoot = "app/javascript/",
customAliasPath = "config/webpack/alias.js",
}) => {
const rootOfProject = __dirname + `/../../`;

const isFile = filePath =>
fs.existsSync(filePath) && fs.lstatSync(filePath).isFile();

const webpackAliasPath = rootOfProject + customAliasPath;

const hasWebpackAliasConfig = isFile(webpackAliasPath);

const isRailsProject = isFile(rootOfProject + "Gemfile");

const emptyPathGroups = [];

if (!hasWebpackAliasConfig || !isRailsProject) return emptyPathGroups;

const {
resolve: { alias },
} = require(webpackAliasPath);

const railsJSFilesRoot = rootOfProject + customJSRoot;

const pathGroups = Object.entries(alias).map(([name, path]) => {
// sometimes alias might be already resolved to full absolute path
const isAleadyAnAbsolutePath =
path.includes("cypress-tests/") || path.includes("app/");

const absolutePath = isAleadyAnAbsolutePath
? path
: `${railsJSFilesRoot}${path}`;
const wildCard =
isFile(absolutePath + ".js") || isFile(absolutePath + ".jsx")
? ""
: "/**";

let group = "internal";

return { pattern: `${name}${wildCard}`, group };
});

return pathGroups;
};

module.exports = { buildPathGroupsBasedOnWebpackAliases };
34 changes: 34 additions & 0 deletions .eslint-rules/imports/enforced.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
rules: {
// not-auto-fixable: Prefer a default export if module exports a single name.
"import/prefer-default-export": "off",
// not-auto-fixable: Forbid a module from importing a module with a dependency path back to itself.
"import/no-cycle": ["error", { maxDepth: 1, ignoreExternal: true }],
// not-auto-fixable: Prevent unnecessary path segments in import and require statements.
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
// not-auto-fixable: Report any invalid exports, i.e. re-export of the same name.
"import/export": "error",
// not-auto-fixable: Forbid the use of mutable exports with var or let.
"import/no-mutable-exports": "error",
// not-auto-fixable: Ensure all imports appear before other statements.
"import/first": "error",
// not-auto-fixable: Ensure all exports appear after other statements.
"import/exports-last": "error",
// auto-fixable: Enforce a newline after import statements.
"import/newline-after-import": ["error", { count: 1 }],
// auto-fixable: Remove file extensions for import statements.
"import/extensions": [
"error",
"never",
{
ignorePackages: true,
pattern: {
json: "always",
mp3: "always",
svg: "always",
mapper: "always",
},
},
],
},
};
64 changes: 64 additions & 0 deletions .eslint-rules/imports/order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const { buildPathGroupsBasedOnWebpackAliases } = require(__dirname +
"/../helpers");
const pathGroups = buildPathGroupsBasedOnWebpackAliases({});

const pathGroupForKeepingReactImportsAtTop = {
pattern: "react+(-native|)",
group: "external",
position: "before",
};

/*
Example pathGroups structure. Adding this here
so that if anyone wants to add custom config,
they can make use of this:
[
{ pattern: 'apis/**', group: 'internal' },
{ pattern: 'common/**', group: 'internal' },
{ pattern: 'components/**', group: 'internal' },
{ pattern: 'constants/**', group: 'internal' },
{ pattern: 'contexts/**', group: 'internal' },
{ pattern: 'reducers/**', group: 'internal' },
{ pattern: 'Constants', group: 'internal' },
{
pattern: 'react+(-native|)',
group: 'external',
position: 'before'
}
]
*/
pathGroups.push(pathGroupForKeepingReactImportsAtTop);

module.exports = {
rules: {
// auto-fixable: Enforce a convention in module import order
"import/order": [
"error",
{
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: true },
warnOnUnassignedImports: true,
groups: [
"builtin",
"external",
"internal",
"index",
"sibling",
"parent",
"object",
"type",
],
/*
* Currently we check for existence of webpack alias
* config and then iterate over the aliases and create
* these pathGroups. Only caveat with this mechanism
* is that in VSCode eslint plugin won't dynamically
* read it. But eslint cli would!
*/
pathGroups,
// Ignore react imports so that they're always ordered to the top of the file.
pathGroupsExcludedImportTypes: ["react", "react-native"],
},
],
},
};
24 changes: 24 additions & 0 deletions .eslint-rules/overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
// Currently we are using this section for excluding certain files from certain rules.
overrides: [
{
files: [
".eslintrc.js",
".prettierrc.js",
"app/assets/**/*",
"app/javascript/packs/**/*",
"*.json",
],
rules: {
"import/order": "off",
"react-hooks/rules-of-hooks": "off",
},
},
{
files: ["app/javascript/packs/**/*.{js,jsx}"],
rules: {
"no-redeclare": "off",
},
},
],
};
8 changes: 8 additions & 0 deletions .eslint-rules/promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
rules: {
// not-auto-fixable: ensure people use async/await promising chaining rather than using "then-catch-finally" statements
"promise/prefer-await-to-then": "error",
// auto-fixable: avoid calling "new" on a Promise static method like reject, resolve etc
"promise/no-new-statics": "error",
},
};
92 changes: 92 additions & 0 deletions .eslint-rules/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
module.exports = {
rules: {
// not-auto-fixable: Prevent missing props validation in a React component definition.
"react/prop-types": "off",
// not-auto-fixable: Detect unescaped HTML entities, which might represent malformed tags.
"react/no-unescaped-entities": "off",
// not-auto-fixable: Prevent missing displayName in a React component definition. Useful when using React extensions in browser and checking for component name.
"react/display-name": "error",
// not-auto-fixable: Reports when this.state is accessed within setState.
"react/no-access-state-in-setstate": "error",
// not-auto-fixable: Prevent usage of dangerous JSX props. Currently jam3 plugin will take care of handling this.
"react/no-danger": "off",
// not-auto-fixable: Report when a DOM element is using both children and dangerouslySetInnerHTML.
"react/no-danger-with-children": "warn",
// not-auto-fixable: Prevent definitions of unused prop types.
"react/no-unused-prop-types": "error",
// not-auto-fixable: Report missing key props in iterators/collection literals. Important rule!
"react/jsx-key": "error",
// not-auto-fixable: Enforce no duplicate props.
"react/jsx-no-duplicate-props": "error",
// not-auto-fixable: Disallow undeclared variables in JSX.
"react/jsx-no-undef": "error",
// not-auto-fixable: Enforce PascalCase for user-defined JSX components.
"react/jsx-pascal-case": ["error", { allowNamespace: true }],
// not-auto-fixable: Prevent React to be incorrectly marked as unused.
"react/jsx-uses-react": "error",
// not-auto-fixable: Prevent variables used in JSX to be marked as unused.
"react/jsx-uses-vars": "error",
// not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html.
"react-hooks/rules-of-hooks": "error",
// not-auto-fixable: Ensures https://reactjs.org/docs/hooks-rules.html - Checks effect dependencies.
"react-hooks/exhaustive-deps": "warn",
// auto-fixable: A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
// auto-fixable: Prefer arrow function expressions for component declaration.
"react/function-component-definition": [
"error",
{
namedComponents: "arrow-function",
unnamedComponents: "arrow-function",
},
],
// auto-fixable: Components without children can be self-closed to avoid unnecessary extra closing tag.
"react/self-closing-comp": [
"error",
{
component: true,
html: true,
},
],
// auto-fixable: Wrapping multiline JSX in parentheses can improve readability and/or convenience.
"react/jsx-wrap-multilines": [
"error",
{
declaration: "parens-new-line",
assignment: "parens-new-line",
return: "parens-new-line",
arrow: "parens-new-line",
condition: "parens-new-line",
logical: "parens-new-line",
prop: "ignore",
},
],
// not-auto-fixable: Make sure files containing JSX is having .jsx extension.
"react/jsx-filename-extension": ["error", { allow: "as-needed" }],
// auto-fixable: Omit mentioning the "true" value if it can be implicitly understood in props.
"react/jsx-boolean-value": "error",
// auto-fixable: Partially fixable. Make sure the state and setter have symmertic naming.
"react/hook-use-state": "error",
// auto-fixable: Shorthand notations should always be at the top and also enforce props alphabetical sorting.
"react/jsx-sort-props": [
"error",
{
callbacksLast: true,
shorthandFirst: true,
multiline: "last",
reservedFirst: false,
locale: "auto",
},
],
// auto-fixable: Disallow unnecessary curly braces in JSX props and/or children.
"react/jsx-curly-brace-presence": [
"error",
{
props: "never",
children: "never",
// JSX prop values that are JSX elements should be enclosed in braces.
propElementValues: "always",
},
],
},
};
16 changes: 16 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
build
.eslintrc
public
coverage
db
docs
log
.scripts
test
tmp
.vscode
babel.config.js
app/javascript/packs
jsconfig.json
package.json
Loading

0 comments on commit 927e463

Please sign in to comment.