Skip to content

Commit

Permalink
Add Prettier and ESLint to the builds (Turfjs#1965)
Browse files Browse the repository at this point in the history
* Configure ESlint and Prettier
- Disable all eslint rules that trigger
- Build's lint step now runs monorepoint, prettier, and eslint
- Remove all tslint references

* [auto] run prettier on everything

Co-authored-by: Matt Fedderly <[email protected]>
  • Loading branch information
mfedderly and mfedderly authored Dec 9, 2020
1 parent 2faafab commit 2e9d3d5
Show file tree
Hide file tree
Showing 1,950 changed files with 1,031,132 additions and 798,920 deletions.
57 changes: 44 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,48 @@
const rules = {
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-case-declarations": "off",
"no-cond-assign": "off",
"no-constant-condition": "off",
"no-dupe-else-if": "off",
"no-empty": "off",
"no-explicit-any": "off",
"no-prototype-builtins": "off",
"no-redeclare": "off",
"no-undef": "off",
"no-unreachable": "off",
"no-unused-vars": "off",
"no-useless-escape": "off",
"no-var": "off",
"prefer-const": "off",
"prefer-spread": "off",
};

module.exports = {
extends: 'mourner',
root: true,
extends: ["eslint:recommended", "prettier"],
parserOptions: {
sourceType: 'module'
ecmaVersion: 6,
sourceType: "module",
},
rules: {
strict: [0],
camelcase: [0],
'no-loop-func': [0],
'object-curly-spacing': [0],
'consistent-return': [0],
'valid-jsdoc': [2, {
prefer: {'return': 'returns'},
requireReturn: false
}]
}
overrides: [
{
files: ["**/*.ts", "**/*.tsx"],
env: { es6: true },
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
],
rules,
},
],
rules,
};
140 changes: 75 additions & 65 deletions .monorepolint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const TYPES_PACKAGES = []; // projects that have types tests
const BENCH_PACKAGES = []; // projects that have benchmarks

// iterate all the packages and figure out what buckets everything falls into
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach(pk => {
glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => {
const name = JSON.parse(
fs.readFileSync(path.join(pk, "package.json"), "utf8")
).name;
Expand All @@ -31,10 +31,18 @@ glob.sync(path.join(__dirname, "packages", "turf-*")).forEach(pk => {
}
});

const TS_BENCH_PACKAGES = BENCH_PACKAGES.filter(pkg => -1 !== TS_PACKAGES.indexOf(pkg));
const JS_BENCH_PACKAGES = BENCH_PACKAGES.filter(pkg => -1 !== JS_PACKAGES.indexOf(pkg));
const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter(pkg => -1 !== TS_PACKAGES.indexOf(pkg));
const JS_TAPE_PACKAGES = TAPE_PACKAGES.filter(pkg => -1 !== JS_PACKAGES.indexOf(pkg));
const TS_BENCH_PACKAGES = BENCH_PACKAGES.filter(
(pkg) => -1 !== TS_PACKAGES.indexOf(pkg)
);
const JS_BENCH_PACKAGES = BENCH_PACKAGES.filter(
(pkg) => -1 !== JS_PACKAGES.indexOf(pkg)
);
const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
(pkg) => -1 !== TS_PACKAGES.indexOf(pkg)
);
const JS_TAPE_PACKAGES = TAPE_PACKAGES.filter(
(pkg) => -1 !== JS_PACKAGES.indexOf(pkg)
);

module.exports = {
rules: {
Expand Down Expand Up @@ -65,10 +73,10 @@ module.exports = {
"husky",
"lint-staged",
"devDependencies",
"dependencies"
]
"dependencies",
],
},
includeWorkspaceRoot: true
includeWorkspaceRoot: true,
},

":alphabetical-scripts": {},
Expand All @@ -85,11 +93,11 @@ module.exports = {
files: ["dist", "index.d.ts", "turf.min.js"],
exports: {
import: "./dist/es/index.js",
require: "./dist/js/index.js"
}
}
require: "./dist/js/index.js",
},
},
},
includePackages: [MAIN_PACKAGE]
includePackages: [MAIN_PACKAGE],
},
{
options: {
Expand All @@ -102,142 +110,144 @@ module.exports = {
},
exports: {
import: "./dist/es/index.js",
require: "./dist/js/index.js"
}
}
require: "./dist/js/index.js",
},
},
},
includePackages: [...TS_PACKAGES, ...JS_PACKAGES]
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
},
{
options: {
entries: {
types: "dist/js/index.d.ts",
files: ["dist"]
}
files: ["dist"],
},
},
includePackages: TS_PACKAGES
includePackages: TS_PACKAGES,
},
{
options: {
entries: {
types: "index.d.ts",
files: ["dist", "index.d.ts"]
}
files: ["dist", "index.d.ts"],
},
},
includePackages: JS_PACKAGES
}
includePackages: JS_PACKAGES,
},
],

":package-script": [
{
options: {
scripts: {
docs: "node ../../scripts/generate-readmes",
test: "npm-run-all test:*"
}
test: "npm-run-all test:*",
},
},
excludePackages: [MAIN_PACKAGE]
excludePackages: [MAIN_PACKAGE],
},
{
options: {
scripts: {
build: "npm-run-all build:*",
"build:js": "tsc",
"build:es":
"tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json"
}
'tsc --outDir dist/es --module esnext --declaration false && echo \'{"type":"module"}\' > dist/es/package.json',
},
},
includePackages: TS_PACKAGES
includePackages: TS_PACKAGES,
},
{
options: {
scripts: {
build: "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
posttest: "node -r esm ../../scripts/validate-es5-dependencies.js"
}
build:
'rollup -c ../../rollup.config.js && echo \'{"type":"module"}\' > dist/es/package.json',
posttest: "node -r esm ../../scripts/validate-es5-dependencies.js",
},
},
includePackages: JS_PACKAGES
includePackages: JS_PACKAGES,
},
{
options: {
scripts: {
build: "rollup -c rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json"
}
build:
'rollup -c rollup.config.js && echo \'{"type":"module"}\' > dist/es/package.json',
},
},
includePackages: [MAIN_PACKAGE]
includePackages: [MAIN_PACKAGE],
},
{
options: {
scripts: {
"test:tape": "node -r esm test.js"
}
"test:tape": "node -r esm test.js",
},
},
includePackages: JS_TAPE_PACKAGES
includePackages: JS_TAPE_PACKAGES,
},
{
options: {
scripts: {
"test:tape": "ts-node -r esm test.js"
}
"test:tape": "ts-node -r esm test.js",
},
},
includePackages: TS_TAPE_PACKAGES
includePackages: TS_TAPE_PACKAGES,
},
{
options: {
scripts: {
"bench": "node -r esm bench.js"
}
bench: "node -r esm bench.js",
},
},
includePackages: JS_TAPE_PACKAGES
includePackages: JS_TAPE_PACKAGES,
},
{
options: {
scripts: {
"bench": "ts-node bench.js"
}
bench: "ts-node bench.js",
},
},
includePackages: TS_TAPE_PACKAGES
includePackages: TS_TAPE_PACKAGES,
},
{
options: {
scripts: {
"test:types": "tsc --esModuleInterop --noEmit types.ts"
}
"test:types": "tsc --esModuleInterop --noEmit types.ts",
},
},
includePackages: TYPES_PACKAGES
}
includePackages: TYPES_PACKAGES,
},
],

":alphabetical-dependencies": {
includeWorkspaceRoot: true
includeWorkspaceRoot: true,
},

":require-dependency": [
{
options: {
devDependencies: {
"npm-run-all": "*"
}
"npm-run-all": "*",
},
},
includePackages: [...TS_PACKAGES, ...JS_PACKAGES]
includePackages: [...TS_PACKAGES, ...JS_PACKAGES],
},
{
options: {
devDependencies: {
"ts-node": "*",
typescript: "*"
}
typescript: "*",
},
},
includePackages: TS_PACKAGES
includePackages: TS_PACKAGES,
},
{
options: {
devDependencies: {
rollup: "*"
}
rollup: "*",
},
},
includePackages: JS_PACKAGES
}
]
}
includePackages: JS_PACKAGES,
},
],
},
};
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
*.md
node_modules
tsconfig.json

# slow
packages/turf-directional-mean/test/in/bus_route_gps.json
packages/turf-directional-mean/test/in/bus_route_utm.json

# is actually output
packages/turf/turf.min.js
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 2e9d3d5

Please sign in to comment.